X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fapi%2Fcontrollers%2Ftags%2FDeleteTagTest.php;h=37f0722978c2e2ee4fc2a2a45589b4fd28f1ffe0;hb=refs%2Ftags%2Fv0.12.1;hp=b098057273ad5f4a5aa68e64d7ee329ba00093b1;hpb=8f60e1206e45e67c96a7630d4ff94e72fe875f09;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php index b0980572..37f07229 100644 --- a/tests/api/controllers/tags/DeleteTagTest.php +++ b/tests/api/controllers/tags/DeleteTagTest.php @@ -3,6 +3,7 @@ namespace Shaarli\Api\Controllers; +use malkusch\lock\mutex\NoMutex; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; @@ -12,7 +13,7 @@ use Slim\Http\Environment; use Slim\Http\Request; use Slim\Http\Response; -class DeleteTagTest extends \PHPUnit\Framework\TestCase +class DeleteTagTest extends \Shaarli\TestCase { /** * @var string datastore to test write operations @@ -54,11 +55,15 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase */ protected $controller; + /** @var NoMutex */ + protected $mutex; + /** * Before each test, instantiate a new Api with its config, plugins and bookmarks. */ protected function setUp(): void { + $this->mutex = new NoMutex(); $this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf->set('resource.datastore', self::$testDatastore); $this->refDB = new \ReferenceLinkDB(); @@ -66,7 +71,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); $this->history = new History(self::$testHistory); - $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); + $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); $this->container = new Container(); $this->container['conf'] = $this->conf; @@ -102,7 +107,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase $this->assertEquals(204, $response->getStatusCode()); $this->assertEmpty((string) $response->getBody()); - $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); + $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertFalse(isset($tags[$tagName])); @@ -136,7 +141,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase $this->assertEquals(204, $response->getStatusCode()); $this->assertEmpty((string) $response->getBody()); - $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); + $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertFalse(isset($tags[$tagName])); $this->assertTrue($tags[strtolower($tagName)] > 0); @@ -150,12 +155,12 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase /** * Test DELETE tag endpoint: reach not existing tag. - * - * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException - * @expectedExceptionMessage Tag not found */ public function testDeleteLink404() { + $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class); + $this->expectExceptionMessage('Tag not found'); + $tagName = 'nopenope'; $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertFalse(isset($tags[$tagName]));