diff options
Diffstat (limited to 'tests/api/controllers')
-rw-r--r-- | tests/api/controllers/history/HistoryTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/info/InfoTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/links/DeleteLinkTest.php | 10 | ||||
-rw-r--r-- | tests/api/controllers/links/GetLinkIdTest.php | 12 | ||||
-rw-r--r-- | tests/api/controllers/links/GetLinksTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/links/PostLinkTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/links/PutLinkTest.php | 12 | ||||
-rw-r--r-- | tests/api/controllers/tags/DeleteTagTest.php | 12 | ||||
-rw-r--r-- | tests/api/controllers/tags/GetTagNameTest.php | 12 | ||||
-rw-r--r-- | tests/api/controllers/tags/GetTagsTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/tags/PutTagTest.php | 18 |
11 files changed, 53 insertions, 53 deletions
diff --git a/tests/api/controllers/history/HistoryTest.php b/tests/api/controllers/history/HistoryTest.php index f4d3b646..84f8716e 100644 --- a/tests/api/controllers/history/HistoryTest.php +++ b/tests/api/controllers/history/HistoryTest.php | |||
@@ -11,7 +11,7 @@ use Slim\Http\Response; | |||
11 | 11 | ||
12 | require_once 'tests/utils/ReferenceHistory.php'; | 12 | require_once 'tests/utils/ReferenceHistory.php'; |
13 | 13 | ||
14 | class HistoryTest extends \PHPUnit\Framework\TestCase | 14 | class HistoryTest extends \Shaarli\TestCase |
15 | { | 15 | { |
16 | /** | 16 | /** |
17 | * @var string datastore to test write operations | 17 | * @var string datastore to test write operations |
@@ -41,7 +41,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase | |||
41 | /** | 41 | /** |
42 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 42 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
43 | */ | 43 | */ |
44 | public function setUp() | 44 | protected function setUp(): void |
45 | { | 45 | { |
46 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 46 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
47 | $this->refHistory = new \ReferenceHistory(); | 47 | $this->refHistory = new \ReferenceHistory(); |
@@ -57,7 +57,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase | |||
57 | /** | 57 | /** |
58 | * After every test, remove the test datastore. | 58 | * After every test, remove the test datastore. |
59 | */ | 59 | */ |
60 | public function tearDown() | 60 | protected function tearDown(): void |
61 | { | 61 | { |
62 | @unlink(self::$testHistory); | 62 | @unlink(self::$testHistory); |
63 | } | 63 | } |
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php index b5c938e1..1598e1e8 100644 --- a/tests/api/controllers/info/InfoTest.php +++ b/tests/api/controllers/info/InfoTest.php | |||
@@ -1,10 +1,10 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Api\Controllers; | 2 | namespace Shaarli\Api\Controllers; |
3 | 3 | ||
4 | use PHPUnit\Framework\TestCase; | ||
5 | use Shaarli\Bookmark\BookmarkFileService; | 4 | use Shaarli\Bookmark\BookmarkFileService; |
6 | use Shaarli\Config\ConfigManager; | 5 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\History; | 6 | use Shaarli\History; |
7 | use Shaarli\TestCase; | ||
8 | use Slim\Container; | 8 | use Slim\Container; |
9 | use Slim\Http\Environment; | 9 | use Slim\Http\Environment; |
10 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
@@ -47,7 +47,7 @@ class InfoTest extends TestCase | |||
47 | /** | 47 | /** |
48 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 48 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
49 | */ | 49 | */ |
50 | public function setUp() | 50 | protected function setUp(): void |
51 | { | 51 | { |
52 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 52 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
53 | $this->conf->set('resource.datastore', self::$testDatastore); | 53 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -67,7 +67,7 @@ class InfoTest extends TestCase | |||
67 | /** | 67 | /** |
68 | * After every test, remove the test datastore. | 68 | * After every test, remove the test datastore. |
69 | */ | 69 | */ |
70 | public function tearDown() | 70 | protected function tearDown(): void |
71 | { | 71 | { |
72 | @unlink(self::$testDatastore); | 72 | @unlink(self::$testDatastore); |
73 | } | 73 | } |
diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php index 6c2b3698..cf9464f0 100644 --- a/tests/api/controllers/links/DeleteLinkTest.php +++ b/tests/api/controllers/links/DeleteLinkTest.php | |||
@@ -11,7 +11,7 @@ use Slim\Http\Environment; | |||
11 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
12 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
13 | 13 | ||
14 | class DeleteLinkTest extends \PHPUnit\Framework\TestCase | 14 | class DeleteLinkTest extends \Shaarli\TestCase |
15 | { | 15 | { |
16 | /** | 16 | /** |
17 | * @var string datastore to test write operations | 17 | * @var string datastore to test write operations |
@@ -56,7 +56,7 @@ class DeleteLinkTest extends \PHPUnit\Framework\TestCase | |||
56 | /** | 56 | /** |
57 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. | 57 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. |
58 | */ | 58 | */ |
59 | public function setUp() | 59 | protected function setUp(): void |
60 | { | 60 | { |
61 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 61 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
62 | $this->conf->set('resource.datastore', self::$testDatastore); | 62 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -78,7 +78,7 @@ class DeleteLinkTest extends \PHPUnit\Framework\TestCase | |||
78 | /** | 78 | /** |
79 | * After each test, remove the test datastore. | 79 | * After each test, remove the test datastore. |
80 | */ | 80 | */ |
81 | public function tearDown() | 81 | protected function tearDown(): void |
82 | { | 82 | { |
83 | @unlink(self::$testDatastore); | 83 | @unlink(self::$testDatastore); |
84 | @unlink(self::$testHistory); | 84 | @unlink(self::$testHistory); |
@@ -113,11 +113,11 @@ class DeleteLinkTest extends \PHPUnit\Framework\TestCase | |||
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Test DELETE link endpoint: reach not existing ID. | 115 | * Test DELETE link endpoint: reach not existing ID. |
116 | * | ||
117 | * @expectedException \Shaarli\Api\Exceptions\ApiLinkNotFoundException | ||
118 | */ | 116 | */ |
119 | public function testDeleteLink404() | 117 | public function testDeleteLink404() |
120 | { | 118 | { |
119 | $this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class); | ||
120 | |||
121 | $id = -1; | 121 | $id = -1; |
122 | $this->assertFalse($this->bookmarkService->exists($id)); | 122 | $this->assertFalse($this->bookmarkService->exists($id)); |
123 | $env = Environment::mock([ | 123 | $env = Environment::mock([ |
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index 8bb81dc8..99dc606f 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php | |||
@@ -20,7 +20,7 @@ use Slim\Http\Response; | |||
20 | * | 20 | * |
21 | * @package Shaarli\Api\Controllers | 21 | * @package Shaarli\Api\Controllers |
22 | */ | 22 | */ |
23 | class GetLinkIdTest extends \PHPUnit\Framework\TestCase | 23 | class GetLinkIdTest extends \Shaarli\TestCase |
24 | { | 24 | { |
25 | /** | 25 | /** |
26 | * @var string datastore to test write operations | 26 | * @var string datastore to test write operations |
@@ -55,7 +55,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
55 | /** | 55 | /** |
56 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. | 56 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. |
57 | */ | 57 | */ |
58 | public function setUp() | 58 | protected function setUp(): void |
59 | { | 59 | { |
60 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 60 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
61 | $this->conf->set('resource.datastore', self::$testDatastore); | 61 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -74,7 +74,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
74 | /** | 74 | /** |
75 | * After each test, remove the test datastore. | 75 | * After each test, remove the test datastore. |
76 | */ | 76 | */ |
77 | public function tearDown() | 77 | protected function tearDown(): void |
78 | { | 78 | { |
79 | @unlink(self::$testDatastore); | 79 | @unlink(self::$testDatastore); |
80 | } | 80 | } |
@@ -120,12 +120,12 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Test basic getLink service: get non existent link => ApiLinkNotFoundException. | 122 | * Test basic getLink service: get non existent link => ApiLinkNotFoundException. |
123 | * | ||
124 | * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException | ||
125 | * @expectedExceptionMessage Link not found | ||
126 | */ | 123 | */ |
127 | public function testGetLink404() | 124 | public function testGetLink404() |
128 | { | 125 | { |
126 | $this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class); | ||
127 | $this->expectExceptionMessage('Link not found'); | ||
128 | |||
129 | $env = Environment::mock([ | 129 | $env = Environment::mock([ |
130 | 'REQUEST_METHOD' => 'GET', | 130 | 'REQUEST_METHOD' => 'GET', |
131 | ]); | 131 | ]); |
diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php index d02e6fad..ca1bfc63 100644 --- a/tests/api/controllers/links/GetLinksTest.php +++ b/tests/api/controllers/links/GetLinksTest.php | |||
@@ -20,7 +20,7 @@ use Slim\Http\Response; | |||
20 | * | 20 | * |
21 | * @package Shaarli\Api\Controllers | 21 | * @package Shaarli\Api\Controllers |
22 | */ | 22 | */ |
23 | class GetLinksTest extends \PHPUnit\Framework\TestCase | 23 | class GetLinksTest extends \Shaarli\TestCase |
24 | { | 24 | { |
25 | /** | 25 | /** |
26 | * @var string datastore to test write operations | 26 | * @var string datastore to test write operations |
@@ -55,7 +55,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase | |||
55 | /** | 55 | /** |
56 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 56 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
57 | */ | 57 | */ |
58 | public function setUp() | 58 | protected function setUp(): void |
59 | { | 59 | { |
60 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 60 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
61 | $this->conf->set('resource.datastore', self::$testDatastore); | 61 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -74,7 +74,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase | |||
74 | /** | 74 | /** |
75 | * After every test, remove the test datastore. | 75 | * After every test, remove the test datastore. |
76 | */ | 76 | */ |
77 | public function tearDown() | 77 | protected function tearDown(): void |
78 | { | 78 | { |
79 | @unlink(self::$testDatastore); | 79 | @unlink(self::$testDatastore); |
80 | } | 80 | } |
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php index f969fe1c..20694571 100644 --- a/tests/api/controllers/links/PostLinkTest.php +++ b/tests/api/controllers/links/PostLinkTest.php | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Api\Controllers; | 3 | namespace Shaarli\Api\Controllers; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | ||
6 | use Shaarli\Bookmark\Bookmark; | 5 | use Shaarli\Bookmark\Bookmark; |
7 | use Shaarli\Bookmark\BookmarkFileService; | 6 | use Shaarli\Bookmark\BookmarkFileService; |
8 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\History; | 8 | use Shaarli\History; |
9 | use Shaarli\TestCase; | ||
10 | use Slim\Container; | 10 | use Slim\Container; |
11 | use Slim\Http\Environment; | 11 | use Slim\Http\Environment; |
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
@@ -70,7 +70,7 @@ class PostLinkTest extends TestCase | |||
70 | /** | 70 | /** |
71 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 71 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
72 | */ | 72 | */ |
73 | public function setUp() | 73 | protected function setUp(): void |
74 | { | 74 | { |
75 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 75 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
76 | $this->conf->set('resource.datastore', self::$testDatastore); | 76 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -107,7 +107,7 @@ class PostLinkTest extends TestCase | |||
107 | /** | 107 | /** |
108 | * After every test, remove the test datastore. | 108 | * After every test, remove the test datastore. |
109 | */ | 109 | */ |
110 | public function tearDown() | 110 | protected function tearDown(): void |
111 | { | 111 | { |
112 | @unlink(self::$testDatastore); | 112 | @unlink(self::$testDatastore); |
113 | @unlink(self::$testHistory); | 113 | @unlink(self::$testHistory); |
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php index 302cac0f..a2e87c59 100644 --- a/tests/api/controllers/links/PutLinkTest.php +++ b/tests/api/controllers/links/PutLinkTest.php | |||
@@ -12,7 +12,7 @@ use Slim\Http\Environment; | |||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
15 | class PutLinkTest extends \PHPUnit\Framework\TestCase | 15 | class PutLinkTest extends \Shaarli\TestCase |
16 | { | 16 | { |
17 | /** | 17 | /** |
18 | * @var string datastore to test write operations | 18 | * @var string datastore to test write operations |
@@ -62,7 +62,7 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
62 | /** | 62 | /** |
63 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 63 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
64 | */ | 64 | */ |
65 | public function setUp() | 65 | protected function setUp(): void |
66 | { | 66 | { |
67 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 67 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
68 | $this->conf->set('resource.datastore', self::$testDatastore); | 68 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -91,7 +91,7 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
91 | /** | 91 | /** |
92 | * After every test, remove the test datastore. | 92 | * After every test, remove the test datastore. |
93 | */ | 93 | */ |
94 | public function tearDown() | 94 | protected function tearDown(): void |
95 | { | 95 | { |
96 | @unlink(self::$testDatastore); | 96 | @unlink(self::$testDatastore); |
97 | @unlink(self::$testHistory); | 97 | @unlink(self::$testHistory); |
@@ -218,12 +218,12 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
218 | 218 | ||
219 | /** | 219 | /** |
220 | * Test link update on non existent link => ApiLinkNotFoundException. | 220 | * Test link update on non existent link => ApiLinkNotFoundException. |
221 | * | ||
222 | * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException | ||
223 | * @expectedExceptionMessage Link not found | ||
224 | */ | 221 | */ |
225 | public function testGetLink404() | 222 | public function testGetLink404() |
226 | { | 223 | { |
224 | $this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class); | ||
225 | $this->expectExceptionMessage('Link not found'); | ||
226 | |||
227 | $env = Environment::mock([ | 227 | $env = Environment::mock([ |
228 | 'REQUEST_METHOD' => 'PUT', | 228 | 'REQUEST_METHOD' => 'PUT', |
229 | ]); | 229 | ]); |
diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php index c6748872..1326eb47 100644 --- a/tests/api/controllers/tags/DeleteTagTest.php +++ b/tests/api/controllers/tags/DeleteTagTest.php | |||
@@ -12,7 +12,7 @@ use Slim\Http\Environment; | |||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
15 | class DeleteTagTest extends \PHPUnit\Framework\TestCase | 15 | class DeleteTagTest extends \Shaarli\TestCase |
16 | { | 16 | { |
17 | /** | 17 | /** |
18 | * @var string datastore to test write operations | 18 | * @var string datastore to test write operations |
@@ -57,7 +57,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase | |||
57 | /** | 57 | /** |
58 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. | 58 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. |
59 | */ | 59 | */ |
60 | public function setUp() | 60 | protected function setUp(): void |
61 | { | 61 | { |
62 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 62 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
63 | $this->conf->set('resource.datastore', self::$testDatastore); | 63 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -79,7 +79,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase | |||
79 | /** | 79 | /** |
80 | * After each test, remove the test datastore. | 80 | * After each test, remove the test datastore. |
81 | */ | 81 | */ |
82 | public function tearDown() | 82 | protected function tearDown(): void |
83 | { | 83 | { |
84 | @unlink(self::$testDatastore); | 84 | @unlink(self::$testDatastore); |
85 | @unlink(self::$testHistory); | 85 | @unlink(self::$testHistory); |
@@ -150,12 +150,12 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase | |||
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Test DELETE tag endpoint: reach not existing tag. | 152 | * Test DELETE tag endpoint: reach not existing tag. |
153 | * | ||
154 | * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException | ||
155 | * @expectedExceptionMessage Tag not found | ||
156 | */ | 153 | */ |
157 | public function testDeleteLink404() | 154 | public function testDeleteLink404() |
158 | { | 155 | { |
156 | $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class); | ||
157 | $this->expectExceptionMessage('Tag not found'); | ||
158 | |||
159 | $tagName = 'nopenope'; | 159 | $tagName = 'nopenope'; |
160 | $tags = $this->bookmarkService->bookmarksCountPerTag(); | 160 | $tags = $this->bookmarkService->bookmarksCountPerTag(); |
161 | $this->assertFalse(isset($tags[$tagName])); | 161 | $this->assertFalse(isset($tags[$tagName])); |
diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php index b9a81f9b..9c05954b 100644 --- a/tests/api/controllers/tags/GetTagNameTest.php +++ b/tests/api/controllers/tags/GetTagNameTest.php | |||
@@ -18,7 +18,7 @@ use Slim\Http\Response; | |||
18 | * | 18 | * |
19 | * @package Shaarli\Api\Controllers | 19 | * @package Shaarli\Api\Controllers |
20 | */ | 20 | */ |
21 | class GetTagNameTest extends \PHPUnit\Framework\TestCase | 21 | class GetTagNameTest extends \Shaarli\TestCase |
22 | { | 22 | { |
23 | /** | 23 | /** |
24 | * @var string datastore to test write operations | 24 | * @var string datastore to test write operations |
@@ -53,7 +53,7 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase | |||
53 | /** | 53 | /** |
54 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. | 54 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. |
55 | */ | 55 | */ |
56 | public function setUp() | 56 | protected function setUp(): void |
57 | { | 57 | { |
58 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 58 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
59 | $this->conf->set('resource.datastore', self::$testDatastore); | 59 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -72,7 +72,7 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase | |||
72 | /** | 72 | /** |
73 | * After each test, remove the test datastore. | 73 | * After each test, remove the test datastore. |
74 | */ | 74 | */ |
75 | public function tearDown() | 75 | protected function tearDown(): void |
76 | { | 76 | { |
77 | @unlink(self::$testDatastore); | 77 | @unlink(self::$testDatastore); |
78 | } | 78 | } |
@@ -117,12 +117,12 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase | |||
117 | 117 | ||
118 | /** | 118 | /** |
119 | * Test basic getTag service: get non existent tag => ApiTagNotFoundException. | 119 | * Test basic getTag service: get non existent tag => ApiTagNotFoundException. |
120 | * | ||
121 | * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException | ||
122 | * @expectedExceptionMessage Tag not found | ||
123 | */ | 120 | */ |
124 | public function testGetTag404() | 121 | public function testGetTag404() |
125 | { | 122 | { |
123 | $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class); | ||
124 | $this->expectExceptionMessage('Tag not found'); | ||
125 | |||
126 | $env = Environment::mock([ | 126 | $env = Environment::mock([ |
127 | 'REQUEST_METHOD' => 'GET', | 127 | 'REQUEST_METHOD' => 'GET', |
128 | ]); | 128 | ]); |
diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php index 53a3326d..3459fdfa 100644 --- a/tests/api/controllers/tags/GetTagsTest.php +++ b/tests/api/controllers/tags/GetTagsTest.php | |||
@@ -17,7 +17,7 @@ use Slim\Http\Response; | |||
17 | * | 17 | * |
18 | * @package Shaarli\Api\Controllers | 18 | * @package Shaarli\Api\Controllers |
19 | */ | 19 | */ |
20 | class GetTagsTest extends \PHPUnit\Framework\TestCase | 20 | class GetTagsTest extends \Shaarli\TestCase |
21 | { | 21 | { |
22 | /** | 22 | /** |
23 | * @var string datastore to test write operations | 23 | * @var string datastore to test write operations |
@@ -57,7 +57,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase | |||
57 | /** | 57 | /** |
58 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 58 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
59 | */ | 59 | */ |
60 | public function setUp() | 60 | protected function setUp(): void |
61 | { | 61 | { |
62 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 62 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
63 | $this->conf->set('resource.datastore', self::$testDatastore); | 63 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -78,7 +78,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase | |||
78 | /** | 78 | /** |
79 | * After every test, remove the test datastore. | 79 | * After every test, remove the test datastore. |
80 | */ | 80 | */ |
81 | public function tearDown() | 81 | protected function tearDown(): void |
82 | { | 82 | { |
83 | @unlink(self::$testDatastore); | 83 | @unlink(self::$testDatastore); |
84 | } | 84 | } |
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php index 2a3cc15a..74edde78 100644 --- a/tests/api/controllers/tags/PutTagTest.php +++ b/tests/api/controllers/tags/PutTagTest.php | |||
@@ -12,7 +12,7 @@ use Slim\Http\Environment; | |||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
15 | class PutTagTest extends \PHPUnit\Framework\TestCase | 15 | class PutTagTest extends \Shaarli\TestCase |
16 | { | 16 | { |
17 | /** | 17 | /** |
18 | * @var string datastore to test write operations | 18 | * @var string datastore to test write operations |
@@ -62,7 +62,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
62 | /** | 62 | /** |
63 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. | 63 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
64 | */ | 64 | */ |
65 | public function setUp() | 65 | protected function setUp(): void |
66 | { | 66 | { |
67 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 67 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
68 | $this->conf->set('resource.datastore', self::$testDatastore); | 68 | $this->conf->set('resource.datastore', self::$testDatastore); |
@@ -84,7 +84,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
84 | /** | 84 | /** |
85 | * After every test, remove the test datastore. | 85 | * After every test, remove the test datastore. |
86 | */ | 86 | */ |
87 | public function tearDown() | 87 | protected function tearDown(): void |
88 | { | 88 | { |
89 | @unlink(self::$testDatastore); | 89 | @unlink(self::$testDatastore); |
90 | @unlink(self::$testHistory); | 90 | @unlink(self::$testHistory); |
@@ -159,12 +159,12 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Test tag update with an empty new tag name => ApiBadParametersException | 161 | * 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 | */ | 162 | */ |
166 | public function testPutTagEmpty() | 163 | public function testPutTagEmpty() |
167 | { | 164 | { |
165 | $this->expectException(\Shaarli\Api\Exceptions\ApiBadParametersException::class); | ||
166 | $this->expectExceptionMessage('New tag name is required in the request body'); | ||
167 | |||
168 | $tagName = 'gnu'; | 168 | $tagName = 'gnu'; |
169 | $newName = ''; | 169 | $newName = ''; |
170 | 170 | ||
@@ -194,12 +194,12 @@ class PutTagTest extends \PHPUnit\Framework\TestCase | |||
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Test tag update on non existent tag => ApiTagNotFoundException. | 196 | * Test tag update on non existent tag => ApiTagNotFoundException. |
197 | * | ||
198 | * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException | ||
199 | * @expectedExceptionMessage Tag not found | ||
200 | */ | 197 | */ |
201 | public function testPutTag404() | 198 | public function testPutTag404() |
202 | { | 199 | { |
200 | $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class); | ||
201 | $this->expectExceptionMessage('Tag not found'); | ||
202 | |||
203 | $env = Environment::mock([ | 203 | $env = Environment::mock([ |
204 | 'REQUEST_METHOD' => 'PUT', | 204 | 'REQUEST_METHOD' => 'PUT', |
205 | ]); | 205 | ]); |