Maintain local ⭤ remote in sync with automatic AT Protocol parity for Laravel (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpParity\Tests\Unit\Sync;
4
5use SocialDept\AtpParity\Sync\ConflictStrategy;
6use SocialDept\AtpParity\Tests\TestCase;
7
8class ConflictStrategyTest extends TestCase
9{
10 public function test_remote_wins_has_correct_value(): void
11 {
12 $this->assertSame('remote', ConflictStrategy::RemoteWins->value);
13 }
14
15 public function test_local_wins_has_correct_value(): void
16 {
17 $this->assertSame('local', ConflictStrategy::LocalWins->value);
18 }
19
20 public function test_newest_wins_has_correct_value(): void
21 {
22 $this->assertSame('newest', ConflictStrategy::NewestWins->value);
23 }
24
25 public function test_manual_has_correct_value(): void
26 {
27 $this->assertSame('manual', ConflictStrategy::Manual->value);
28 }
29
30 public function test_from_config_returns_remote_wins_by_default(): void
31 {
32 config()->set('parity.conflicts.strategy', 'remote');
33
34 $strategy = ConflictStrategy::fromConfig();
35
36 $this->assertSame(ConflictStrategy::RemoteWins, $strategy);
37 }
38
39 public function test_from_config_returns_local_wins(): void
40 {
41 config()->set('parity.conflicts.strategy', 'local');
42
43 $strategy = ConflictStrategy::fromConfig();
44
45 $this->assertSame(ConflictStrategy::LocalWins, $strategy);
46 }
47
48 public function test_from_config_returns_newest_wins(): void
49 {
50 config()->set('parity.conflicts.strategy', 'newest');
51
52 $strategy = ConflictStrategy::fromConfig();
53
54 $this->assertSame(ConflictStrategy::NewestWins, $strategy);
55 }
56
57 public function test_from_config_returns_manual(): void
58 {
59 config()->set('parity.conflicts.strategy', 'manual');
60
61 $strategy = ConflictStrategy::fromConfig();
62
63 $this->assertSame(ConflictStrategy::Manual, $strategy);
64 }
65
66 public function test_from_config_defaults_to_remote_wins_for_invalid_value(): void
67 {
68 config()->set('parity.conflicts.strategy', 'invalid');
69
70 $strategy = ConflictStrategy::fromConfig();
71
72 $this->assertSame(ConflictStrategy::RemoteWins, $strategy);
73 }
74
75 public function test_from_config_defaults_to_remote_wins_when_not_set(): void
76 {
77 config()->set('parity.conflicts.strategy', null);
78
79 $strategy = ConflictStrategy::fromConfig();
80
81 $this->assertSame(ConflictStrategy::RemoteWins, $strategy);
82 }
83}