summaryrefslogtreecommitdiff
path: root/tests/ajax
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-03-25 19:26:21 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-25 19:26:21 +0100
commitdb71e63467a26afb8265979f8c8071935ec349b4 (patch)
treed8984f0207c90c47f10698dafd9116162eabf758 /tests/ajax
parentd6e99db40dc88de1782099b30941075ebc8dfa97 (diff)
downloadsemanticscuttle-db71e63467a26afb8265979f8c8071935ec349b4.tar.gz
semanticscuttle-db71e63467a26afb8265979f8c8071935ec349b4.tar.bz2
begin with ajax unittests - but they do not work yet
Diffstat (limited to 'tests/ajax')
-rw-r--r--tests/ajax/GetContactTagsTest.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/ajax/GetContactTagsTest.php b/tests/ajax/GetContactTagsTest.php
new file mode 100644
index 0000000..7f46888
--- /dev/null
+++ b/tests/ajax/GetContactTagsTest.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @author Eric Dane <ericdane@users.sourceforge.net>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+
+require_once dirname(__FILE__) . '/../prepare.php';
+require_once 'HTTP/Request2.php';
+
+/**
+ * Unit tests for the ajax getcontacttags.php script
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+class ajax_GetContactTagsTest extends TestBaseApi
+{
+ protected $urlPart = 'ajax/getcontacttags.php';
+
+
+ /**
+ * If no user is logged in, no data are returned
+ */
+ public function testNoUserLoggedIn()
+ {
+ $res = $this->getRequest()->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(0, count($data));
+ }
+
+
+ public function testUserLoggedIn()
+ {
+ list($req, $uId) = $this->getAuthRequest();
+ $this->addBookmark($uId, null, 0, array('public'));
+ $this->addBookmark($uId, null, 1, array('shared'));
+ $this->addBookmark($uId, null, 2, array('private'));
+
+ $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(3, count($data));
+ $this->assertContains('public', $data);
+ $this->assertContains('shared', $data);
+ $this->assertContains('private', $data);
+ }
+}
+
+
+?> \ No newline at end of file