<?php
namespace Shaarli\Api\Controllers;
+use malkusch\lock\mutex\NoMutex;
use Shaarli\Bookmark\Bookmark;
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 GetLinksTest extends \PHPUnit\Framework\TestCase
+class GetLinksTest 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();
$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);
/**
* After every test, remove the test datastore.
*/
- public function tearDown()
+ protected function tearDown(): void
{
@unlink(self::$testDatastore);
}
$response = $this->controller->getLinks($request, new Response());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
- $this->assertEquals(4, count($data));
+ $this->assertEquals(5, count($data));
$this->assertEquals(6, $data[0]['id']);
// wildcard: placeholder at the middle