From 891df346377be014bbad14c229421d92cfd332ea Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 27 Apr 2017 00:24:17 +0300 Subject: add some basic API unit tests --- tests/ApiTest.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/ApiTest.php (limited to 'tests') diff --git a/tests/ApiTest.php b/tests/ApiTest.php new file mode 100644 index 000000000..7a620d86e --- /dev/null +++ b/tests/ApiTest.php @@ -0,0 +1,70 @@ +$method(); + $rv = json_decode(ob_get_contents(), true); + ob_end_clean(); + + return $rv; + } + + public function testBasicAuth() { + $this->assertEquals(true, + authenticate_user("admin", "password")); + } + + public function testVersion() { + + $ret = $this->apiCall([], "getVersion"); + + $this->assertStringStartsWith( + VERSION_STATIC, + $ret['content']['version']); + } + + public function testLogin() { + + $ret = $this->apiCall(["op" => "login", + "user" => "admin", + "password" => "password"], "login"); + + $this->assertNotEmpty($ret['content']['session_id']); + } + + public function testGetUnread() { + $this->testLogin(); + $ret = $this->apiCall([],"getUnread"); + + $this->assertNotEmpty($ret['content']['unread']); + } + + public function testGetFeeds() { + $this->testLogin(); + $ret = $this->apiCall([], "getFeeds"); + + $this->assertEquals("http://tt-rss.org/forum/rss.php", + $ret['content'][0]['feed_url']); + + } +} -- cgit v1.2.3