From 32d51093e32e9293e840fbda61cfcfed2d3bd4b6 Mon Sep 17 00:00:00 2001 From: Chris Kuethe Date: Thu, 19 May 2016 12:43:44 -0700 Subject: add unit test --- tests/LinkDBTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/LinkDBTest.php') diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index 46956f20..e413928a 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php @@ -429,4 +429,30 @@ class LinkDBTest extends PHPUnit_Framework_TestCase { self::$publicLinkDB->filterHash(''); } + + /** + * test whitespace handling in tags. + * split on whitespace runs and don't allow empty tags. + */ + public function testReadTagsWithWhitespace() + { + // test load contains "tags": " tag1 tag2 tag3 tag4 " + $ds = ''; + file_put_contents(self::$testDatastore, $ds); + self::$publicLinkDB = new LinkDB(self::$testDatastore, false, false); + + $this->assertEquals( + array( + 'tag1' => 1, + 'tag2' => 1, + 'tag3' => 1, + 'tag4' => 1 + ), + self::$publicLinkDB->allTags() + ); + } } -- cgit v1.2.3