2 use PHPUnit\Framework\TestCase
;
4 set_include_path(dirname(__DIR__
) ."/include" . PATH_SEPARATOR
.
5 dirname(__DIR__
) . PATH_SEPARATOR
.
8 require_once "autoload.php";
10 final class ApiTest
extends TestCase
{
12 public function __construct() {
14 initialize_user_prefs(1);
15 set_pref('ENABLE_API_ACCESS', true, 1);
17 parent
::__construct();
20 public function apiCall($args, $method) {
23 $api = new API($args);
26 $rv = json_decode(ob_get_contents(), true);
32 public function testBasicAuth() {
33 $this->assertEquals(true,
34 authenticate_user("admin", "password"));
37 public function testVersion() {
39 $ret = $this->apiCall([], "getVersion");
41 $this->assertStringStartsWith(
43 $ret['content']['version']);
46 public function testLogin() {
48 $ret = $this->apiCall(["op" => "login",
50 "password" => "password"], "login");
52 $this->assertNotEmpty($ret['content']['session_id']);
55 public function testGetUnread() {
57 $ret = $this->apiCall([],"getUnread");
59 $this->assertNotEmpty($ret['content']['unread']);
62 public function testGetFeeds() {
64 $ret = $this->apiCall([], "getFeeds");
66 $this->assertEquals("http://tt-rss.org/forum/rss.php",
67 $ret['content'][0]['feed_url']);