+
+ /**
+ * Test hidden tags feature:
+ * tags starting with a dot '.' are only visible when logged in.
+ */
+ public function testHiddenTags()
+ {
+ $tags = '.hidden';
+ $request = array('searchtags' => $tags);
+ $this->assertEquals(
+ 1,
+ count(self::$privateLinkDB->filterSearch($request, true, false))
+ );
+
+ $this->assertEquals(
+ 0,
+ count(self::$publicLinkDB->filterSearch($request, true, false))
+ );
+ }
+
+ /**
+ * Test filterHash() with a valid smallhash.
+ */
+ public function testFilterHashValid()
+ {
+ $request = smallHash('20150310_114651');
+ $this->assertEquals(
+ 1,
+ count(self::$publicLinkDB->filterHash($request))
+ );
+ $request = smallHash('20150310_114633' . 8);
+ $this->assertEquals(
+ 1,
+ count(self::$publicLinkDB->filterHash($request))
+ );
+ }
+
+ /**
+ * Test filterHash() with an invalid smallhash.
+ *
+ * @expectedException LinkNotFoundException
+ */
+ public function testFilterHashInValid1()
+ {
+ $request = 'blabla';
+ self::$publicLinkDB->filterHash($request);
+ }
+
+ /**
+ * Test filterHash() with an empty smallhash.
+ *
+ * @expectedException LinkNotFoundException
+ */
+ public function testFilterHashInValid()
+ {
+ self::$publicLinkDB->filterHash('');
+ }
+
+ /**
+ * Test reorder with asc/desc parameter.
+ */
+ public function testReorderLinksDesc()
+ {
+ self::$privateLinkDB->reorder('ASC');
+ $linkIds = array(42, 4, 1, 0, 7, 6, 8, 41);
+ $cpt = 0;
+ foreach (self::$privateLinkDB as $key => $value) {
+ $this->assertEquals($linkIds[$cpt++], $key);
+ }
+ self::$privateLinkDB->reorder('DESC');
+ $linkIds = array_reverse($linkIds);
+ $cpt = 0;
+ foreach (self::$privateLinkDB as $key => $value) {
+ $this->assertEquals($linkIds[$cpt++], $key);
+ }
+ }