Fix Twitter statuses list & reenable tests
This commit is contained in:
parent
85b9f2b02c
commit
9081b37762
|
@ -40,23 +40,23 @@ class Statuses extends BaseApi
|
||||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||||
$uid = BaseApi::getCurrentUserID();
|
$uid = BaseApi::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($_REQUEST['list_id'])) {
|
if (empty($request['list_id'])) {
|
||||||
throw new BadRequestException('list_id not specified');
|
throw new BadRequestException('list_id not specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
// params
|
// params
|
||||||
$count = $_REQUEST['count'] ?? 20;
|
$count = $request['count'] ?? 20;
|
||||||
$page = $_REQUEST['page'] ?? 1;
|
$page = $request['page'] ?? 1;
|
||||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
$since_id = $request['since_id'] ?? 0;
|
||||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
$max_id = $request['max_id'] ?? 0;
|
||||||
$exclude_replies = (!empty($_REQUEST['exclude_replies']) ? 1 : 0);
|
$exclude_replies = (!empty($request['exclude_replies']) ? 1 : 0);
|
||||||
$conversation_id = $_REQUEST['conversation_id'] ?? 0;
|
$conversation_id = $request['conversation_id'] ?? 0;
|
||||||
|
|
||||||
$start = max(0, ($page - 1) * $count);
|
$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');
|
$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]);
|
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
|
@ -75,7 +75,7 @@ class Statuses extends BaseApi
|
||||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||||
|
|
||||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
while ($status = DBA::fetch($statuses)) {
|
while ($status = DBA::fetch($statuses)) {
|
||||||
|
|
|
@ -827,6 +827,13 @@ return [
|
||||||
'name' => 'Private list',
|
'name' => 'Private list',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'group_member' => [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'gid' => 1,
|
||||||
|
'contact-id' => 42,
|
||||||
|
],
|
||||||
|
],
|
||||||
'search' => [
|
'search' => [
|
||||||
[
|
[
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Twitter\Lists;
|
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;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
|
||||||
class StatusesTest extends ApiTest
|
class StatusesTest extends ApiTest
|
||||||
|
@ -13,37 +17,41 @@ class StatusesTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiListsStatuses()
|
public function testApiListsStatuses()
|
||||||
{
|
{
|
||||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
// api_lists_statuses('json');
|
|
||||||
|
$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.
|
* Test the api_lists_statuses() function with a list ID.
|
||||||
* @doesNotPerformAssertions
|
|
||||||
*/
|
*/
|
||||||
public function testApiListsStatusesWithListId()
|
public function testApiListsStatusesWithListId()
|
||||||
{
|
{
|
||||||
/*
|
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
$_REQUEST['list_id'] = 1;
|
$response = $lists->run(['list_id' => 1, 'page' => -1, 'max_id' => 10]);
|
||||||
$_REQUEST['page'] = -1;
|
|
||||||
$_REQUEST['max_id'] = 10;
|
$body = (string)$response->getBody();
|
||||||
$result = api_lists_statuses('json');
|
|
||||||
foreach ($result['status'] as $status) {
|
self::assertJson($body);
|
||||||
self::assertStatus($status);
|
|
||||||
|
$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.
|
* Test the api_lists_statuses() function with a list ID and a RSS result.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiListsStatusesWithListIdAndRss()
|
public function testApiListsStatusesWithListIdAndRss()
|
||||||
{
|
{
|
||||||
// $_REQUEST['list_id'] = 1;
|
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
|
||||||
// $result = api_lists_statuses('rss');
|
$response = $lists->run(['list_id' => 1]);
|
||||||
// self::assertXml($result, 'statuses');
|
|
||||||
|
self::assertXml((string)$response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +61,8 @@ class StatusesTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiListsStatusesWithUnallowedUser()
|
public function testApiListsStatusesWithUnallowedUser()
|
||||||
{
|
{
|
||||||
|
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||||
|
|
||||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||||
// BasicAuth::setCurrentUserID();
|
// BasicAuth::setCurrentUserID();
|
||||||
// api_lists_statuses('json');
|
// api_lists_statuses('json');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user