namespace Shaarli\Api\Controllers;
+use malkusch\lock\mutex\NoMutex;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager;
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
*/
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();
$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;
$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->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);
/**
* 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]));