1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-01-19 15:52:10 +01:00

First stubs of BM tests

This commit is contained in:
Brice Maron 2012-10-12 21:06:19 +00:00
parent 380a883fcf
commit d2ea5725c2
2 changed files with 30 additions and 0 deletions

View File

@ -27,6 +27,9 @@ class OC_Bookmarks_Bookmarks{
/** /**
* @brief Finds all tags for bookmarks * @brief Finds all tags for bookmarks
* @param filterTags array of tag to look for if empty then every tag
* @param offset result offset
* @param limit number of item to return
*/ */
public static function findTags($filterTags = array(), $offset = 0, $limit = 10){ public static function findTags($filterTags = array(), $offset = 0, $limit = 10){
$params = array_merge($filterTags, $filterTags); $params = array_merge($filterTags, $filterTags);

27
tests/lib_bookmark.php Normal file
View File

@ -0,0 +1,27 @@
<?php
class Test_LibBookmarks_Bookmarks extends UnitTestCase {
function testAddBM() {
$this->assertCount(0, OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1));
OC_Bookmarks_Bookmarks::addBookmark(
'http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project');
$this->assertCount(1, OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1));
}
function testFindTags() {
$uid=uniqid();
$this->assertEqual(OC_Bookmarks_Bookmarks::findTags(), array());
OC_Bookmarks_Bookmarks::addBookmark(
'http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project');
$this->assertEqual(array(0=>array('tag' => 'cloud', 'nbr'=>1), 1=>array('tag' => 'oc', 'nbr'=>1)),
OC_Bookmarks_Bookmarks::findTags());
}
protected function tearDown() {
$query = OC_DB::prepare('DELETE FROM *PREFIX*bookmarks WHERE `user_id` = \'\' ');
$query->execute();
}
}