aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-08-02 10:34:21 +0200
committerArthurHoaro <arthur@hoa.ro>2016-08-02 10:34:21 +0200
commit9866b40814a120f1a019f9f2c8ef66f44e1ddfcb (patch)
tree2ab5f36db51fb71188c4d978682027f8e1a7e707 /tests
parent32d51093e32e9293e840fbda61cfcfed2d3bd4b6 (diff)
downloadShaarli-9866b40814a120f1a019f9f2c8ef66f44e1ddfcb.tar.gz
Shaarli-9866b40814a120f1a019f9f2c8ef66f44e1ddfcb.tar.zst
Shaarli-9866b40814a120f1a019f9f2c8ef66f44e1ddfcb.zip
Better whitespace handling in tags
Correct PR #573 to work properly with hidden tags, and add ReferenceLinkDB UT. Fixes #571 - Closes #573
Diffstat (limited to 'tests')
-rw-r--r--tests/LinkDBTest.php30
-rw-r--r--tests/utils/ReferenceLinkDB.php2
2 files changed, 5 insertions, 27 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index e413928a..31306069 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -317,6 +317,10 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
317 '-exclude' => 1, 317 '-exclude' => 1,
318 '.hidden' => 1, 318 '.hidden' => 1,
319 'hashtag' => 2, 319 'hashtag' => 2,
320 'tag1' => 1,
321 'tag2' => 1,
322 'tag3' => 1,
323 'tag4' => 1,
320 ), 324 ),
321 self::$privateLinkDB->allTags() 325 self::$privateLinkDB->allTags()
322 ); 326 );
@@ -429,30 +433,4 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
429 { 433 {
430 self::$publicLinkDB->filterHash(''); 434 self::$publicLinkDB->filterHash('');
431 } 435 }
432
433 /**
434 * test whitespace handling in tags.
435 * split on whitespace runs and don't allow empty tags.
436 */
437 public function testReadTagsWithWhitespace()
438 {
439 // test load contains "tags": " tag1 tag2 tag3 tag4 "
440 $ds = '<?php /* ';
441 $ds .= 'fY5BDoMwDAS/gvwB4hRKMY9BEaASNQKUuL1U/L22D721Odheez';
442 $ds .= 'baQEjvQtgSeIdX12I/onfyYAjU6e1GkOL2mAMvMPxAC8mWIydD';
443 $ds .= 'enHsU0jrXlj1heCZk5k7gpX5oLr+ErUdkGBeypTjwXHfdOUItD';
444 $ds .= 'XycbgXHb24KxFYafWVtYvVRoQiQhw5vixrJDdY/LyENP5PcJ4f */ ?>';
445 file_put_contents(self::$testDatastore, $ds);
446 self::$publicLinkDB = new LinkDB(self::$testDatastore, false, false);
447
448 $this->assertEquals(
449 array(
450 'tag1' => 1,
451 'tag2' => 1,
452 'tag3' => 1,
453 'tag4' => 1
454 ),
455 self::$publicLinkDB->allTags()
456 );
457 }
458} 436}
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index fe16baac..fcc7a4f9 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -75,7 +75,7 @@ class ReferenceLinkDB
75 '', 75 '',
76 1, 76 1,
77 '20121206_182539', 77 '20121206_182539',
78 'dev cartoon' 78 'dev cartoon tag1 tag2 tag3 tag4 '
79 ); 79 );
80 } 80 }
81 81