Adapt API tests for dynamic usage

This commit is contained in:
Philipp 2021-11-14 23:35:01 +01:00
parent cca1be21a3
commit d32f8e5285
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
8 changed files with 23 additions and 15 deletions

View file

@ -67,14 +67,16 @@ class NotificationTest extends ApiTest
</notes> </notes>
XML; XML;
Notification::rawContent(['extension' => 'xml']); $notification = new Notification(['extension' => 'xml']);
$notification->rawContent();
self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput()); self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput());
} }
public function testWithJsonResult() public function testWithJsonResult()
{ {
Notification::rawContent(['parameter' => 'json']); $notification = new Notification(['parameter' => 'json']);
$notification->rawContent();
$result = json_encode(ApiResponseDouble::getOutput()); $result = json_encode(ApiResponseDouble::getOutput());

View file

@ -30,7 +30,7 @@ class DeleteTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Delete::rawContent(); (new Delete())->rawContent();
} }
public function testWithoutAuthenticatedUser() public function testWithoutAuthenticatedUser()
@ -41,7 +41,7 @@ class DeleteTest extends ApiTest
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Delete::rawContent(['photo_id' => 1]); (new Delete(['photo_id' => 1]))->rawContent();
} }
public function testWithCorrectPhotoId() public function testWithCorrectPhotoId()

View file

@ -30,13 +30,13 @@ class DeleteTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Delete::rawContent(); (new Delete())->rawContent();
} }
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Delete::rawContent(['album' => 'album_name']); (new Delete(['album' => 'album_name']))->rawContent();
} }
public function testValid() public function testValid()

View file

@ -30,19 +30,19 @@ class UpdateTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Update::rawContent(); (new Update())->rawContent();
} }
public function testTooFewArgs() public function testTooFewArgs()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
Update::rawContent(['album' => 'album_name']); (new Update(['album' => 'album_name']))->rawContent();
} }
public function testWrongUpdate() public function testWrongUpdate()
{ {
$this->expectException(BadRequestException::class); $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() public function testWithoutAuthenticatedUser()

View file

@ -10,7 +10,8 @@ class VersionTest extends ApiTest
{ {
public function test() public function test()
{ {
Version::rawContent(['extension' => 'json']); $version = new Version(['extension' => 'json']);
$version->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());

View file

@ -10,14 +10,16 @@ class TestTest extends ApiTest
{ {
public function testJson() public function testJson()
{ {
Test::rawContent(['extension' => 'json']); $test = new Test(['extension' => 'json']);
$test->rawContent();
self::assertEquals('"ok"', ApiResponseDouble::getOutput()); self::assertEquals('"ok"', ApiResponseDouble::getOutput());
} }
public function testXml() public function testXml()
{ {
Test::rawContent(['extension' => 'xml']); $test = new Test(['extension' => 'xml']);
$test->rawContent();
self::assertxml(ApiResponseDouble::getOutput(), 'ok'); self::assertxml(ApiResponseDouble::getOutput(), 'ok');
} }

View file

@ -10,7 +10,8 @@ class RateLimitStatusTest extends ApiTest
{ {
public function testWithJson() public function testWithJson()
{ {
RateLimitStatus::rawContent(['extension' => 'json']); $rateLimitStatus = new RateLimitStatus(['extension' => 'json']);
$rateLimitStatus->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());
@ -21,7 +22,8 @@ class RateLimitStatusTest extends ApiTest
public function testWithXml() public function testWithXml()
{ {
RateLimitStatus::rawContent(['extension' => 'xml']); $rateLimitStatus = new RateLimitStatus(['extension' => 'xml']);
$rateLimitStatus->rawContent();
self::assertXml(ApiResponseDouble::getOutput(), 'hash'); self::assertXml(ApiResponseDouble::getOutput(), 'hash');
} }

View file

@ -10,7 +10,8 @@ class SavedSearchesTest extends ApiTest
{ {
public function test() public function test()
{ {
SavedSearches::rawContent(['extension' => 'json']); $savedSearch = new SavedSearches(['extension' => 'json']);
$savedSearch->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());