1
0
Fork 0

Introduce FixtureTest::useHttpMethod for manually overwrite the HTTP Method argument

This commit is contained in:
Philipp Holzer 2022-01-02 22:51:16 +01:00
parent 4e67bfed8d
commit 5e85939502
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
36 changed files with 175 additions and 82 deletions

View file

@ -6,6 +6,8 @@
namespace Friendica\Test; namespace Friendica\Test;
use Dice\Dice; use Dice\Dice;
use Friendica\App\Arguments;
use Friendica\App\Router;
use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Session; use Friendica\Core\Session;
@ -50,4 +52,20 @@ abstract class FixtureTest extends DatabaseTest
// Load the API dataset for the whole API // Load the API dataset for the whole API
$this->loadFixture(__DIR__ . '/datasets/api.fixture.php', $dba); $this->loadFixture(__DIR__ . '/datasets/api.fixture.php', $dba);
} }
protected function useHttpMethod(string $method = Router::GET)
{
$server = $_SERVER;
$server['REQUEST_METHOD'] = $method;
$this->dice = $this->dice
->addRule(Arguments::class, [
'instanceOf' => Arguments::class,
'call' => [
['determine', [$server, $_GET], Dice::CHAIN_CALL],
],
]);
DI::init($this->dice);
}
} }

View file

@ -21,7 +21,9 @@
namespace Friendica\Test\src\Module\Api; namespace Friendica\Test\src\Module\Api;
use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\App\Arguments;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -167,9 +169,18 @@ abstract class ApiTest extends FixtureTest
{ {
parent::setUp(); // TODO: Change the autogenerated stub parent::setUp(); // TODO: Change the autogenerated stub
$server = $_SERVER;
$server['REQUEST_METHOD'] = App\Router::GET;
$this->dice = $this->dice $this->dice = $this->dice
->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]) ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true])
->addRule(App::class, ['instanceOf' => AppDouble::class, 'shared' => true]); ->addRule(App::class, ['instanceOf' => AppDouble::class, 'shared' => true])
->addRule(Arguments::class, [
'instanceOf' => App\Arguments::class,
'call' => [
['determine', [$server, $_GET], Dice::CHAIN_CALL],
],
]);
DI::init($this->dice); DI::init($this->dice);
// Manual override to bypass API authentication // Manual override to bypass API authentication

View file

@ -34,7 +34,7 @@ class SearchTest extends ApiTest
{ {
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);
@ -52,7 +52,7 @@ class SearchTest extends ApiTest
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'searchstring' => 'item_body' 'searchstring' => 'item_body'
]); ]);
@ -73,7 +73,7 @@ class SearchTest extends ApiTest
{ {
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'searchstring' => 'test' 'searchstring' => 'test'
]); ]);

View file

@ -29,10 +29,17 @@ use Friendica\Test\src\Module\Api\ApiTest;
class DeleteTest extends ApiTest class DeleteTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(); (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run();
} }
public function testWithoutAuthenticatedUser() public function testWithoutAuthenticatedUser()
@ -43,14 +50,14 @@ class DeleteTest extends ApiTest
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['photo_id' => 1]); (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run(['photo_id' => 1]);
} }
public function testValidWithPost() public function testValidWithPost()
{ {
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'photo_id' => '709057080661a283a6aa598501504178' 'photo_id' => '709057080661a283a6aa598501504178'
]); ]);
@ -65,7 +72,7 @@ class DeleteTest extends ApiTest
{ {
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'photo_id' => '709057080661a283a6aa598501504178' 'photo_id' => '709057080661a283a6aa598501504178'
]); ]);

View file

@ -29,10 +29,17 @@ use Friendica\Test\src\Module\Api\ApiTest;
class DeleteTest extends ApiTest class DeleteTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -40,7 +47,7 @@ class DeleteTest extends ApiTest
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'album' => 'album_name' 'album' => 'album_name'
]); ]);
@ -50,7 +57,7 @@ class DeleteTest extends ApiTest
{ {
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'album' => 'test_album'] 'album' => 'test_album']
); );

View file

@ -29,17 +29,24 @@ use Friendica\Test\src\Module\Api\ApiTest;
class UpdateTest extends ApiTest class UpdateTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
public function testTooFewArgs() public function testTooFewArgs()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'album' => 'album_name' 'album' => 'album_name'
]); ]);
@ -48,7 +55,7 @@ class UpdateTest extends ApiTest
public function testWrongUpdate() public function testWrongUpdate()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'album' => 'album_name', 'album' => 'album_name',
'album_new' => 'album_name' 'album_new' => 'album_name'
@ -64,7 +71,7 @@ class UpdateTest extends ApiTest
{ {
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'album' => 'test_album', 'album' => 'test_album',
'album_new' => 'test_album_2' 'album_new' => 'test_album_2'

View file

@ -17,9 +17,8 @@ class ConfigTest extends ApiTest
{ {
DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL); DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL);
$response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);
self::assertEquals('localhost', $json->site->server); self::assertEquals('localhost', $json->site->server);

View file

@ -16,7 +16,7 @@ class VerifyCredentialsTest extends ApiTest
*/ */
public function testApiAccountVerifyCredentials() public function testApiAccountVerifyCredentials()
{ {
$response = (new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -12,7 +12,7 @@ class RateLimitStatusTest extends ApiTest
{ {
public function testWithJson() public function testWithJson()
{ {
$response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run(); ->run();
$result = $this->toJson($response); $result = $this->toJson($response);

View file

@ -14,7 +14,9 @@ class UpdateProfileTest extends ApiTest
*/ */
public function testApiAccountUpdateProfile() public function testApiAccountUpdateProfile()
{ {
$response = (new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json'])) $this->useHttpMethod(Router::POST);
$response = (new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'name' => 'new_name', 'name' => 'new_name',
'description' => 'new_description' 'description' => 'new_description'

View file

@ -14,7 +14,7 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFWithBlocks() public function testApiStatusesFWithBlocks()
{ {
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -21,7 +21,7 @@ class AllTest extends ApiTest
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new All($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new All($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -19,7 +19,7 @@ class ConversationTest extends ApiTest
{ {
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new Conversation($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Conversation($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'friendica_verbose' => true, 'friendica_verbose' => true,
]); ]);

View file

@ -18,7 +18,7 @@ class DestroyTest extends ApiTest
public function testApiDirectMessagesDestroy() public function testApiDirectMessagesDestroy()
{ {
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run(); ->run();
} }
@ -29,7 +29,7 @@ class DestroyTest extends ApiTest
*/ */
public function testApiDirectMessagesDestroyWithVerbose() public function testApiDirectMessagesDestroyWithVerbose()
{ {
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'friendica_verbose' => true, 'friendica_verbose' => true,
]); ]);
@ -65,7 +65,7 @@ class DestroyTest extends ApiTest
public function testApiDirectMessagesDestroyWithId() public function testApiDirectMessagesDestroyWithId()
{ {
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'id' => 1 'id' => 1
]); ]);
@ -78,7 +78,7 @@ class DestroyTest extends ApiTest
*/ */
public function testApiDirectMessagesDestroyWithIdAndVerbose() public function testApiDirectMessagesDestroyWithIdAndVerbose()
{ {
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'id' => 1, 'id' => 1,
'friendica_parenturi' => 'parent_uri', 'friendica_parenturi' => 'parent_uri',
@ -102,7 +102,7 @@ class DestroyTest extends ApiTest
$ids = DBA::selectToArray('mail', ['id']); $ids = DBA::selectToArray('mail', ['id']);
$id = $ids[0]['id']; $id = $ids[0]['id'];
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'id' => $id, 'id' => $id,
'friendica_verbose' => true, 'friendica_verbose' => true,

View file

@ -21,7 +21,7 @@ class InboxTest extends ApiTest
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new Inbox($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Inbox($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -19,7 +19,7 @@ class NewDMTest extends ApiTest
{ {
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run(); ->run();
self::assertEmpty((string)$response->getBody()); self::assertEmpty((string)$response->getBody());
@ -51,7 +51,7 @@ class NewDMTest extends ApiTest
{ {
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'text' => 'message_text', 'text' => 'message_text',
'user_id' => 43 'user_id' => 43
@ -73,7 +73,7 @@ class NewDMTest extends ApiTest
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'text' => 'message_text', 'text' => 'message_text',
'user_id' => 44 'user_id' => 44
@ -97,7 +97,7 @@ class NewDMTest extends ApiTest
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'text' => 'message_text', 'text' => 'message_text',
'user_id' => 44, 'user_id' => 44,
@ -123,7 +123,7 @@ class NewDMTest extends ApiTest
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss'])) $response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss']))
->run([ ->run([
'text' => 'message_text', 'text' => 'message_text',
'user_id' => 44, 'user_id' => 44,

View file

@ -19,7 +19,7 @@ class SentTest extends ApiTest
{ {
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) $response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
->run([ ->run([
'friendica_verbose' => true, 'friendica_verbose' => true,
]); ]);
@ -39,7 +39,7 @@ class SentTest extends ApiTest
{ {
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
$response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss'])) $response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss']))
->run(); ->run();
self::assertXml((string)$response->getBody(), 'direct-messages'); self::assertXml((string)$response->getBody(), 'direct-messages');

View file

@ -11,6 +11,13 @@ use Friendica\Test\src\Module\Api\ApiTest;
class CreateTest extends ApiTest class CreateTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the api_favorites_create_destroy() function with an invalid ID. * Test the api_favorites_create_destroy() function with an invalid ID.
* *
@ -20,7 +27,7 @@ class CreateTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -31,7 +38,7 @@ class CreateTest extends ApiTest
*/ */
public function testApiFavoritesCreateDestroyWithCreateAction() public function testApiFavoritesCreateDestroyWithCreateAction()
{ {
$response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 3 'id' => 3
]); ]);
@ -48,7 +55,7 @@ class CreateTest extends ApiTest
*/ */
public function testApiFavoritesCreateDestroyWithCreateActionAndRss() public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
{ {
$response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => ICanCreateResponses::TYPE_RSS])) $response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS]))
->run([ ->run([
'id' => 3 'id' => 3
]); ]);

View file

@ -10,6 +10,13 @@ use Friendica\Test\src\Module\Api\ApiTest;
class DestroyTest extends ApiTest class DestroyTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the api_favorites_create_destroy() function with an invalid ID. * Test the api_favorites_create_destroy() function with an invalid ID.
* *
@ -19,7 +26,7 @@ class DestroyTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -30,7 +37,7 @@ class DestroyTest extends ApiTest
*/ */
public function testApiFavoritesCreateDestroyWithDestroyAction() public function testApiFavoritesCreateDestroyWithDestroyAction()
{ {
$response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 3 'id' => 3
]); ]);

View file

@ -17,7 +17,7 @@ class FavoritesTest extends ApiTest
*/ */
public function testApiFavorites() public function testApiFavorites()
{ {
$response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'page' => -1, 'page' => -1,
'max_id' => 10, 'max_id' => 10,
@ -37,7 +37,7 @@ class FavoritesTest extends ApiTest
*/ */
public function testApiFavoritesWithRss() public function testApiFavoritesWithRss()
{ {
$response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
'extension' => ICanCreateResponses::TYPE_RSS 'extension' => ICanCreateResponses::TYPE_RSS
]))->run(); ]))->run();

View file

@ -14,7 +14,7 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFWithFollowers() public function testApiStatusesFWithFollowers()
{ {
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -16,7 +16,7 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFWithFriends() public function testApiStatusesFWithFriends()
{ {
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -16,7 +16,7 @@ class IncomingTest extends ApiTest
*/ */
public function testApiFriendshipsIncoming() public function testApiFriendshipsIncoming()
{ {
$response = (new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);

View file

@ -19,7 +19,7 @@ class StatusesTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -28,7 +28,7 @@ class StatusesTest extends ApiTest
*/ */
public function testApiListsStatusesWithListId() public function testApiListsStatusesWithListId()
{ {
$response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'list_id' => 1, 'list_id' => 1,
'page' => -1, 'page' => -1,
@ -48,7 +48,7 @@ class StatusesTest extends ApiTest
*/ */
public function testApiListsStatusesWithListIdAndRss() public function testApiListsStatusesWithListIdAndRss()
{ {
$response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss'])) $response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'rss']))
->run([ ->run([
'list_id' => 1 'list_id' => 1
]); ]);

View file

@ -13,6 +13,13 @@ use Friendica\Test\Util\AuthTestConfig;
class UploadTest extends ApiTest class UploadTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the \Friendica\Module\Api\Twitter\Media\Upload module. * Test the \Friendica\Module\Api\Twitter\Media\Upload module.
*/ */
@ -20,7 +27,7 @@ class UploadTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -34,7 +41,7 @@ class UploadTest extends ApiTest
$this->expectException(UnauthorizedException::class); $this->expectException(UnauthorizedException::class);
AuthTestConfig::$authenticated = false; AuthTestConfig::$authenticated = false;
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -53,7 +60,7 @@ class UploadTest extends ApiTest
] ]
]; ];
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -76,7 +83,7 @@ class UploadTest extends ApiTest
] ]
]; ];
$response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$media = $this->toJson($response); $media = $this->toJson($response);

View file

@ -10,6 +10,13 @@ use Friendica\Test\src\Module\Api\ApiTest;
class DestroyTest extends ApiTest class DestroyTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the api_statuses_destroy() function. * Test the api_statuses_destroy() function.
* *
@ -19,7 +26,7 @@ class DestroyTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -45,7 +52,7 @@ class DestroyTest extends ApiTest
*/ */
public function testApiStatusesDestroyWithId() public function testApiStatusesDestroyWithId()
{ {
$response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 1 'id' => 1
]); ]);

View file

@ -17,7 +17,7 @@ class MentionsTest extends ApiTest
*/ */
public function testApiStatusesMentions() public function testApiStatusesMentions()
{ {
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'max_id' => 10 'max_id' => 10
]); ]);
@ -35,7 +35,7 @@ class MentionsTest extends ApiTest
*/ */
public function testApiStatusesMentionsWithNegativePage() public function testApiStatusesMentionsWithNegativePage()
{ {
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'page' => -2 'page' => -2
]); ]);
@ -67,7 +67,7 @@ class MentionsTest extends ApiTest
*/ */
public function testApiStatusesMentionsWithRss() public function testApiStatusesMentionsWithRss()
{ {
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS])) $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => ICanCreateResponses::TYPE_RSS]))
->run([ ->run([
'page' => -2 'page' => -2
]); ]);

View file

@ -17,7 +17,7 @@ class NetworkPublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesNetworkpublicTimeline() public function testApiStatusesNetworkpublicTimeline()
{ {
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'max_id' => 10 'max_id' => 10
]); ]);
@ -39,7 +39,7 @@ class NetworkPublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesNetworkpublicTimelineWithNegativePage() public function testApiStatusesNetworkpublicTimelineWithNegativePage()
{ {
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'page' => -2 'page' => -2
]); ]);
@ -75,7 +75,7 @@ class NetworkPublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesNetworkpublicTimelineWithRss() public function testApiStatusesNetworkpublicTimelineWithRss()
{ {
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
'extension' => ICanCreateResponses::TYPE_RSS 'extension' => ICanCreateResponses::TYPE_RSS
]))->run([ ]))->run([
'page' => -2 'page' => -2

View file

@ -10,6 +10,13 @@ use Friendica\Test\src\Module\Api\ApiTest;
class RetweetTest extends ApiTest class RetweetTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the api_statuses_repeat() function. * Test the api_statuses_repeat() function.
* *
@ -19,7 +26,7 @@ class RetweetTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -45,7 +52,7 @@ class RetweetTest extends ApiTest
*/ */
public function testApiStatusesRepeatWithId() public function testApiStatusesRepeatWithId()
{ {
$response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 1 'id' => 1
]); ]);
@ -62,7 +69,7 @@ class RetweetTest extends ApiTest
*/ */
public function testApiStatusesRepeatWithSharedId() public function testApiStatusesRepeatWithSharedId()
{ {
$response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 5 'id' => 5
]); ]);

View file

@ -20,7 +20,7 @@ class ShowTest extends ApiTest
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -31,7 +31,7 @@ class ShowTest extends ApiTest
*/ */
public function testApiStatusesShowWithId() public function testApiStatusesShowWithId()
{ {
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 1 'id' => 1
]); ]);
@ -49,7 +49,7 @@ class ShowTest extends ApiTest
*/ */
public function testApiStatusesShowWithConversation() public function testApiStatusesShowWithConversation()
{ {
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'id' => 1, 'id' => 1,
'conversation' => 1 'conversation' => 1

View file

@ -9,6 +9,13 @@ use Friendica\Test\src\Module\Api\ApiTest;
class UpdateTest extends ApiTest class UpdateTest extends ApiTest
{ {
protected function setUp(): void
{
parent::setUp();
$this->useHttpMethod(Router::POST);
}
/** /**
* Test the api_statuses_update() function. * Test the api_statuses_update() function.
* *
@ -28,7 +35,7 @@ class UpdateTest extends ApiTest
] ]
]; ];
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'status' => 'Status content #friendica', 'status' => 'Status content #friendica',
'in_reply_to_status_id' => 0, 'in_reply_to_status_id' => 0,
@ -50,7 +57,7 @@ class UpdateTest extends ApiTest
*/ */
public function testApiStatusesUpdateWithHtml() public function testApiStatusesUpdateWithHtml()
{ {
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'htmlstatus' => '<b>Status content</b>', 'htmlstatus' => '<b>Status content</b>',
]); ]);

View file

@ -17,7 +17,7 @@ class UserTimelineTest extends ApiTest
*/ */
public function testApiStatusesUserTimeline() public function testApiStatusesUserTimeline()
{ {
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'user_id' => 42, 'user_id' => 42,
'max_id' => 10, 'max_id' => 10,
@ -42,7 +42,7 @@ class UserTimelineTest extends ApiTest
*/ */
public function testApiStatusesUserTimelineWithNegativePage() public function testApiStatusesUserTimelineWithNegativePage()
{ {
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'user_id' => 42, 'user_id' => 42,
'page' => -2, 'page' => -2,
@ -65,7 +65,7 @@ class UserTimelineTest extends ApiTest
*/ */
public function testApiStatusesUserTimelineWithRss() public function testApiStatusesUserTimelineWithRss()
{ {
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
'extension' => ICanCreateResponses::TYPE_RSS 'extension' => ICanCreateResponses::TYPE_RSS
]))->run(); ]))->run();

View file

@ -19,7 +19,7 @@ class LookupTest extends ApiTest
{ {
$this->expectException(NotFoundException::class); $this->expectException(NotFoundException::class);
(new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
@ -30,7 +30,7 @@ class LookupTest extends ApiTest
*/ */
public function testApiUsersLookupWithUserId() public function testApiUsersLookupWithUserId()
{ {
$respone = (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $respone = (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'user_id' => static::OTHER_USER['id'] 'user_id' => static::OTHER_USER['id']
]); ]);

View file

@ -18,7 +18,7 @@ class SearchTest extends ApiTest
*/ */
public function testApiUsersSearch() public function testApiUsersSearch()
{ {
$respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run([ ->run([
'q' => static::OTHER_USER['name'] 'q' => static::OTHER_USER['name']
]); ]);
@ -35,7 +35,7 @@ class SearchTest extends ApiTest
*/ */
public function testApiUsersSearchWithXml() public function testApiUsersSearchWithXml()
{ {
$respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ $respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
'extension' => ICanCreateResponses::TYPE_XML 'extension' => ICanCreateResponses::TYPE_XML
]))->run([ ]))->run([
'q' => static::OTHER_USER['name'] 'q' => static::OTHER_USER['name']
@ -53,7 +53,7 @@ class SearchTest extends ApiTest
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
} }
} }

View file

@ -17,7 +17,7 @@ class ShowTest extends ApiTest
*/ */
public function testApiUsersShow() public function testApiUsersShow()
{ {
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
->run(); ->run();
$json = $this->toJson($response); $json = $this->toJson($response);
@ -37,7 +37,7 @@ class ShowTest extends ApiTest
*/ */
public function testApiUsersShowWithXml() public function testApiUsersShowWithXml()
{ {
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
'extension' => ICanCreateResponses::TYPE_XML 'extension' => ICanCreateResponses::TYPE_XML
]))->run(); ]))->run();

View file

@ -2,8 +2,6 @@
namespace Friendica\Test\src\Module\Special; namespace Friendica\Test\src\Module\Special;
use Friendica\App\Arguments;
use Friendica\App\Page;
use Friendica\App\Router; use Friendica\App\Router;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\DI; use Friendica\DI;
@ -14,7 +12,9 @@ class OptionsTest extends FixtureTest
{ {
public function testOptions() public function testOptions()
{ {
$response = (new Options(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::OPTIONS]))->run(); $this->useHttpMethod(Router::OPTIONS);
$response = (new Options(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))->run();
self::assertEmpty((string)$response->getBody()); self::assertEmpty((string)$response->getBody());
self::assertEquals(204, $response->getStatusCode()); self::assertEquals(204, $response->getStatusCode());