diff --git a/src/Module/Api/Twitter/Followers/Lists.php b/src/Module/Api/Twitter/Followers/Lists.php index 5f6696341d..1982d921be 100644 --- a/src/Module/Api/Twitter/Followers/Lists.php +++ b/src/Module/Api/Twitter/Followers/Lists.php @@ -92,6 +92,6 @@ class Lists extends ContactEndpoint self::setLinkHeader(); - System::jsonExit($return); + $this->response->exit('lists', ['lists' => $return]); } } diff --git a/src/Module/Api/Twitter/Friends/Lists.php b/src/Module/Api/Twitter/Friends/Lists.php index 7b38ed3668..16947d0721 100644 --- a/src/Module/Api/Twitter/Friends/Lists.php +++ b/src/Module/Api/Twitter/Friends/Lists.php @@ -92,6 +92,6 @@ class Lists extends ContactEndpoint self::setLinkHeader(); - System::jsonExit($return); + $this->response->exit('lists', ['lists' => $return]); } } diff --git a/tests/src/Module/Api/Twitter/Followers/ListsTest.php b/tests/src/Module/Api/Twitter/Followers/ListsTest.php index 2008227951..c1e053e5a1 100644 --- a/tests/src/Module/Api/Twitter/Followers/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Followers/ListsTest.php @@ -2,30 +2,28 @@ namespace Friendica\Test\src\Module\Api\Twitter\Followers; +use Friendica\App\Router; +use Friendica\DI; +use Friendica\Module\Api\Twitter\Followers\Lists; use Friendica\Test\src\Module\Api\ApiTest; class ListsTest extends ApiTest { /** * Test the api_statuses_f() function. - * - * @return void */ public function testApiStatusesFWithFollowers() { - // $result = api_statuses_f('followers'); - // self::assertArrayHasKey('user', $result); - } + $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); + $response = $lists->run(); - /** - * Test the api_statuses_followers() function. - * - * @return void - */ - public function testApiStatusesFollowers() - { - // $result = api_statuses_followers('json'); - // self::assertArrayHasKey('user', $result); + $body = (string)$response->getBody(); + + self::assertJson($body); + + $json = json_decode($body); + + self::assertIsArray($json->users); } /** @@ -35,6 +33,8 @@ class ListsTest extends ApiTest */ public function testApiStatusesFollowersWithUndefinedCursor() { + self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks'); + // $_GET['cursor'] = 'undefined'; // self::assertFalse(api_statuses_followers('json')); } diff --git a/tests/src/Module/Api/Twitter/Friends/ListsTest.php b/tests/src/Module/Api/Twitter/Friends/ListsTest.php index c4c48daced..fbc5868424 100644 --- a/tests/src/Module/Api/Twitter/Friends/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Friends/ListsTest.php @@ -2,6 +2,9 @@ namespace Friendica\Test\src\Module\Api\Twitter\Friends; +use Friendica\App\Router; +use Friendica\DI; +use Friendica\Module\Api\Twitter\Friends\Lists; use Friendica\Test\src\Module\Api\ApiTest; class ListsTest extends ApiTest @@ -13,7 +16,17 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithFriends() { - // $_GET['page'] = -1; + $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); + $response = $lists->run(); + + $body = (string)$response->getBody(); + + self::assertJson($body); + + $json = json_decode($body); + + self::assertIsArray($json->users); + // $result = api_statuses_f('friends'); // self::assertArrayHasKey('user', $result); } @@ -25,29 +38,9 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithUndefinedCursor() { + self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks'); + // $_GET['cursor'] = 'undefined'; // self::assertFalse(api_statuses_f('friends')); } - - /** - * Test the api_statuses_friends() function. - * - * @return void - */ - public function testApiStatusesFriends() - { - // $result = api_statuses_friends('json'); - // self::assertArrayHasKey('user', $result); - } - - /** - * Test the api_statuses_friends() function an undefined cursor GET variable. - * - * @return void - */ - public function testApiStatusesFriendsWithUndefinedCursor() - { - // $_GET['cursor'] = 'undefined'; - // self::assertFalse(api_statuses_friends('json')); - } }