summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/BookmarkTest.php54
-rw-r--r--tests/Tag2TagTest.php12
-rw-r--r--tests/TestBase.php2
3 files changed, 56 insertions, 12 deletions
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index 0b47bc2..741b6bf 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -69,6 +69,24 @@ class BookmarkTest extends TestBase
$this->vs->deleteAll();
}
+ /**
+ * Tests if adding a bookmark with short url name
+ * saves it in the database.
+ *
+ * @return void
+ */
+ public function testAddBookmarkShort()
+ {
+ $bid = $this->bs->addBookmark(
+ 'http://example.org', 'title', 'desc', 'priv',
+ 0, array(), 'myShortName'
+ );
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertEquals('http://example.org', $bm['bAddress']);
+ $this->assertArrayHasKey('bShort', $bm);
+ $this->assertEquals('myShortName', $bm['bShort']);
+ }
+
public function testHardCharactersInBookmarks()
{
$bs = $this->bs;
@@ -81,7 +99,7 @@ class BookmarkTest extends TestBase
$bid = $bs->addBookmark(
'http://site1.com', $title, $desc, 'note',
0, array($tag1, $tag2),
- null, false, false, $uid
+ null, null, false, false, $uid
);
$bookmarks = $bs->getBookmarks(0, 1);
@@ -108,12 +126,12 @@ class BookmarkTest extends TestBase
$bs->addBookmark(
'http://site1.com', "title", "description", 'note',
- 0, array('tag1'), null, false, false,
+ 0, array('tag1'), null, null, false, false,
$uid
);
$bs->addBookmark(
"http://site1.com", "title2", "description2", 'note',
- 0, array('tag2'), null, false, false,
+ 0, array('tag2'), null, null, false, false,
$uid2
);
@@ -280,7 +298,7 @@ class BookmarkTest extends TestBase
$this->bs->addBookmark(
'http://test', 'test', 'desc', 'note',
2,//private
- array(), null, false, false, $uid
+ array(), null, null, false, false, $uid
);
$this->assertEquals(0, $this->bs->countBookmarks($uid));
$this->assertEquals(0, $this->bs->countBookmarks($uid, 'public'));
@@ -302,7 +320,7 @@ class BookmarkTest extends TestBase
$this->bs->addBookmark(
'http://test', 'test', 'desc', 'note',
1,//shared
- array(), null, false, false, $uid
+ array(), null, null, false, false, $uid
);
$this->assertEquals(0, $this->bs->countBookmarks($uid));
$this->assertEquals(0, $this->bs->countBookmarks($uid, 'public'));
@@ -734,6 +752,32 @@ class BookmarkTest extends TestBase
$this->assertEquals(1, count($bm['tags']));
$this->assertContains('new', $bm['tags']);
}
+
+ /**
+ * Tests if updating a bookmark's short url name
+ * saves it in the database.
+ *
+ * @return void
+ */
+ public function testUpdateBookmarkShort()
+ {
+ $bid = $this->bs->addBookmark(
+ 'http://example.org', 'title', 'desc', 'priv',
+ 0, array(), 'myShortName'
+ );
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertEquals('myShortName', $bm['bShort']);
+
+ $this->assertTrue(
+ $this->bs->updateBookmark(
+ $bid, 'http://example2.org', 'my title', 'desc',
+ 'priv', 0, array(), 'newShortNambb'
+ )
+ );
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertEquals('newShortNambb', $bm['bShort']);
+ }
+
}
diff --git a/tests/Tag2TagTest.php b/tests/Tag2TagTest.php
index f888dd5..d1b6100 100644
--- a/tests/Tag2TagTest.php
+++ b/tests/Tag2TagTest.php
@@ -274,7 +274,7 @@ class Tag2TagTest extends TestBase
$uid = $this->addUser();
$bs->addBookmark(
"http://google.com", "title", "description", 'note',
- 0, $tags, null, false, false,
+ 0, $tags, null, null, false, false,
$uid
);
$bookmark = $bs->getBookmarkByAddress("http://google.com");
@@ -312,17 +312,17 @@ class Tag2TagTest extends TestBase
$tags = array('aa>bb>cc', 'dd');
$bs->addBookmark(
"web1.com", "B1", "description", 'note', 0,
- $tags, null, false, false, 1
+ $tags, null, null, false, false, 1
);
$tags = array('bb>gg', 'ee>ff');
$bs->addBookmark(
"web2.com", "B2", "description", 'note', 0,
- $tags, null, false, false, 1
+ $tags, null, null, false, false, 1
);
$tags = array('ee=ii');
$bs->addBookmark(
"web3.com", "B3", "description", 'note', 0,
- $tags, null, false, false, 1
+ $tags, null, null, false, false, 1
);
// Query format:
@@ -489,12 +489,12 @@ class Tag2TagTest extends TestBase
// with classic tags (users 10 & 20)
$bid1 = $bs->addBookmark(
"http://site1.com", "title", "description", 'note', 0,
- array('tag1', 'tag11', 'tag111'), null, false, false,
+ array('tag1', 'tag11', 'tag111'), null, null, false, false,
$uid1
);
$bid2 = $bs->addBookmark(
"http://site1.com", "title2", "description2", 'note', 0,
- array('tag2', 'tag22', 'tag222'), null, false, false,
+ array('tag2', 'tag22', 'tag222'), null, null, false, false,
$uid2
);
diff --git a/tests/TestBase.php b/tests/TestBase.php
index 86519f3..05988a5 100644
--- a/tests/TestBase.php
+++ b/tests/TestBase.php
@@ -48,7 +48,7 @@ class TestBase extends PHPUnit_Framework_TestCase
null,
0,
array('unittest'),
- null, false, false,
+ null, null, false, false,
$user
);
return $bid;