Reenable Twitter/Statuses tests
This commit is contained in:
parent
7982190a3c
commit
ccf7e251b5
|
@ -42,14 +42,14 @@ class Show extends BaseApi
|
||||||
$uid = BaseApi::getCurrentUserID();
|
$uid = BaseApi::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($this->parameters['id'])) {
|
if (empty($this->parameters['id'])) {
|
||||||
$id = intval($_REQUEST['id'] ?? 0);
|
$id = intval($request['id'] ?? 0);
|
||||||
} else {
|
} else {
|
||||||
$id = (int)$this->parameters['id'];
|
$id = (int)$this->parameters['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('API: api_statuses_show: ' . $id);
|
Logger::notice('API: api_statuses_show: ' . $id);
|
||||||
|
|
||||||
$conversation = !empty($_REQUEST['conversation']);
|
$conversation = !empty($request['conversation']);
|
||||||
|
|
||||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||||
$uri_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
$uri_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||||
|
@ -79,7 +79,7 @@ class Show extends BaseApi
|
||||||
throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id));
|
throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||||
|
|
||||||
$ret = [];
|
$ret = [];
|
||||||
while ($status = DBA::fetch($statuses)) {
|
while ($status = DBA::fetch($statuses)) {
|
||||||
|
@ -92,7 +92,7 @@ class Show extends BaseApi
|
||||||
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
$this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||||
} else {
|
} else {
|
||||||
$data = ['status' => $ret[0]];
|
$data = ['status' => $ret[0]];
|
||||||
$this->response->exit('status', ['status' => $data], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
$this->response->exit('status', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
|
namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
|
||||||
|
|
||||||
|
use Friendica\App\Router;
|
||||||
|
use Friendica\DI;
|
||||||
|
use Friendica\Module\Api\Twitter\Statuses\Show;
|
||||||
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
|
||||||
class ShowTest extends ApiTest
|
class ShowTest extends ApiTest
|
||||||
|
@ -13,8 +17,10 @@ class ShowTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesShow()
|
public function testApiStatusesShow()
|
||||||
{
|
{
|
||||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
// api_statuses_show('json');
|
|
||||||
|
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
|
$show->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,9 +30,13 @@ class ShowTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesShowWithId()
|
public function testApiStatusesShowWithId()
|
||||||
{
|
{
|
||||||
// DI::args()->setArgv(['', '', '', 1]);
|
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
// $result = api_statuses_show('json');
|
$response = $show->run(['id' => 1]);
|
||||||
// self::assertStatus($result['status']);
|
|
||||||
|
$json = $this->toJson($response);
|
||||||
|
|
||||||
|
self::assertIsInt($json->id);
|
||||||
|
self::assertIsString($json->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,15 +46,17 @@ class ShowTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesShowWithConversation()
|
public function testApiStatusesShowWithConversation()
|
||||||
{
|
{
|
||||||
/*
|
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
DI::args()->setArgv(['', '', '', 1]);
|
$response = $show->run(['id' => 1, 'conversation' => 1]);
|
||||||
$_REQUEST['conversation'] = 1;
|
|
||||||
$result = api_statuses_show('json');
|
$json = $this->toJson($response);
|
||||||
self::assertNotEmpty($result['status']);
|
|
||||||
foreach ($result['status'] as $status) {
|
self::assertIsArray($json);
|
||||||
self::assertStatus($status);
|
|
||||||
|
foreach ($json as $status) {
|
||||||
|
self::assertIsInt($status->id);
|
||||||
|
self::assertIsString($status->text);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,6 +66,8 @@ class ShowTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesShowWithUnallowedUser()
|
public function testApiStatusesShowWithUnallowedUser()
|
||||||
{
|
{
|
||||||
|
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_statuses_show('json');
|
// api_statuses_show('json');
|
||||||
|
|
Loading…
Reference in a new issue