BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
- if (empty($_REQUEST['list_id'])) {
+ if (empty($request['list_id'])) {
throw new BadRequestException('list_id not specified');
}
// params
- $count = $_REQUEST['count'] ?? 20;
- $page = $_REQUEST['page'] ?? 1;
- $since_id = $_REQUEST['since_id'] ?? 0;
- $max_id = $_REQUEST['max_id'] ?? 0;
- $exclude_replies = (!empty($_REQUEST['exclude_replies']) ? 1 : 0);
- $conversation_id = $_REQUEST['conversation_id'] ?? 0;
+ $count = $request['count'] ?? 20;
+ $page = $request['page'] ?? 1;
+ $since_id = $request['since_id'] ?? 0;
+ $max_id = $request['max_id'] ?? 0;
+ $exclude_replies = (!empty($request['exclude_replies']) ? 1 : 0);
+ $conversation_id = $request['conversation_id'] ?? 0;
$start = max(0, ($page - 1) * $count);
- $groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => 1]);
+ $groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
$gids = array_column($groups, 'contact-id');
- $condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids];
+ $condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
if ($max_id > 0) {
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
$statuses = Post::selectForUser($uid, [], $condition, $params);
- $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
+ $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
$items = [];
while ($status = DBA::fetch($statuses)) {
namespace Friendica\Test\src\Module\Api\Twitter\Lists;
+use Friendica\App\Router;
+use Friendica\DI;
+use Friendica\Module\Api\Twitter\Lists\Statuses;
+use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest;
class StatusesTest extends ApiTest
*/
public function testApiListsStatuses()
{
- // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- // api_lists_statuses('json');
+ $this->expectException(BadRequestException::class);
+
+ $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
+ $lists->run();
}
/**
* Test the api_lists_statuses() function with a list ID.
- * @doesNotPerformAssertions
*/
public function testApiListsStatusesWithListId()
{
- /*
- $_REQUEST['list_id'] = 1;
- $_REQUEST['page'] = -1;
- $_REQUEST['max_id'] = 10;
- $result = api_lists_statuses('json');
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
+ $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
+ $response = $lists->run(['list_id' => 1, 'page' => -1, 'max_id' => 10]);
+
+ $body = (string)$response->getBody();
+
+ self::assertJson($body);
+
+ $json = json_decode($body);
+
+ foreach ($json as $status) {
+ self::assertIsString($status->text);
+ self::assertIsInt($status->id);
}
- */
}
/**
* Test the api_lists_statuses() function with a list ID and a RSS result.
- *
- * @return void
*/
public function testApiListsStatusesWithListIdAndRss()
{
- // $_REQUEST['list_id'] = 1;
- // $result = api_lists_statuses('rss');
- // self::assertXml($result, 'statuses');
+ $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
+ $response = $lists->run(['list_id' => 1]);
+
+ self::assertXml((string)$response->getBody());
}
/**
*/
public function testApiListsStatusesWithUnallowedUser()
{
+ self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
+
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID();
// api_lists_statuses('json');