]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/api/controllers/info/InfoTest.php
New plugin hook: ability to add custom filters to Shaarli search engine
[github/shaarli/Shaarli.git] / tests / api / controllers / info / InfoTest.php
index 44a9382e847381196d52e5c28393ba056760907e..2428ca4307f2640765d4ab2493bf80e0382139d0 100644 (file)
@@ -1,8 +1,12 @@
 <?php
 namespace Shaarli\Api\Controllers;
 
+use malkusch\lock\mutex\NoMutex;
+use Shaarli\Bookmark\BookmarkFileService;
 use Shaarli\Config\ConfigManager;
-
+use Shaarli\History;
+use Shaarli\Plugin\PluginManager;
+use Shaarli\TestCase;
 use Slim\Container;
 use Slim\Http\Environment;
 use Slim\Http\Request;
@@ -15,7 +19,7 @@ use Slim\Http\Response;
  *
  * @package Api\Controllers
  */
-class InfoTest extends \PHPUnit_Framework_TestCase
+class InfoTest extends TestCase
 {
     /**
      * @var string datastore to test write operations
@@ -43,17 +47,27 @@ class InfoTest extends \PHPUnit_Framework_TestCase
     protected $controller;
 
     /**
-     * Before every test, instantiate a new Api with its config, plugins and links.
+     * Before every test, instantiate a new Api with its config, plugins and bookmarks.
      */
-    public function setUp()
+    protected function setUp(): void
     {
-        $this->conf = new ConfigManager('tests/utils/config/configJson.json.php');
+        $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);
+        $this->pluginManager = new PluginManager($this->conf);
+        $history = new History('sandbox/history.php');
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new BookmarkFileService(
+            $this->conf,
+            $this->pluginManager,
+            $history,
+            $mutex,
+            true
+        );
         $this->container['history'] = null;
 
         $this->controller = new Info($this->container);
@@ -62,7 +76,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
     /**
      * After every test, remove the test datastore.
      */
-    public function tearDown()
+    protected function tearDown(): void
     {
         @unlink(self::$testDatastore);
     }
@@ -85,11 +99,11 @@ class InfoTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(2, $data['private_counter']);
         $this->assertEquals('Shaarli', $data['settings']['title']);
         $this->assertEquals('?', $data['settings']['header_link']);
-        $this->assertEquals('UTC', $data['settings']['timezone']);
+        $this->assertEquals('Europe/Paris', $data['settings']['timezone']);
         $this->assertEquals(ConfigManager::$DEFAULT_PLUGINS, $data['settings']['enabled_plugins']);
-        $this->assertEquals(false, $data['settings']['default_private_links']);
+        $this->assertEquals(true, $data['settings']['default_private_links']);
 
-        $title = 'My links';
+        $title = 'My bookmarks';
         $headerLink = 'http://shaarli.tld';
         $timezone = 'Europe/Paris';
         $enabledPlugins = array('foo', 'bar');