From d32f8e5285e6bb2265398fd658a39d3a6b5ff94e Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 14 Nov 2021 23:35:01 +0100 Subject: [PATCH] Adapt API tests for dynamic usage --- tests/src/Module/Api/Friendica/NotificationTest.php | 6 ++++-- tests/src/Module/Api/Friendica/Photo/DeleteTest.php | 4 ++-- tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php | 4 ++-- tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php | 6 +++--- tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php | 3 ++- tests/src/Module/Api/GnuSocial/Help/TestTest.php | 6 ++++-- .../src/Module/Api/Twitter/Account/RateLimitStatusTest.php | 6 ++++-- tests/src/Module/Api/Twitter/SavedSearchesTest.php | 3 ++- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index 7a213e2a5..7f1fd701f 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -67,14 +67,16 @@ class NotificationTest extends ApiTest XML; - Notification::rawContent(['extension' => 'xml']); + $notification = new Notification(['extension' => 'xml']); + $notification->rawContent(); self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput()); } public function testWithJsonResult() { - Notification::rawContent(['parameter' => 'json']); + $notification = new Notification(['parameter' => 'json']); + $notification->rawContent(); $result = json_encode(ApiResponseDouble::getOutput()); diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index 3fd1d92f7..5581c9cc2 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -30,7 +30,7 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Delete::rawContent(); + (new Delete())->rawContent(); } public function testWithoutAuthenticatedUser() @@ -41,7 +41,7 @@ class DeleteTest extends ApiTest public function testWrong() { $this->expectException(BadRequestException::class); - Delete::rawContent(['photo_id' => 1]); + (new Delete(['photo_id' => 1]))->rawContent(); } public function testWithCorrectPhotoId() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index f99e61bd1..6ee3c5e7b 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -30,13 +30,13 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Delete::rawContent(); + (new Delete())->rawContent(); } public function testWrong() { $this->expectException(BadRequestException::class); - Delete::rawContent(['album' => 'album_name']); + (new Delete(['album' => 'album_name']))->rawContent(); } public function testValid() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index b07d4c5bc..c7d65cb16 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -30,19 +30,19 @@ class UpdateTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Update::rawContent(); + (new Update())->rawContent(); } public function testTooFewArgs() { $this->expectException(BadRequestException::class); - Update::rawContent(['album' => 'album_name']); + (new Update(['album' => 'album_name']))->rawContent(); } public function testWrongUpdate() { $this->expectException(BadRequestException::class); - Update::rawContent(['album' => 'album_name', 'album_new' => 'album_name']); + (new Update(['album' => 'album_name', 'album_new' => 'album_name']))->rawContent(); } public function testWithoutAuthenticatedUser() diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php index 454b8ef40..a819a7a1e 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php @@ -10,7 +10,8 @@ class VersionTest extends ApiTest { public function test() { - Version::rawContent(['extension' => 'json']); + $version = new Version(['extension' => 'json']); + $version->rawContent(); $result = json_decode(ApiResponseDouble::getOutput()); diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php index c962cac30..c624ca032 100644 --- a/tests/src/Module/Api/GnuSocial/Help/TestTest.php +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -10,14 +10,16 @@ class TestTest extends ApiTest { public function testJson() { - Test::rawContent(['extension' => 'json']); + $test = new Test(['extension' => 'json']); + $test->rawContent(); self::assertEquals('"ok"', ApiResponseDouble::getOutput()); } public function testXml() { - Test::rawContent(['extension' => 'xml']); + $test = new Test(['extension' => 'xml']); + $test->rawContent(); self::assertxml(ApiResponseDouble::getOutput(), 'ok'); } diff --git a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php index 46088d330..3a84324af 100644 --- a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php +++ b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php @@ -10,7 +10,8 @@ class RateLimitStatusTest extends ApiTest { public function testWithJson() { - RateLimitStatus::rawContent(['extension' => 'json']); + $rateLimitStatus = new RateLimitStatus(['extension' => 'json']); + $rateLimitStatus->rawContent(); $result = json_decode(ApiResponseDouble::getOutput()); @@ -21,7 +22,8 @@ class RateLimitStatusTest extends ApiTest public function testWithXml() { - RateLimitStatus::rawContent(['extension' => 'xml']); + $rateLimitStatus = new RateLimitStatus(['extension' => 'xml']); + $rateLimitStatus->rawContent(); self::assertXml(ApiResponseDouble::getOutput(), 'hash'); } diff --git a/tests/src/Module/Api/Twitter/SavedSearchesTest.php b/tests/src/Module/Api/Twitter/SavedSearchesTest.php index f4dad04fc..fc0f80467 100644 --- a/tests/src/Module/Api/Twitter/SavedSearchesTest.php +++ b/tests/src/Module/Api/Twitter/SavedSearchesTest.php @@ -10,7 +10,8 @@ class SavedSearchesTest extends ApiTest { public function test() { - SavedSearches::rawContent(['extension' => 'json']); + $savedSearch = new SavedSearches(['extension' => 'json']); + $savedSearch->rawContent(); $result = json_decode(ApiResponseDouble::getOutput());