mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:40:15 +00:00
Reenable Twitter/Destroy tests
This commit is contained in:
parent
354c2d828a
commit
4d330f2876
3 changed files with 24 additions and 11 deletions
|
@ -26,6 +26,7 @@ use Friendica\Module\BaseApi;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* Destroys a specific status.
|
||||
|
@ -39,10 +40,12 @@ class Destroy extends BaseApi
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
$id = intval($request['id'] ?? 0);
|
||||
} else {
|
||||
if (empty($this->parameters['id']) && !empty($request['id'])) {
|
||||
$id = intval($request['id']);
|
||||
} elseif (!empty($this->parameters['id'])) {
|
||||
$id = (int)$this->parameters['id'];
|
||||
} else {
|
||||
throw new BadRequestException('An id is missing.');
|
||||
}
|
||||
|
||||
$this->logger->notice('API: api_statuses_destroy: ' . $id);
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Mastodon\Accounts\Statuses;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class StatusesTest extends ApiTest
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Statuses\Destroy;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class DestroyTest extends ApiTest
|
||||
|
@ -13,8 +17,10 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesDestroy()
|
||||
{
|
||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
// api_statuses_destroy('json');
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$destroy->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +30,8 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesDestroyWithoutAuthenticatedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// $_SESSION['authenticated'] = false;
|
||||
|
@ -37,8 +45,13 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesDestroyWithId()
|
||||
{
|
||||
// DI::args()->setArgv(['', '', '', 1]);
|
||||
// $result = api_statuses_destroy('json');
|
||||
// self::assertStatus($result['status']);
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $destroy->run(['id' => 1]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
self::assertEquals(1, $json->id);
|
||||
self::assertIsObject($json->user);
|
||||
self::assertIsObject($json->friendica_author);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue