namespace Shaarli\Api\Controllers;
+use malkusch\lock\mutex\NoMutex;
+use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager;
+use Shaarli\History;
+use Shaarli\Plugin\PluginManager;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
*
* @package Shaarli\Api\Controllers
*/
-class GetTagNameTest extends \PHPUnit\Framework\TestCase
+class GetTagNameTest extends \Shaarli\TestCase
{
/**
* @var string datastore to test write operations
*/
protected $controller;
+ /** @var PluginManager */
+ protected $pluginManager;
+
/**
* Number of JSON fields per link.
*/
const NB_FIELDS_TAG = 2;
/**
- * Before each test, instantiate a new Api with its config, plugins and links.
+ * 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();
$this->refDB->write(self::$testDatastore);
+ $history = new History('sandbox/history.php');
$this->container = new Container();
$this->container['conf'] = $this->conf;
- $this->container['db'] = new LinkDB(self::$testDatastore, true, false);
+ $this->pluginManager = new PluginManager($this->conf);
+ $this->container['db'] = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $history,
+ $mutex,
+ true
+ );
$this->container['history'] = null;
$this->controller = new Tags($this->container);
/**
* After each test, remove the test datastore.
*/
- public function tearDown()
+ protected function tearDown(): void
{
@unlink(self::$testDatastore);
}
/**
* Test basic getTag service: get non existent tag => ApiTagNotFoundException.
- *
- * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
- * @expectedExceptionMessage Tag not found
*/
public function testGetTag404()
{
+ $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
+ $this->expectExceptionMessage('Tag not found');
+
$env = Environment::mock([
'REQUEST_METHOD' => 'GET',
]);