Replace IRespondToRequests with PSR-7 ResponseInterface

This commit is contained in:
Philipp 2021-11-21 23:37:17 +01:00
parent ca5c40c97e
commit 7cd85873ee
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
17 changed files with 96 additions and 92 deletions

View file

@ -68,7 +68,7 @@ XML;
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
$response = $notification->run();
self::assertXmlStringEqualsXmlString($assertXml, $response->getContent());
self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody());
}
public function testWithJsonResult()
@ -76,6 +76,6 @@ XML;
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
$response = $notification->run();
self::assertJson($response->getContent());
self::assertJson($response->getBody());
}
}

View file

@ -13,6 +13,6 @@ class VersionTest extends ApiTest
$version = new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
$response = $version->run();
self::assertEquals('"0.9.7"', $response->getContent());
self::assertEquals('"0.9.7"', $response->getBody());
}
}

View file

@ -13,7 +13,7 @@ class TestTest extends ApiTest
$test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
$response = $test->run();
self::assertEquals('"ok"', $response->getContent());
self::assertEquals('"ok"', $response->getBody());
}
public function testXml()
@ -21,6 +21,6 @@ class TestTest extends ApiTest
$test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
$response = $test->run();
self::assertxml($response->getContent(), 'ok');
self::assertxml($response->getBody(), 'ok');
}
}

View file

@ -13,7 +13,7 @@ class RateLimitStatusTest extends ApiTest
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
$response = $rateLimitStatus->run();
$result = json_decode($response->getContent());
$result = json_decode($response->getBody());
self::assertEquals(150, $result->remaining_hits);
self::assertEquals(150, $result->hourly_limit);
@ -25,6 +25,6 @@ class RateLimitStatusTest extends ApiTest
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
$response = $rateLimitStatus->run();
self::assertXml($response->getContent(), 'hash');
self::assertXml($response->getBody(), 'hash');
}
}

View file

@ -13,7 +13,7 @@ class SavedSearchesTest extends ApiTest
$savedSearch = new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
$response = $savedSearch->run();
$result = json_decode($response->getContent());
$result = json_decode($response->getBody());
self::assertEquals(1, $result[0]->id);
self::assertEquals(1, $result[0]->id_str);

View file

@ -2,7 +2,6 @@
namespace Friendica\Test\src\Module;
use Friendica\Capabilities\IRespondToRequests;
use Friendica\DI;
use Friendica\Module\NodeInfo110;
use Friendica\Module\NodeInfo120;
@ -19,11 +18,10 @@ class NodeInfoTest extends FixtureTest
$nodeinfo = new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
$response = $nodeinfo->run();
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
self::assertJson($response->getContent());
self::assertEquals(['Content-type' => 'application/json'], $response->getHeaders());
self::assertJson($response->getBody());
self::assertEquals(['Content-type' => ['application/json']], $response->getHeaders());
$json = json_decode($response->getContent());
$json = json_decode($response->getBody());
self::assertEquals('1.0', $json->version);
@ -43,11 +41,10 @@ class NodeInfoTest extends FixtureTest
$nodeinfo = new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
$response = $nodeinfo->run();
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
self::assertJson($response->getContent());
self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
self::assertJson($response->getBody());
self::assertEquals(['Content-type' => ['application/json; charset=utf-8']], $response->getHeaders());
$json = json_decode($response->getContent());
$json = json_decode($response->getBody());
self::assertEquals('2.0', $json->version);
@ -66,11 +63,10 @@ class NodeInfoTest extends FixtureTest
$nodeinfo = new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
$response = $nodeinfo->run();
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
self::assertJson($response->getContent());
self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
self::assertJson($response->getBody());
self::assertEquals(['Content-type' => ['application/json; charset=utf-8']], $response->getHeaders());
$json = json_decode($response->getContent());
$json = json_decode($response->getBody());
self::assertEquals('1.0', $json->version);