aboutsummaryrefslogtreecommitdiff
path: root/tests/BookmarkTest.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:39:03 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:39:03 +0000
commit17374001b8ccfe806851862c91b29671ba998828 (patch)
tree624a684efb80cb7318ec6c51dd733311f64917de /tests/BookmarkTest.php
parent6a2f1f4f573613400479d427c32b083a7274158b (diff)
downloadsemanticscuttle-17374001b8ccfe806851862c91b29671ba998828.tar.gz
semanticscuttle-17374001b8ccfe806851862c91b29671ba998828.tar.bz2
add SemanticScuttle_Service_Bookmark::bookmarksExist() method to check for existance of multiple bookmarks at once for future sql optimization
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@680 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests/BookmarkTest.php')
-rw-r--r--tests/BookmarkTest.php122
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index 39a9974..74685c4 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -253,6 +253,128 @@ class BookmarkTest extends TestBase
/**
+ * Tests if bookmarksExist() returns true when a bookmark
+ * exists
+ *
+ * @return void
+ */
+ public function testBookmarksExistTrueSingle()
+ {
+ $bid = $this->addBookmark();
+ $bookmark = $this->bs->getBookmark($bid);
+
+ $ret = $this->bs->bookmarksExist(array($bookmark['bAddress']));
+ $this->assertType('array', $ret);
+ $this->assertEquals(1, count($ret));
+ $this->assertTrue($ret[$bookmark['bAddress']]);
+ }
+
+
+
+ /**
+ * Tests if bookmarksExist() returns true when all bookmarks
+ * exist
+ *
+ * @return void
+ */
+ public function testBookmarksExistTrueMultiple()
+ {
+ $bid = $this->addBookmark();
+ $bookmark = $this->bs->getBookmark($bid);
+
+ $bid2 = $this->addBookmark();
+ $bookmark2 = $this->bs->getBookmark($bid2);
+
+
+ $ret = $this->bs->bookmarksExist(
+ array(
+ $bookmark['bAddress'],
+ $bookmark2['bAddress']
+ )
+ );
+ $this->assertType('array', $ret);
+ $this->assertEquals(2, count($ret));
+ $this->assertTrue($ret[$bookmark['bAddress']]);
+ $this->assertTrue($ret[$bookmark2['bAddress']]);
+ }
+
+
+
+ /**
+ * Tests if bookmarksExist() returns false when a bookmark
+ * does not exist
+ *
+ * @return void
+ */
+ public function testBookmarksExistFalseSingle()
+ {
+ $ret = $this->bs->bookmarksExist(array('does-not-exist'));
+ $this->assertType('array', $ret);
+ $this->assertEquals(1, count($ret));
+ $this->assertFalse($ret['does-not-exist']);
+ }
+
+
+
+ /**
+ * Tests if bookmarksExist() returns false when all bookmarks
+ * do not exist
+ *
+ * @return void
+ */
+ public function testBookmarksExistFalseMultiple()
+ {
+ $bms = array(
+ 'does-not-exist',
+ 'does-not-exist-2',
+ 'does-not-exist-3',
+ );
+ $ret = $this->bs->bookmarksExist($bms);
+ $this->assertType('array', $ret);
+ $this->assertEquals(3, count($ret));
+ $this->assertFalse($ret['does-not-exist']);
+ $this->assertFalse($ret['does-not-exist-2']);
+ $this->assertFalse($ret['does-not-exist-3']);
+ }
+
+
+
+ /**
+ * Tests if bookmarksExist() returns true when some bookmarks
+ * exist.
+ *
+ * @return void
+ */
+ public function testBookmarksExistSome()
+ {
+ $bid = $this->addBookmark();
+ $bookmark = $this->bs->getBookmark($bid);
+
+ $bid2 = $this->addBookmark();
+ $bookmark2 = $this->bs->getBookmark($bid2);
+
+
+ $ret = $this->bs->bookmarksExist(
+ array(
+ $bookmark['bAddress'],
+ 'does-not-exist',
+ $bookmark2['bAddress'],
+ 'does-not-exist-2',
+ 'does-not-exist-3'
+ )
+ );
+ $this->assertType('array', $ret);
+ $this->assertEquals(5, count($ret));
+ $this->assertTrue($ret[$bookmark['bAddress']]);
+ $this->assertTrue($ret[$bookmark2['bAddress']]);
+ $this->assertFalse($ret['does-not-exist']);
+ $this->assertFalse($ret['does-not-exist-2']);
+ $this->assertFalse($ret['does-not-exist-3']);
+ }
+
+
+
+ /**
* Test if countBookmarks() works with no bookmarks
*
* @return void