namespace Shaarli\Api\Controllers;
+use malkusch\lock\mutex\NoMutex;
use Shaarli\Api\Exceptions\ApiBadParametersException;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\LinkDB;
use Slim\Http\Request;
use Slim\Http\Response;
-class PutTagTest extends \PHPUnit\Framework\TestCase
+class PutTagTest extends \Shaarli\TestCase
{
/**
* @var string datastore to test write operations
/**
* Before every 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();
$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, $mutex, true);
$this->container = new Container();
$this->container['conf'] = $this->conf;
/**
* After every test, remove the test datastore.
*/
- public function tearDown()
+ protected function tearDown(): void
{
@unlink(self::$testDatastore);
@unlink(self::$testHistory);
/**
* Test tag update with an empty new tag name => ApiBadParametersException
- *
- * @expectedException Shaarli\Api\Exceptions\ApiBadParametersException
- * @expectedExceptionMessage New tag name is required in the request body
*/
public function testPutTagEmpty()
{
+ $this->expectException(\Shaarli\Api\Exceptions\ApiBadParametersException::class);
+ $this->expectExceptionMessage('New tag name is required in the request body');
+
$tagName = 'gnu';
$newName = '';
/**
* Test tag update on non existent tag => ApiTagNotFoundException.
- *
- * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
- * @expectedExceptionMessage Tag not found
*/
public function testPutTag404()
{
+ $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
+ $this->expectExceptionMessage('Tag not found');
+
$env = Environment::mock([
'REQUEST_METHOD' => 'PUT',
]);