diff options
Diffstat (limited to 'tests/api/controllers/tags/PutTagTest.php')
-rw-r--r-- | tests/api/controllers/tags/PutTagTest.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php index 2a3cc15a..c73f6d3b 100644 --- a/tests/api/controllers/tags/PutTagTest.php +++ b/tests/api/controllers/tags/PutTagTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Api\Controllers; | 3 | namespace Shaarli\Api\Controllers; |
4 | 4 | ||
5 | use malkusch\lock\mutex\NoMutex; | ||
5 | use Shaarli\Api\Exceptions\ApiBadParametersException; | 6 | use Shaarli\Api\Exceptions\ApiBadParametersException; |
6 | use Shaarli\Bookmark\BookmarkFileService; | 7 | use Shaarli\Bookmark\BookmarkFileService; |
7 | use Shaarli\Bookmark\LinkDB; | 8 | use Shaarli\Bookmark\LinkDB; |
@@ -12,7 +13,7 @@ use Slim\Http\Environment; | |||
12 | use Slim\Http\Request; | 13 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 14 | use Slim\Http\Response; |
14 | 15 | ||
15 | class PutTagTest extends \PHPUnit\Framework\TestCase | 16 | class PutTagTest extends \Shaarli\TestCase |
16 | { | 17 | { |
17 | /** | 18 | /** |
18 | * @var string datastore to test write operations | 19 | * @var string datastore to test write operations |
@@ -62,8 +63,9 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
62 | /** | 63 | /** |
63 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 64 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
64 | */ | 65 | */ |
65 | public function setUp() | 66 | protected function setUp(): void |
66 | { | 67 | { |
68 | $mutex = new NoMutex(); | ||
67 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 69 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
68 | $this->conf->set('resource.datastore', self::$testDatastore); | 70 | $this->conf->set('resource.datastore', self::$testDatastore); |
69 | $this->refDB = new \ReferenceLinkDB(); | 71 | $this->refDB = new \ReferenceLinkDB(); |
@@ -71,7 +73,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
71 | $refHistory = new \ReferenceHistory(); | 73 | $refHistory = new \ReferenceHistory(); |
72 | $refHistory->write(self::$testHistory); | 74 | $refHistory->write(self::$testHistory); |
73 | $this->history = new History(self::$testHistory); | 75 | $this->history = new History(self::$testHistory); |
74 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); | 76 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true); |
75 | 77 | ||
76 | $this->container = new Container(); | 78 | $this->container = new Container(); |
77 | $this->container['conf'] = $this->conf; | 79 | $this->container['conf'] = $this->conf; |
@@ -84,7 +86,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
84 | /** | 86 | /** |
85 | * After every test, remove the test datastore. | 87 | * After every test, remove the test datastore. |
86 | */ | 88 | */ |
87 | public function tearDown() | 89 | protected function tearDown(): void |
88 | { | 90 | { |
89 | @unlink(self::$testDatastore); | 91 | @unlink(self::$testDatastore); |
90 | @unlink(self::$testHistory); | 92 | @unlink(self::$testHistory); |
@@ -159,12 +161,12 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
159 | 161 | ||
160 | /** | 162 | /** |
161 | * Test tag update with an empty new tag name => ApiBadParametersException | 163 | * Test tag update with an empty new tag name => ApiBadParametersException |
162 | * | ||
163 | * @expectedException Shaarli\Api\Exceptions\ApiBadParametersException | ||
164 | * @expectedExceptionMessage New tag name is required in the request body | ||
165 | */ | 164 | */ |
166 | public function testPutTagEmpty() | 165 | public function testPutTagEmpty() |
167 | { | 166 | { |
167 | $this->expectException(\Shaarli\Api\Exceptions\ApiBadParametersException::class); | ||
168 | $this->expectExceptionMessage('New tag name is required in the request body'); | ||
169 | |||
168 | $tagName = 'gnu'; | 170 | $tagName = 'gnu'; |
169 | $newName = ''; | 171 | $newName = ''; |
170 | 172 | ||
@@ -194,12 +196,12 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
194 | 196 | ||
195 | /** | 197 | /** |
196 | * Test tag update on non existent tag => ApiTagNotFoundException. | 198 | * Test tag update on non existent tag => ApiTagNotFoundException. |
197 | * | ||
198 | * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException | ||
199 | * @expectedExceptionMessage Tag not found | ||
200 | */ | 199 | */ |
201 | public function testPutTag404() | 200 | public function testPutTag404() |
202 | { | 201 | { |
202 | $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class); | ||
203 | $this->expectExceptionMessage('Tag not found'); | ||
204 | |||
203 | $env = Environment::mock([ | 205 | $env = Environment::mock([ |
204 | 'REQUEST_METHOD' => 'PUT', | 206 | 'REQUEST_METHOD' => 'PUT', |
205 | ]); | 207 | ]); |