aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LinkDBTest.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-03-25 19:20:55 +0100
committerArthur <arthur@hoa.ro>2016-03-25 19:20:55 +0100
commitf66a1990e5d93a6f302ce594968e5e717b93da72 (patch)
tree22e5da81979bc7ee596fcd5c9c56d4c01c599aa4 /tests/LinkDBTest.php
parentb2764886c7b52ed98debb90b2ebf075dec5ae2e8 (diff)
parent528a6f8a232c060faf024008e4f8a09b4aa8dabc (diff)
downloadShaarli-f66a1990e5d93a6f302ce594968e5e717b93da72.tar.gz
Shaarli-f66a1990e5d93a6f302ce594968e5e717b93da72.tar.zst
Shaarli-f66a1990e5d93a6f302ce594968e5e717b93da72.zip
Merge pull request #515 from ArthurHoaro/template-feeds
Refactor RSS feeds generation, and do it through templates
Diffstat (limited to 'tests/LinkDBTest.php')
-rw-r--r--tests/LinkDBTest.php56
1 files changed, 52 insertions, 4 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index b6a273b3..52d31400 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -17,8 +17,20 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
17{ 17{
18 // datastore to test write operations 18 // datastore to test write operations
19 protected static $testDatastore = 'sandbox/datastore.php'; 19 protected static $testDatastore = 'sandbox/datastore.php';
20
21 /**
22 * @var ReferenceLinkDB instance.
23 */
20 protected static $refDB = null; 24 protected static $refDB = null;
25
26 /**
27 * @var LinkDB public LinkDB instance.
28 */
21 protected static $publicLinkDB = null; 29 protected static $publicLinkDB = null;
30
31 /**
32 * @var LinkDB private LinkDB instance.
33 */
22 protected static $privateLinkDB = null; 34 protected static $privateLinkDB = null;
23 35
24 /** 36 /**
@@ -335,9 +347,10 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
335 public function testFilterString() 347 public function testFilterString()
336 { 348 {
337 $tags = 'dev cartoon'; 349 $tags = 'dev cartoon';
350 $request = array('searchtags' => $tags);
338 $this->assertEquals( 351 $this->assertEquals(
339 2, 352 2,
340 count(self::$privateLinkDB->filter(LinkFilter::$FILTER_TAG, $tags, true, false)) 353 count(self::$privateLinkDB->filterSearch($request, true, false))
341 ); 354 );
342 } 355 }
343 356
@@ -347,9 +360,10 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
347 public function testFilterArray() 360 public function testFilterArray()
348 { 361 {
349 $tags = array('dev', 'cartoon'); 362 $tags = array('dev', 'cartoon');
363 $request = array('searchtags' => $tags);
350 $this->assertEquals( 364 $this->assertEquals(
351 2, 365 2,
352 count(self::$privateLinkDB->filter(LinkFilter::$FILTER_TAG, $tags, true, false)) 366 count(self::$privateLinkDB->filterSearch($request, true, false))
353 ); 367 );
354 } 368 }
355 369
@@ -360,14 +374,48 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
360 public function testHiddenTags() 374 public function testHiddenTags()
361 { 375 {
362 $tags = '.hidden'; 376 $tags = '.hidden';
377 $request = array('searchtags' => $tags);
363 $this->assertEquals( 378 $this->assertEquals(
364 1, 379 1,
365 count(self::$privateLinkDB->filter(LinkFilter::$FILTER_TAG, $tags, true, false)) 380 count(self::$privateLinkDB->filterSearch($request, true, false))
366 ); 381 );
367 382
368 $this->assertEquals( 383 $this->assertEquals(
369 0, 384 0,
370 count(self::$publicLinkDB->filter(LinkFilter::$FILTER_TAG, $tags, true, false)) 385 count(self::$publicLinkDB->filterSearch($request, true, false))
371 ); 386 );
372 } 387 }
388
389 /**
390 * Test filterHash() with a valid smallhash.
391 */
392 public function testFilterHashValid()
393 {
394 $request = smallHash('20150310_114651');
395 $this->assertEquals(
396 1,
397 count(self::$publicLinkDB->filterHash($request))
398 );
399 }
400
401 /**
402 * Test filterHash() with an invalid smallhash.
403 *
404 * @expectedException LinkNotFoundException
405 */
406 public function testFilterHashInValid1()
407 {
408 $request = 'blabla';
409 self::$publicLinkDB->filterHash($request);
410 }
411
412 /**
413 * Test filterHash() with an empty smallhash.
414 *
415 * @expectedException LinkNotFoundException
416 */
417 public function testFilterHashInValid()
418 {
419 self::$publicLinkDB->filterHash('');
420 }
373} 421}