+ $this->assertNotEmpty($linkDB->filterSearch(array('searchtags' => 'exclude')));
+ }
+
+ /**
+ * Convert old PHP config file to JSON config.
+ */
+ public function testConfigToJson()
+ {
+ $configFile = 'tests/utils/config/configPhp';
+ ConfigManager::$CONFIG_FILE = $configFile;
+ $conf = ConfigManager::reset();
+
+ // The ConfigIO is initialized with ConfigPhp.
+ $this->assertTrue($conf->getConfigIO() instanceof ConfigPhp);
+
+ $updater = new Updater(array(), array(), false);
+ $done = $updater->updateMethodConfigToJson();
+ $this->assertTrue($done);
+
+ // The ConfigIO has been updated to ConfigJson.
+ $this->assertTrue($conf->getConfigIO() instanceof ConfigJson);
+ $this->assertTrue(file_exists($conf->getConfigFile()));
+
+ // Check JSON config data.
+ $conf->reload();
+ $this->assertEquals('root', $conf->get('login'));
+ $this->assertEquals('lala', $conf->get('redirector'));
+ $this->assertEquals('data/datastore.php', $conf->get('config.DATASTORE'));
+ $this->assertEquals('1', $conf->get('plugins.WALLABAG_VERSION'));
+
+ rename($configFile . '.save.php', $configFile . '.php');
+ unlink($conf->getConfigFile());
+ }
+
+ /**
+ * Launch config conversion update with an existing JSON file => nothing to do.
+ */
+ public function testConfigToJsonNothingToDo()
+ {
+ $configFile = 'tests/utils/config/configUpdateDone';
+ ConfigManager::$CONFIG_FILE = $configFile;
+ $conf = ConfigManager::reset();
+ $conf->reload();
+ $filetime = filemtime($conf->getConfigFile());
+ $updater = new Updater(array(), array(), false);
+ $done = $updater->updateMethodConfigToJson();
+ $this->assertTrue($done);
+ $expected = filemtime($conf->getConfigFile());
+ $this->assertEquals($expected, $filetime);