|
4 | 4 |
|
5 | 5 | namespace PhpList\Core\Tests\Unit\Domain\Configuration\Service\Manager; |
6 | 6 |
|
| 7 | +use PhpList\Core\Domain\Configuration\Exception\ConfigNotEditableException; |
7 | 8 | use PhpList\Core\Domain\Configuration\Model\Config; |
8 | 9 | use PhpList\Core\Domain\Configuration\Repository\ConfigRepository; |
9 | 10 | use PhpList\Core\Domain\Configuration\Service\Manager\ConfigManager; |
@@ -61,30 +62,13 @@ public function testGetAllReturnsAllConfigsFromRepository(): void |
61 | 62 | $this->assertSame('value2', $result[1]->getValue()); |
62 | 63 | } |
63 | 64 |
|
64 | | - public function testUpdateSavesConfigToRepository(): void |
65 | | - { |
66 | | - $configRepository = $this->createMock(ConfigRepository::class); |
67 | | - $manager = new ConfigManager($configRepository); |
68 | | - |
69 | | - $config = new Config(); |
70 | | - $config->setKey('test_item'); |
71 | | - $config->setValue('test_value'); |
72 | | - $config->setEditable(true); |
73 | | - |
74 | | - $configRepository->expects($this->once()) |
75 | | - ->method('save') |
76 | | - ->with($config); |
77 | | - |
78 | | - $manager->update($config, 'new_value'); |
79 | | - } |
80 | | - |
81 | 65 | public function testCreateSavesNewConfigToRepository(): void |
82 | 66 | { |
83 | 67 | $configRepository = $this->createMock(ConfigRepository::class); |
84 | 68 | $manager = new ConfigManager($configRepository); |
85 | 69 |
|
86 | 70 | $configRepository->expects($this->once()) |
87 | | - ->method('save') |
| 71 | + ->method('persist') |
88 | 72 | ->with($this->callback(function (Config $config) { |
89 | 73 | return $config->getKey() === 'test_key' && |
90 | 74 | $config->getValue() === 'test_value' && |
@@ -119,10 +103,7 @@ public function testUpdateThrowsExceptionWhenConfigIsNotEditable(): void |
119 | 103 | $config->setValue('test_value'); |
120 | 104 | $config->setEditable(false); |
121 | 105 |
|
122 | | - $configRepository->expects($this->never()) |
123 | | - ->method('save'); |
124 | | - |
125 | | - $this->expectException(\PhpList\Core\Domain\Configuration\Exception\ConfigNotEditableException::class); |
| 106 | + $this->expectException(ConfigNotEditableException::class); |
126 | 107 | $this->expectExceptionMessage('Configuration item "test_item" is not editable.'); |
127 | 108 |
|
128 | 109 | $manager->update($config, 'new_value'); |
|
0 commit comments