From 21979ff11ceee0042642ac17147858a4155d54c5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 20 Jan 2016 23:34:33 +0100 Subject: Add exclusion in tag search * Searching '-mytag' will now exlude all shaares with 'mytag' tag. * All tags starting with a '-' are renamed without it (through the Updater). * Unit tests. Minor code changes: * LinkDB->filter() can now take no parameters (get all link depending on logged status). * tagsStrToArray() is now static and filters blank tags. --- tests/Updater/UpdaterTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/Updater/UpdaterTest.php') diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index 63ed5e03..84b82350 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php @@ -13,6 +13,11 @@ class UpdaterTest extends PHPUnit_Framework_TestCase */ private static $configFields; + /** + * @var string Path to test datastore. + */ + protected static $testDatastore = 'sandbox/datastore.php'; + /** * Executed before each test. */ @@ -31,6 +36,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase 'config' => array( 'CONFIG_FILE' => 'tests/Updater/config.php', 'DATADIR' => 'tests/Updater', + 'PAGECACHE' => 'sandbox/pagecache', 'config1' => 'config1data', 'config2' => 'config2data', ) @@ -224,4 +230,16 @@ class UpdaterTest extends PHPUnit_Framework_TestCase include self::$configFields['config']['CONFIG_FILE']; $this->assertEquals(self::$configFields['login'], $GLOBALS['login']); } + + public function testRenameDashTags() + { + $refDB = new ReferenceLinkDB(); + $refDB->write(self::$testDatastore); + $linkDB = new LinkDB(self::$testDatastore, true, false); + $this->assertEmpty($linkDB->filter(LinkFilter::$FILTER_TAG, 'exclude')); + $updater = new Updater(array(), self::$configFields, $linkDB, true); + $updater->updateMethodRenameDashTags(); + var_dump($linkDB->filter(LinkFilter::$FILTER_TAG, 'exclude')); + $this->assertNotEmpty($linkDB->filter(LinkFilter::$FILTER_TAG, 'exclude')); + } } -- cgit v1.2.3