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\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys a specific status.
|
* Destroys a specific status.
|
||||||
|
@ -39,10 +40,12 @@ class Destroy extends BaseApi
|
||||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||||
$uid = BaseApi::getCurrentUserID();
|
$uid = BaseApi::getCurrentUserID();
|
||||||
|
|
||||||
if (empty($this->parameters['id'])) {
|
if (empty($this->parameters['id']) && !empty($request['id'])) {
|
||||||
$id = intval($request['id'] ?? 0);
|
$id = intval($request['id']);
|
||||||
} else {
|
} elseif (!empty($this->parameters['id'])) {
|
||||||
$id = (int)$this->parameters['id'];
|
$id = (int)$this->parameters['id'];
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException('An id is missing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->notice('API: api_statuses_destroy: ' . $id);
|
$this->logger->notice('API: api_statuses_destroy: ' . $id);
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
|
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;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
|
||||||
class StatusesTest extends ApiTest
|
class StatusesTest extends ApiTest
|
||||||
|
|
|
@ -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\Destroy;
|
||||||
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
|
||||||
class DestroyTest extends ApiTest
|
class DestroyTest extends ApiTest
|
||||||
|
@ -13,8 +17,10 @@ class DestroyTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesDestroy()
|
public function testApiStatusesDestroy()
|
||||||
{
|
{
|
||||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
// api_statuses_destroy('json');
|
|
||||||
|
$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()
|
public function testApiStatusesDestroyWithoutAuthenticatedUser()
|
||||||
{
|
{
|
||||||
|
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();
|
||||||
// $_SESSION['authenticated'] = false;
|
// $_SESSION['authenticated'] = false;
|
||||||
|
@ -37,8 +45,13 @@ class DestroyTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusesDestroyWithId()
|
public function testApiStatusesDestroyWithId()
|
||||||
{
|
{
|
||||||
// DI::args()->setArgv(['', '', '', 1]);
|
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||||
// $result = api_statuses_destroy('json');
|
$response = $destroy->run(['id' => 1]);
|
||||||
// self::assertStatus($result['status']);
|
|
||||||
|
$json = $this->toJson($response);
|
||||||
|
|
||||||
|
self::assertEquals(1, $json->id);
|
||||||
|
self::assertIsObject($json->user);
|
||||||
|
self::assertIsObject($json->friendica_author);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue