From 301ac83ebfe9149b63e14ee1305eb8d6ab8c035a Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 2 Jan 2022 01:04:04 +0100 Subject: [PATCH] Add feedback - avoid intermediate variables --- .../Factory/Api/Twitter/ActivitiesTest.php | 8 +-- .../Factory/Api/Twitter/DirectMessageTest.php | 24 ++++---- tests/src/Factory/Api/Twitter/StatusTest.php | 58 +++++++++---------- tests/src/Factory/Api/Twitter/UserTest.php | 12 ++-- .../Friendica/DirectMessages/SearchTest.php | 15 +++-- .../Module/Api/Friendica/NotificationTest.php | 18 ++++-- .../Module/Api/Friendica/Photo/DeleteTest.php | 12 ++-- .../Api/Friendica/Photoalbum/DeleteTest.php | 14 +++-- .../Api/Friendica/Photoalbum/UpdateTest.php | 20 +++++-- .../Api/GnuSocial/GnuSocial/ConfigTest.php | 4 +- .../Api/GnuSocial/GnuSocial/VersionTest.php | 9 ++- .../Module/Api/GnuSocial/Help/TestTest.php | 18 ++++-- .../Accounts/VerifyCredentialsTest.php | 4 +- .../Twitter/Account/RateLimitStatusTest.php | 18 ++++-- .../Api/Twitter/Account/UpdateProfileTest.php | 7 ++- .../Module/Api/Twitter/Blocks/ListsTest.php | 4 +- .../Api/Twitter/DirectMessages/AllTest.php | 4 +- .../DirectMessages/ConversationTest.php | 8 +-- .../Twitter/DirectMessages/DestroyTest.php | 38 ++++++------ .../Api/Twitter/DirectMessages/InboxTest.php | 4 +- .../Api/Twitter/DirectMessages/NewDMTest.php | 48 +++++++-------- .../Api/Twitter/DirectMessages/SentTest.php | 12 ++-- .../Api/Twitter/Favorites/CreateTest.php | 16 +++-- .../Api/Twitter/Favorites/DestroyTest.php | 10 ++-- .../src/Module/Api/Twitter/FavoritesTest.php | 15 ++--- .../Api/Twitter/Followers/ListsTest.php | 4 +- .../Module/Api/Twitter/Friends/ListsTest.php | 4 +- .../Api/Twitter/Friendships/IncomingTest.php | 4 +- .../Module/Api/Twitter/Lists/StatusesTest.php | 18 ++++-- .../Module/Api/Twitter/Media/UploadTest.php | 16 +++-- .../Module/Api/Twitter/SavedSearchesTest.php | 4 +- .../Api/Twitter/Statuses/DestroyTest.php | 10 ++-- .../Api/Twitter/Statuses/MentionsTest.php | 18 ++++-- .../Statuses/NetworkPublicTimelineTest.php | 19 ++++-- .../Api/Twitter/Statuses/RetweetTest.php | 16 +++-- .../Module/Api/Twitter/Statuses/ShowTest.php | 18 ++++-- .../Api/Twitter/Statuses/UpdateTest.php | 22 +++---- .../Api/Twitter/Statuses/UserTimelineTest.php | 32 +++++----- .../Module/Api/Twitter/Users/LookupTest.php | 10 ++-- .../Module/Api/Twitter/Users/SearchTest.php | 17 ++++-- .../src/Module/Api/Twitter/Users/ShowTest.php | 9 +-- tests/src/Module/NodeInfoTest.php | 18 ++---- 42 files changed, 367 insertions(+), 272 deletions(-) diff --git a/tests/src/Factory/Api/Twitter/ActivitiesTest.php b/tests/src/Factory/Api/Twitter/ActivitiesTest.php index 43f976e35..b468bdd1e 100644 --- a/tests/src/Factory/Api/Twitter/ActivitiesTest.php +++ b/tests/src/Factory/Api/Twitter/ActivitiesTest.php @@ -17,8 +17,8 @@ class ActivitiesTest extends FixtureTest { $item = ['uid' => 0, 'uri-id' => 1]; - $friendicaActivitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()); - $result = $friendicaActivitiesFac->createFromUriId($item['uri-id'], $item['uid']); + $result = (new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser())) + ->createFromUriId($item['uri-id'], $item['uid']); self::assertArrayHasKey('like', $result); self::assertArrayHasKey('dislike', $result); @@ -36,8 +36,8 @@ class ActivitiesTest extends FixtureTest { $item = ['uid' => 0, 'uri-id' => 1]; - $friendicaActivitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()); - $result = $friendicaActivitiesFac->createFromUriId($item['uri-id'], $item['uid'], 'xml'); + $result = (new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser())) + ->createFromUriId($item['uri-id'], $item['uid'], 'xml'); self::assertArrayHasKey('friendica:like', $result); self::assertArrayHasKey('friendica:dislike', $result); diff --git a/tests/src/Factory/Api/Twitter/DirectMessageTest.php b/tests/src/Factory/Api/Twitter/DirectMessageTest.php index 9cc756070..8ba821c76 100644 --- a/tests/src/Factory/Api/Twitter/DirectMessageTest.php +++ b/tests/src/Factory/Api/Twitter/DirectMessageTest.php @@ -20,9 +20,9 @@ class DirectMessageTest extends FixtureTest $ids = DI::dba()->selectToArray('mail', ['id']); $id = $ids[0]['id']; - $directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id']); - $directMessage = $directMessageObj->toArray(); + $directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser())) + ->createFromMailId($id, ApiTest::SELF_USER['id']) + ->toArray(); self::assertEquals('item_title' . "\n" . 'item_body', $directMessage['text']); self::assertIsInt($directMessage['id']); @@ -43,9 +43,9 @@ class DirectMessageTest extends FixtureTest $ids = DI::dba()->selectToArray('mail', ['id']); $id = $ids[0]['id']; - $directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'html'); - $directMessage = $directMessageObj->toArray(); + $directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser())) + ->createFromMailId($id, ApiTest::SELF_USER['id'], 'html') + ->toArray(); self::assertEquals('item_title', $directMessage['title']); self::assertEquals('item_body', $directMessage['text']); @@ -62,9 +62,9 @@ class DirectMessageTest extends FixtureTest $ids = DI::dba()->selectToArray('mail', ['id']); $id = $ids[0]['id']; - $directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain'); - $directMessage = $directMessageObj->toArray(); + $directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser())) + ->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain') + ->toArray(); self::assertEquals('item_title', $directMessage['title']); self::assertEquals('item_body', $directMessage['text']); @@ -84,9 +84,9 @@ class DirectMessageTest extends FixtureTest $ids = DI::dba()->selectToArray('mail', ['id']); $id = $ids[0]['id']; - $directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain', $$GETUSEROBJECTS$$); - $directMessage = $directMessageObj->toArray(); + $directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser())) + ->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain', $$GETUSEROBJECTS$$) + ->toArray(); self::assertTrue(!isset($directMessage['sender'])); self::assertTrue(!isset($directMessage['recipient'])); diff --git a/tests/src/Factory/Api/Twitter/StatusTest.php b/tests/src/Factory/Api/Twitter/StatusTest.php index 1073867ee..a2d9d7171 100644 --- a/tests/src/Factory/Api/Twitter/StatusTest.php +++ b/tests/src/Factory/Api/Twitter/StatusTest.php @@ -15,6 +15,24 @@ use Friendica\Test\src\Module\Api\ApiTest; class StatusTest extends FixtureTest { + protected $statusFactory; + + protected function setUp(): void + { + parent::setUp(); + + $this->statusFactory = new Status( + DI::logger(), + DI::dba(), + DI::twitterUser(), + new Hashtag(DI::logger()), + new Media(DI::logger(), DI::baseUrl()), + new Url(DI::logger()), + new Mention(DI::logger(), DI::baseUrl()), + new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()), + new Attachment(DI::logger())); + } + /** * Test the api_convert_item() function. * @@ -22,16 +40,9 @@ class StatusTest extends FixtureTest */ public function testApiConvertItem() { - $hashTagFac = new Hashtag(DI::logger()); - $mediaFac = new Media(DI::logger(), DI::baseUrl()); - $urlFac = new Url(DI::logger()); - $mentionFac = new Mention(DI::logger(), DI::baseUrl()); - $activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()); - $attachmentFac = new Attachment(DI::logger()); - - $statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac); - $statusObj = $statusFac->createFromItemId(13, ApiTest::SELF_USER['id']); - $status = $statusObj->toArray(); + $status = $this->statusFactory + ->createFromItemId(13, ApiTest::SELF_USER['id']) + ->toArray(); self::assertStringStartsWith('item_title', $status['text']); self::assertStringStartsWith('

item_title


perspiciatis impedit voluptatem', $status['friendica_html']); @@ -90,16 +101,9 @@ class StatusTest extends FixtureTest */ public function testApiGetEntititiesWithIncludeEntities() { - $hashTagFac = new Hashtag(DI::logger()); - $mediaFac = new Media(DI::logger(), DI::baseUrl()); - $urlFac = new Url(DI::logger()); - $mentionFac = new Mention(DI::logger(), DI::baseUrl()); - $activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()); - $attachmentFac = new Attachment(DI::logger()); - - $statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac); - $statusObj = $statusFac->createFromItemId(13, ApiTest::SELF_USER['id'], true); - $status = $statusObj->toArray(); + $status = $this->statusFactory + ->createFromItemId(13, ApiTest::SELF_USER['id'], true) + ->toArray(); self::assertIsArray($status['entities']); self::assertIsArray($status['extended_entities']); @@ -114,19 +118,11 @@ class StatusTest extends FixtureTest */ public function testApiFormatItems() { - $hashTagFac = new Hashtag(DI::logger()); - $mediaFac = new Media(DI::logger(), DI::baseUrl()); - $urlFac = new Url(DI::logger()); - $mentionFac = new Mention(DI::logger(), DI::baseUrl()); - $activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()); - $attachmentFac = new Attachment(DI::logger()); - - $statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac); - $posts = DI::dba()->selectToArray('post-view', ['uri-id']); foreach ($posts as $item) { - $statusObj = $statusFac->createFromUriId($item['uri-id'], ApiTest::SELF_USER['id']); - $status = $statusObj->toArray(); + $status = $this->statusFactory + ->createFromUriId($item['uri-id'], ApiTest::SELF_USER['id']) + ->toArray(); self::assertIsInt($status['id']); self::assertIsString($status['text']); diff --git a/tests/src/Factory/Api/Twitter/UserTest.php b/tests/src/Factory/Api/Twitter/UserTest.php index a39055a91..9a279ee7f 100644 --- a/tests/src/Factory/Api/Twitter/UserTest.php +++ b/tests/src/Factory/Api/Twitter/UserTest.php @@ -31,9 +31,9 @@ class UserTest extends FixtureTest */ public function testApiGetUser() { - $userFactory = new User(DI::logger(), DI::twitterStatus()); - $userObj = $userFactory->createFromUserId(ApiTest::SELF_USER['id']); - $user = $userObj->toArray(); + $user = (new User(DI::logger(), DI::twitterStatus())) + ->createFromUserId(ApiTest::SELF_USER['id']) + ->toArray(); $this->assertSelfUser($user); } @@ -114,9 +114,9 @@ class UserTest extends FixtureTest */ public function testApiGetUserWithWrongGetId() { - $userFactory = new User(DI::logger(), DI::twitterStatus()); - $userObj = $userFactory->createFromUserId(-1); - $user = $userObj->toArray(); + $user = (new User(DI::logger(), DI::twitterStatus())) + ->createFromUserId(-1) + ->toArray(); self::assertEquals(0, $user['id']); self::assertEquals(0, $user['uid']); diff --git a/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php b/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php index 9fe8f7ca7..af12be2c1 100644 --- a/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php +++ b/tests/src/Module/Api/Friendica/DirectMessages/SearchTest.php @@ -34,7 +34,8 @@ class SearchTest extends ApiTest { $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]))->run(); + $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); @@ -51,8 +52,10 @@ class SearchTest extends ApiTest $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); - $search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $search->run(['searchstring' => 'item_body']); + $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'searchstring' => 'item_body' + ]); $json = $this->toJson($response); @@ -70,8 +73,10 @@ class SearchTest extends ApiTest { $directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser()); - $search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $search->run(['searchstring' => 'test']); + $response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'searchstring' => 'test' + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index f05387bd8..bd0edf046 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -66,17 +66,20 @@ class NotificationTest extends ApiTest XML; - $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); - $response = $notification->run(); + $response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + ->run(); self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody()); - self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['text/xml'], + ICanCreateResponses::X_HEADER => ['xml'] + ], $response->getHeaders()); } public function testWithJsonResult() { - $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); - $response = $notification->run(); + $response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + ->run(); $json = $this->toJson($response); @@ -88,6 +91,9 @@ XML; self::assertIsString($note->msg); } - self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['application/json'], + ICanCreateResponses::X_HEADER => ['json'] + ], $response->getHeaders()); } } diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index 05808d56c..2f8bdb8fd 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -50,8 +50,10 @@ class DeleteTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']); + $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'photo_id' => '709057080661a283a6aa598501504178' + ]); $json = $this->toJson($response); @@ -63,8 +65,10 @@ class DeleteTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']); + $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'photo_id' => '709057080661a283a6aa598501504178' + ]); $responseText = (string)$response->getBody(); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index 230ba70c8..b4c6df2d5 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -32,22 +32,28 @@ class DeleteTest extends ApiTest public function testEmpty() { $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(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } public function testWrong() { $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(['album' => 'album_name']); + (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'album' => 'album_name' + ]); } public function testValidWithDelete() { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $delete->run(['album' => 'test_album']); + $response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'album' => 'test_album'] + ); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index fa4638e37..e370ba3f9 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -32,19 +32,27 @@ class UpdateTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } public function testTooFewArgs() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name']); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'album' => 'album_name' + ]); } public function testWrongUpdate() { $this->expectException(BadRequestException::class); - (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name', 'album_new' => 'album_name']); + (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'album' => 'album_name', + 'album_new' => 'album_name' + ]); } public function testWithoutAuthenticatedUser() @@ -56,7 +64,11 @@ class UpdateTest extends ApiTest { $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]))->run(['album' => 'test_album', 'album_new' => 'test_album_2']); + $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'album' => 'test_album', + 'album_new' => 'test_album_2' + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php index b1874d838..07e43479d 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/ConfigTest.php @@ -17,8 +17,8 @@ class ConfigTest extends ApiTest { DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL); - $config = new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $config->run(); + $response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php index 0f6531831..7d98e365c 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php @@ -11,10 +11,13 @@ class VersionTest extends ApiTest { public function test() { - $version = new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); - $response = $version->run(); + $response = (new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + ->run(); - self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['application/json'], + ICanCreateResponses::X_HEADER => ['json'] + ], $response->getHeaders()); self::assertEquals('"0.9.7"', $response->getBody()); } } diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php index 858c9b6cd..4c9e0c169 100644 --- a/tests/src/Module/Api/GnuSocial/Help/TestTest.php +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -11,21 +11,27 @@ class TestTest extends ApiTest { public function testJson() { - $test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); - $response = $test->run(); + $response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + ->run(); $json = $this->toJson($response); - self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['application/json'], + ICanCreateResponses::X_HEADER => ['json'] + ], $response->getHeaders()); self::assertEquals('ok', $json); } public function testXml() { - $test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); - $response = $test->run(); + $response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + ->run(); - self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['text/xml'], + ICanCreateResponses::X_HEADER => ['xml'] + ], $response->getHeaders()); self::assertxml($response->getBody(), 'ok'); } } diff --git a/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php b/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php index 51d76696f..5942aa1d2 100644 --- a/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php +++ b/tests/src/Module/Api/Mastodon/Accounts/VerifyCredentialsTest.php @@ -16,8 +16,8 @@ class VerifyCredentialsTest extends ApiTest */ public function testApiAccountVerifyCredentials() { - $verifyCredentials = new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $verifyCredentials->run(); + $response = (new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php index a76b5d87e..9b29d314b 100644 --- a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php +++ b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php @@ -12,12 +12,15 @@ class RateLimitStatusTest extends ApiTest { public function testWithJson() { - $rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']); - $response = $rateLimitStatus->run(); + $response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) + ->run(); $result = $this->toJson($response); - self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['application/json'], + ICanCreateResponses::X_HEADER => ['json'] + ], $response->getHeaders()); self::assertEquals(150, $result->remaining_hits); self::assertEquals(150, $result->hourly_limit); self::assertIsInt($result->reset_time_in_seconds); @@ -25,10 +28,13 @@ class RateLimitStatusTest extends ApiTest public function testWithXml() { - $rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); - $response = $rateLimitStatus->run(); + $response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml'])) + ->run(); - self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); + self::assertEquals([ + 'Content-type' => ['text/xml'], + ICanCreateResponses::X_HEADER => ['xml'] + ], $response->getHeaders()); self::assertXml($response->getBody(), 'hash'); } } diff --git a/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php index e06e8d484..76cb27c91 100644 --- a/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php +++ b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php @@ -14,8 +14,11 @@ class UpdateProfileTest extends ApiTest */ public function testApiAccountUpdateProfile() { - $updateProfile = new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json']); - $response = $updateProfile->run(['name' => 'new_name', 'description' => 'new_description']); + $response = (new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json'])) + ->run([ + 'name' => 'new_name', + 'description' => 'new_description' + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Blocks/ListsTest.php b/tests/src/Module/Api/Twitter/Blocks/ListsTest.php index a37b59f03..77c45ada8 100644 --- a/tests/src/Module/Api/Twitter/Blocks/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Blocks/ListsTest.php @@ -14,8 +14,8 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithBlocks() { - $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $lists->run(); + $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php b/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php index 52021c71b..63290368a 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/AllTest.php @@ -21,8 +21,8 @@ class AllTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $destroy = 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 = $destroy->run(); + $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'])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php b/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php index 815d5eb57..5667b7276 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/ConversationTest.php @@ -19,10 +19,10 @@ class ConversationTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $sent = 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 = $sent->run([ - 'friendica_verbose' => true, - ]); + $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'])) + ->run([ + 'friendica_verbose' => true, + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php b/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php index f1ab18d5c..b74322778 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/DestroyTest.php @@ -18,7 +18,8 @@ class DestroyTest extends ApiTest public function testApiDirectMessagesDestroy() { $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']))->run(); + (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) + ->run(); } /** @@ -28,10 +29,10 @@ class DestroyTest extends ApiTest */ public function testApiDirectMessagesDestroyWithVerbose() { - $destroy = 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 = $destroy->run([ - 'friendica_verbose' => true, - ]); + $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'])) + ->run([ + 'friendica_verbose' => true, + ]); $json = $this->toJson($response); @@ -64,7 +65,10 @@ class DestroyTest extends ApiTest public function testApiDirectMessagesDestroyWithId() { $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']))->run(['id' => 1]); + (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json'])) + ->run([ + 'id' => 1 + ]); } /** @@ -74,12 +78,12 @@ class DestroyTest extends ApiTest */ public function testApiDirectMessagesDestroyWithIdAndVerbose() { - $destroy = 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 = $destroy->run([ - 'id' => 1, - 'friendica_parenturi' => 'parent_uri', - 'friendica_verbose' => true, - ]); + $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'])) + ->run([ + 'id' => 1, + 'friendica_parenturi' => 'parent_uri', + 'friendica_verbose' => true, + ]); $json = $this->toJson($response); @@ -98,11 +102,11 @@ class DestroyTest extends ApiTest $ids = DBA::selectToArray('mail', ['id']); $id = $ids[0]['id']; - $destroy = 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 = $destroy->run([ - 'id' => $id, - 'friendica_verbose' => true, - ]); + $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'])) + ->run([ + 'id' => $id, + 'friendica_verbose' => true, + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php b/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php index 42c0b5978..beb61ee96 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/InboxTest.php @@ -21,8 +21,8 @@ class InboxTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $destroy = 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 = $destroy->run(); + $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'])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php b/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php index d9bcc87ed..3cae992fa 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/NewDMTest.php @@ -19,8 +19,8 @@ class NewDMTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $newDm = 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 = $newDm->run(); + $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'])) + ->run(); self::assertEmpty((string)$response->getBody()); } @@ -51,11 +51,11 @@ class NewDMTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $newDm = 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 = $newDm->run([ - 'text' => 'message_text', - 'user_id' => 43 - ]); + $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'])) + ->run([ + 'text' => 'message_text', + 'user_id' => 43 + ]); $json = $this->toJson($response); @@ -73,11 +73,11 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $newDm = 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 = $newDm->run([ - 'text' => 'message_text', - 'user_id' => 44 - ]); + $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'])) + ->run([ + 'text' => 'message_text', + 'user_id' => 44 + ]); $json = $this->toJson($response); @@ -97,12 +97,12 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $newDm = 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 = $newDm->run([ - 'text' => 'message_text', - 'user_id' => 44, - 'title' => 'message_title', - ]); + $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'])) + ->run([ + 'text' => 'message_text', + 'user_id' => 44, + 'title' => 'message_title', + ]); $json = $this->toJson($response); @@ -123,12 +123,12 @@ class NewDMTest extends ApiTest $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $newDm = 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 = $newDm->run([ - 'text' => 'message_text', - 'user_id' => 44, - 'title' => 'message_title', - ]); + $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'])) + ->run([ + 'text' => 'message_text', + 'user_id' => 44, + 'title' => 'message_title', + ]); self::assertXml((string)$response->getBody(), 'direct-messages'); } diff --git a/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php b/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php index 334371662..ccea4fd53 100644 --- a/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php +++ b/tests/src/Module/Api/Twitter/DirectMessages/SentTest.php @@ -19,10 +19,10 @@ class SentTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $sent = 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 = $sent->run([ - 'friendica_verbose' => true, - ]); + $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'])) + ->run([ + 'friendica_verbose' => true, + ]); $json = $this->toJson($response); @@ -39,8 +39,8 @@ class SentTest extends ApiTest { $directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()); - $sent = 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 = $sent->run(); + $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'])) + ->run(); self::assertXml((string)$response->getBody(), 'direct-messages'); } diff --git a/tests/src/Module/Api/Twitter/Favorites/CreateTest.php b/tests/src/Module/Api/Twitter/Favorites/CreateTest.php index 00a99643b..1055dd9d1 100644 --- a/tests/src/Module/Api/Twitter/Favorites/CreateTest.php +++ b/tests/src/Module/Api/Twitter/Favorites/CreateTest.php @@ -20,8 +20,8 @@ class CreateTest extends ApiTest { $this->expectException(BadRequestException::class); - $create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $create->run(); + (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -31,8 +31,10 @@ class CreateTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithCreateAction() { - $create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $create->run(['id' => 3]); + $response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'id' => 3 + ]); $json = $this->toJson($response); @@ -46,8 +48,10 @@ class CreateTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithCreateActionAndRss() { - $create = 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 = $create->run(['id' => 3]); + $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])) + ->run([ + 'id' => 3 + ]); self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php b/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php index 3d8ce8a21..65113f556 100644 --- a/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/Favorites/DestroyTest.php @@ -19,8 +19,8 @@ class DestroyTest extends ApiTest { $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(); + (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -30,8 +30,10 @@ class DestroyTest extends ApiTest */ public function testApiFavoritesCreateDestroyWithDestroyAction() { - $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' => 3]); + $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'id' => 3 + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/FavoritesTest.php b/tests/src/Module/Api/Twitter/FavoritesTest.php index dd95d73f9..1f0faa971 100644 --- a/tests/src/Module/Api/Twitter/FavoritesTest.php +++ b/tests/src/Module/Api/Twitter/FavoritesTest.php @@ -17,11 +17,11 @@ class FavoritesTest extends ApiTest */ public function testApiFavorites() { - $favorites = new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $favorites->run([ - 'page' => -1, - 'max_id' => 10, - ]); + $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'page' => -1, + 'max_id' => 10, + ]); $json = $this->toJson($response); @@ -37,8 +37,9 @@ class FavoritesTest extends ApiTest */ public function testApiFavoritesWithRss() { - $favorites = new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]); - $response = $favorites->run(); + $response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ + 'extension' => ICanCreateResponses::TYPE_RSS + ]))->run(); self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/Api/Twitter/Followers/ListsTest.php b/tests/src/Module/Api/Twitter/Followers/ListsTest.php index 7ea3863ea..e9946bb73 100644 --- a/tests/src/Module/Api/Twitter/Followers/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Followers/ListsTest.php @@ -14,8 +14,8 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithFollowers() { - $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $lists->run(); + $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Friends/ListsTest.php b/tests/src/Module/Api/Twitter/Friends/ListsTest.php index 7cb5bd10a..3628f5c96 100644 --- a/tests/src/Module/Api/Twitter/Friends/ListsTest.php +++ b/tests/src/Module/Api/Twitter/Friends/ListsTest.php @@ -16,8 +16,8 @@ class ListsTest extends ApiTest */ public function testApiStatusesFWithFriends() { - $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $lists->run(); + $response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php b/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php index c1309e1f0..d8e5cc3da 100644 --- a/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php +++ b/tests/src/Module/Api/Twitter/Friendships/IncomingTest.php @@ -16,8 +16,8 @@ class IncomingTest extends ApiTest */ public function testApiFriendshipsIncoming() { - $lists = new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $lists->run(); + $response = (new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Lists/StatusesTest.php b/tests/src/Module/Api/Twitter/Lists/StatusesTest.php index 3f47fcaca..66ebf8bbd 100644 --- a/tests/src/Module/Api/Twitter/Lists/StatusesTest.php +++ b/tests/src/Module/Api/Twitter/Lists/StatusesTest.php @@ -19,8 +19,8 @@ class StatusesTest extends ApiTest { $this->expectException(BadRequestException::class); - $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $lists->run(); + (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); } /** @@ -28,8 +28,12 @@ class StatusesTest extends ApiTest */ public function testApiListsStatusesWithListId() { - $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $lists->run(['list_id' => 1, 'page' => -1, 'max_id' => 10]); + $response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'list_id' => 1, + 'page' => -1, + 'max_id' => 10 + ]); $json = $this->toJson($response); @@ -44,8 +48,10 @@ class StatusesTest extends ApiTest */ public function testApiListsStatusesWithListIdAndRss() { - $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']); - $response = $lists->run(['list_id' => 1]); + $response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss'])) + ->run([ + 'list_id' => 1 + ]); self::assertXml((string)$response->getBody()); } diff --git a/tests/src/Module/Api/Twitter/Media/UploadTest.php b/tests/src/Module/Api/Twitter/Media/UploadTest.php index 4b0ffada1..b3516c307 100644 --- a/tests/src/Module/Api/Twitter/Media/UploadTest.php +++ b/tests/src/Module/Api/Twitter/Media/UploadTest.php @@ -19,8 +19,9 @@ class UploadTest extends ApiTest public function testApiMediaUpload() { $this->expectException(BadRequestException::class); - $upload = new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $upload->run(); + + (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -32,7 +33,9 @@ class UploadTest extends ApiTest { $this->expectException(UnauthorizedException::class); AuthTestConfig::$authenticated = false; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(); + + (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -49,7 +52,9 @@ class UploadTest extends ApiTest 'tmp_name' => 'tmp_name' ] ]; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(); + + (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -71,7 +76,8 @@ 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]))->run(); + $response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); $media = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/SavedSearchesTest.php b/tests/src/Module/Api/Twitter/SavedSearchesTest.php index 5735f8eef..667caf98c 100644 --- a/tests/src/Module/Api/Twitter/SavedSearchesTest.php +++ b/tests/src/Module/Api/Twitter/SavedSearchesTest.php @@ -11,8 +11,8 @@ class SavedSearchesTest extends ApiTest { public function test() { - $savedSearch = new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); - $response = $savedSearch->run(); + $response = (new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json'])) + ->run(); $result = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php b/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php index 9b2110eb6..0480ba8c2 100644 --- a/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/DestroyTest.php @@ -19,8 +19,8 @@ class DestroyTest extends ApiTest { $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(); + (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -45,8 +45,10 @@ class DestroyTest extends ApiTest */ public function testApiStatusesDestroyWithId() { - $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]); + $response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'id' => 1 + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php b/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php index 364af4a56..d92f26f72 100644 --- a/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/MentionsTest.php @@ -17,8 +17,10 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentions() { - $mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $mentions->run(['max_id' => 10]); + $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'max_id' => 10 + ]); $json = $this->toJson($response); @@ -33,8 +35,10 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentionsWithNegativePage() { - $mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $mentions->run(['page' => -2]); + $response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'page' => -2 + ]); $json = $this->toJson($response); @@ -63,8 +67,10 @@ class MentionsTest extends ApiTest */ public function testApiStatusesMentionsWithRss() { - $mentions = 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 = $mentions->run(['page' => -2]); + $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])) + ->run([ + 'page' => -2 + ]); self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php b/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php index 7d75cdd7d..a5217fb71 100644 --- a/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/NetworkPublicTimelineTest.php @@ -17,8 +17,10 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimeline() { - $networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $networkPublicTimeline->run(['max_id' => 10]); + $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'max_id' => 10 + ]); $json = $this->toJson($response); @@ -37,8 +39,10 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimelineWithNegativePage() { - $networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $networkPublicTimeline->run(['page' => -2]); + $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'page' => -2 + ]); $json = $this->toJson($response); @@ -71,8 +75,11 @@ class NetworkPublicTimelineTest extends ApiTest */ public function testApiStatusesNetworkpublicTimelineWithRss() { - $networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]); - $response = $networkPublicTimeline->run(['page' => -2]); + $response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ + 'extension' => ICanCreateResponses::TYPE_RSS + ]))->run([ + 'page' => -2 + ]); self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php b/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php index 1b527ccc9..1d93c0296 100644 --- a/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/RetweetTest.php @@ -19,8 +19,8 @@ class RetweetTest extends ApiTest { $this->expectException(BadRequestException::class); - $retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $retweet->run(); + (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run(); } /** @@ -45,8 +45,10 @@ class RetweetTest extends ApiTest */ public function testApiStatusesRepeatWithId() { - $retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $retweet->run(['id' => 1]); + $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'id' => 1 + ]); $json = $this->toJson($response); @@ -60,8 +62,10 @@ class RetweetTest extends ApiTest */ public function testApiStatusesRepeatWithSharedId() { - $retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $retweet->run(['id' => 5]); + $response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'id' => 5 + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/ShowTest.php b/tests/src/Module/Api/Twitter/Statuses/ShowTest.php index c2d87a95f..f9d302f0e 100644 --- a/tests/src/Module/Api/Twitter/Statuses/ShowTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/ShowTest.php @@ -19,8 +19,9 @@ class ShowTest extends ApiTest { $this->expectException(BadRequestException::class); - $show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $show->run(); + + (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); } /** @@ -30,8 +31,10 @@ class ShowTest extends ApiTest */ public function testApiStatusesShowWithId() { - $show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $show->run(['id' => 1]); + $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'id' => 1 + ]); $json = $this->toJson($response); @@ -46,8 +49,11 @@ class ShowTest extends ApiTest */ public function testApiStatusesShowWithConversation() { - $show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $show->run(['id' => 1, 'conversation' => 1]); + $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'id' => 1, + 'conversation' => 1 + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php b/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php index 1d181dd52..f3f6b5a92 100644 --- a/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/UpdateTest.php @@ -28,13 +28,13 @@ class UpdateTest extends ApiTest ] ]; - $show = new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $show->run([ - 'status' => 'Status content #friendica', - 'in_reply_to_status_id' => 0, - 'lat' => 48, - 'long' => 7, - ]); + $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'status' => 'Status content #friendica', + 'in_reply_to_status_id' => 0, + 'lat' => 48, + 'long' => 7, + ]); $json = $this->toJson($response); @@ -50,10 +50,10 @@ class UpdateTest extends ApiTest */ public function testApiStatusesUpdateWithHtml() { - $show = new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $show->run([ - 'htmlstatus' => 'Status content', - ]); + $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST])) + ->run([ + 'htmlstatus' => 'Status content', + ]); $json = $this->toJson($response); diff --git a/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php b/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php index fc2565e31..eb06133f3 100644 --- a/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php +++ b/tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php @@ -17,14 +17,13 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimeline() { - $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - - $response = $networkPublicTimeline->run([ - 'user_id' => 42, - 'max_id' => 10, - 'exclude_replies' => true, - 'conversation_id' => 7, - ]); + $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'user_id' => 42, + 'max_id' => 10, + 'exclude_replies' => true, + 'conversation_id' => 7, + ]); $json = $this->toJson($response); @@ -43,12 +42,11 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimelineWithNegativePage() { - $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - - $response = $networkPublicTimeline->run([ - 'user_id' => 42, - 'page' => -2, - ]); + $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'user_id' => 42, + 'page' => -2, + ]); $json = $this->toJson($response); @@ -67,9 +65,9 @@ class UserTimelineTest extends ApiTest */ public function testApiStatusesUserTimelineWithRss() { - $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]); - - $response = $networkPublicTimeline->run(); + $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ + 'extension' => ICanCreateResponses::TYPE_RSS + ]))->run(); self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/Api/Twitter/Users/LookupTest.php b/tests/src/Module/Api/Twitter/Users/LookupTest.php index e54d20dcf..2c5739e82 100644 --- a/tests/src/Module/Api/Twitter/Users/LookupTest.php +++ b/tests/src/Module/Api/Twitter/Users/LookupTest.php @@ -19,8 +19,8 @@ class LookupTest extends ApiTest { $this->expectException(NotFoundException::class); - $lookup = new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $lookup->run(); + (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); } /** @@ -30,8 +30,10 @@ class LookupTest extends ApiTest */ public function testApiUsersLookupWithUserId() { - $lookup = new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $respone = $lookup->run(['user_id' => static::OTHER_USER['id']]); + $respone = (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'user_id' => static::OTHER_USER['id'] + ]); $json = $this->toJson($respone); diff --git a/tests/src/Module/Api/Twitter/Users/SearchTest.php b/tests/src/Module/Api/Twitter/Users/SearchTest.php index 4fee774da..c88999e45 100644 --- a/tests/src/Module/Api/Twitter/Users/SearchTest.php +++ b/tests/src/Module/Api/Twitter/Users/SearchTest.php @@ -18,8 +18,10 @@ class SearchTest extends ApiTest */ public function testApiUsersSearch() { - $search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $respone = $search->run(['q' => static::OTHER_USER['name']]); + $respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run([ + 'q' => static::OTHER_USER['name'] + ]); $json = $this->toJson($respone); @@ -33,8 +35,11 @@ class SearchTest extends ApiTest */ public function testApiUsersSearchWithXml() { - $search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_XML]); - $respone = $search->run(['q' => static::OTHER_USER['name']]); + $respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ + 'extension' => ICanCreateResponses::TYPE_XML + ]))->run([ + 'q' => static::OTHER_USER['name'] + ]); self::assertXml((string)$respone->getBody(), 'users'); } @@ -48,7 +53,7 @@ class SearchTest extends ApiTest { $this->expectException(BadRequestException::class); - $search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $search->run(); + (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); } } diff --git a/tests/src/Module/Api/Twitter/Users/ShowTest.php b/tests/src/Module/Api/Twitter/Users/ShowTest.php index 975bf6d8f..dd63c3e51 100644 --- a/tests/src/Module/Api/Twitter/Users/ShowTest.php +++ b/tests/src/Module/Api/Twitter/Users/ShowTest.php @@ -17,8 +17,8 @@ class ShowTest extends ApiTest */ public function testApiUsersShow() { - $show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]); - $response = $show->run(); + $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET])) + ->run(); $json = $this->toJson($response); @@ -37,8 +37,9 @@ class ShowTest extends ApiTest */ public function testApiUsersShowWithXml() { - $show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_XML]); - $response = $show->run(); + $response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [ + 'extension' => ICanCreateResponses::TYPE_XML + ]))->run(); self::assertEquals(ICanCreateResponses::TYPE_XML, $response->getHeaderLine(ICanCreateResponses::X_HEADER)); diff --git a/tests/src/Module/NodeInfoTest.php b/tests/src/Module/NodeInfoTest.php index 53a2926f9..b80057e17 100644 --- a/tests/src/Module/NodeInfoTest.php +++ b/tests/src/Module/NodeInfoTest.php @@ -14,10 +14,8 @@ class NodeInfoTest extends FixtureTest { public function testNodeInfo110() { - $response = new Response(); - - $nodeinfo = new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []); - $response = $nodeinfo->run(); + $response = (new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), [])) + ->run(); self::assertJson($response->getBody()); self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); @@ -37,10 +35,8 @@ class NodeInfoTest extends FixtureTest public function testNodeInfo120() { - $response = new Response(); - - $nodeinfo = new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []); - $response = $nodeinfo->run(); + $response = (new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), [])) + ->run(); self::assertJson($response->getBody()); self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); @@ -59,10 +55,8 @@ class NodeInfoTest extends FixtureTest public function testNodeInfo210() { - $response = new Response(); - - $nodeinfo = new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []); - $response = $nodeinfo->run(); + $response = (new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), [])) + ->run(); self::assertJson($response->getBody()); self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());