X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fapi%2Fcontrollers%2Flinks%2FGetLinkIdTest.php;h=1ec56ef3cd97c870fc52b7bbb54875178c52a6ea;hb=fd1ddad98df45bc3c18be7980c1cbe68ce6b219c;hp=c26411ac57d11963f9b091609b5492067b37b03b;hpb=3fb29fdda04ca86e04422d49b86cf646d53c4f9d;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index c26411ac..1ec56ef3 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php @@ -2,6 +2,7 @@ namespace Shaarli\Api\Controllers; +use malkusch\lock\mutex\NoMutex; use Shaarli\Bookmark\Bookmark; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Config\ConfigManager; @@ -20,7 +21,7 @@ use Slim\Http\Response; * * @package Shaarli\Api\Controllers */ -class GetLinkIdTest extends \PHPUnit\Framework\TestCase +class GetLinkIdTest extends \Shaarli\TestCase { /** * @var string datastore to test write operations @@ -55,8 +56,9 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase /** * Before each test, instantiate a new Api with its config, plugins and bookmarks. */ - public function setUp() + protected function setUp(): void { + $mutex = new NoMutex(); $this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf->set('resource.datastore', self::$testDatastore); $this->refDB = new \ReferenceLinkDB(); @@ -65,7 +67,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase $this->container = new Container(); $this->container['conf'] = $this->conf; - $this->container['db'] = new BookmarkFileService($this->conf, $history, true); + $this->container['db'] = new BookmarkFileService($this->conf, $history, $mutex, true); $this->container['history'] = null; $this->controller = new Links($this->container); @@ -74,7 +76,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase /** * After each test, remove the test datastore. */ - public function tearDown() + protected function tearDown(): void { @unlink(self::$testDatastore); } @@ -102,7 +104,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase $this->assertEquals($id, $data['id']); // Check link elements - $this->assertEquals('http://domain.tld/?WDWyig', $data['url']); + $this->assertEquals('http://domain.tld/shaare/WDWyig', $data['url']); $this->assertEquals('WDWyig', $data['shorturl']); $this->assertEquals('Link title: @website', $data['title']); $this->assertEquals( @@ -120,12 +122,12 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase /** * Test basic getLink service: get non existent link => ApiLinkNotFoundException. - * - * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException - * @expectedExceptionMessage Link not found */ public function testGetLink404() { + $this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class); + $this->expectExceptionMessage('Link not found'); + $env = Environment::mock([ 'REQUEST_METHOD' => 'GET', ]);