X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fapi%2Fcontrollers%2Flinks%2FGetLinkIdTest.php;h=c93a3b4b3139949b7fd023108ee9519b27a7cee3;hb=bcba6bd353161fab456b423e93571ab027d5423c;hp=8bb81dc8f8f1a7c313da25d9c8ce54c1c2dd9d25;hpb=a975d97a8da64864c3c49f1c54f571eb4ea5b81a;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index 8bb81dc8..c93a3b4b 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php @@ -2,10 +2,12 @@ namespace Shaarli\Api\Controllers; +use malkusch\lock\mutex\NoMutex; use Shaarli\Bookmark\Bookmark; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Config\ConfigManager; use Shaarli\History; +use Shaarli\Plugin\PluginManager; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -20,7 +22,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 +57,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 +68,14 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase $this->container = new Container(); $this->container['conf'] = $this->conf; - $this->container['db'] = new BookmarkFileService($this->conf, $history, true); + $pluginManager = new PluginManager($this->conf); + $this->container['db'] = new BookmarkFileService( + $this->conf, + $pluginManager, + $history, + $mutex, + true + ); $this->container['history'] = null; $this->controller = new Links($this->container); @@ -74,7 +84,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase /** * After each test, remove the test datastore. */ - public function tearDown() + protected function tearDown(): void { @unlink(self::$testDatastore); } @@ -120,12 +130,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', ]);