From 78654369e918126c137b5aa4ba709a7bc0a27b43 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 26 Mar 2011 11:54:47 +0100 Subject: [PATCH] test for beginsWith parameter and a bugfix :) --- tests/ajax/GetContactTagsTest.php | 17 +++++++++++++++++ www/ajax/getcontacttags.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/ajax/GetContactTagsTest.php b/tests/ajax/GetContactTagsTest.php index 757dce9..6e40444 100644 --- a/tests/ajax/GetContactTagsTest.php +++ b/tests/ajax/GetContactTagsTest.php @@ -71,6 +71,23 @@ class ajax_GetContactTagsTest extends TestBaseApi $this->assertContains('public2', $data); $this->assertContains('user2tag', $data); } + + public function testParameterBeginsWith() + { + list($req, $uId) = $this->getLoggedInRequest('?beginsWith=bar'); + $this->addBookmark($uId, null, 0, array('foobar', 'barmann')); + + $res = $req->send(); + $this->assertEquals(200, $res->getStatus()); + $this->assertEquals( + 'application/json; charset=utf-8', + $res->getHeader('content-type') + ); + $data = json_decode($res->getBody()); + $this->assertInternalType('array', $data); + $this->assertEquals(1, count($data)); + $this->assertContains('barmann', $data); + } } diff --git a/www/ajax/getcontacttags.php b/www/ajax/getcontacttags.php index 1377fea..d353226 100644 --- a/www/ajax/getcontacttags.php +++ b/www/ajax/getcontacttags.php @@ -36,7 +36,7 @@ if (isset($_GET['beginsWith']) && strlen(trim($_GET['beginsWith']))) { } $listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getContactTags( - $currentUserId, $limit, $currentUserId, $beginsWith + $currentUserId, $limit, $currentUserId, null, $beginsWith ); $tags = array(); foreach ($listTags as $t) {