diff options
Diffstat (limited to 'tests/api/controllers/links/PutLinkTest.php')
-rw-r--r-- | tests/api/controllers/links/PutLinkTest.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php index cb63742e..240ee323 100644 --- a/tests/api/controllers/links/PutLinkTest.php +++ b/tests/api/controllers/links/PutLinkTest.php | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | namespace Shaarli\Api\Controllers; | 4 | namespace Shaarli\Api\Controllers; |
5 | 5 | ||
6 | use malkusch\lock\mutex\NoMutex; | ||
6 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
7 | use Shaarli\Bookmark\BookmarkFileService; | 8 | use Shaarli\Bookmark\BookmarkFileService; |
8 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
@@ -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 PutLinkTest extends \PHPUnit\Framework\TestCase | 16 | class PutLinkTest 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 PutLinkTest 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 PutLinkTest 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; |
@@ -91,7 +93,7 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
91 | /** | 93 | /** |
92 | * After every test, remove the test datastore. | 94 | * After every test, remove the test datastore. |
93 | */ | 95 | */ |
94 | public function tearDown() | 96 | protected function tearDown(): void |
95 | { | 97 | { |
96 | @unlink(self::$testDatastore); | 98 | @unlink(self::$testDatastore); |
97 | @unlink(self::$testHistory); | 99 | @unlink(self::$testHistory); |
@@ -114,8 +116,8 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
114 | $this->assertEquals(self::NB_FIELDS_LINK, count($data)); | 116 | $this->assertEquals(self::NB_FIELDS_LINK, count($data)); |
115 | $this->assertEquals($id, $data['id']); | 117 | $this->assertEquals($id, $data['id']); |
116 | $this->assertEquals('WDWyig', $data['shorturl']); | 118 | $this->assertEquals('WDWyig', $data['shorturl']); |
117 | $this->assertEquals('http://domain.tld/?WDWyig', $data['url']); | 119 | $this->assertEquals('http://domain.tld/shaare/WDWyig', $data['url']); |
118 | $this->assertEquals('?WDWyig', $data['title']); | 120 | $this->assertEquals('/shaare/WDWyig', $data['title']); |
119 | $this->assertEquals('', $data['description']); | 121 | $this->assertEquals('', $data['description']); |
120 | $this->assertEquals([], $data['tags']); | 122 | $this->assertEquals([], $data['tags']); |
121 | $this->assertEquals(true, $data['private']); | 123 | $this->assertEquals(true, $data['private']); |
@@ -218,12 +220,12 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase | |||
218 | 220 | ||
219 | /** | 221 | /** |
220 | * Test link update on non existent link => ApiLinkNotFoundException. | 222 | * Test link update on non existent link => ApiLinkNotFoundException. |
221 | * | ||
222 | * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException | ||
223 | * @expectedExceptionMessage Link not found | ||
224 | */ | 223 | */ |
225 | public function testGetLink404() | 224 | public function testGetLink404() |
226 | { | 225 | { |
226 | $this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class); | ||
227 | $this->expectExceptionMessage('Link not found'); | ||
228 | |||
227 | $env = Environment::mock([ | 229 | $env = Environment::mock([ |
228 | 'REQUEST_METHOD' => 'PUT', | 230 | 'REQUEST_METHOD' => 'PUT', |
229 | ]); | 231 | ]); |