mirror of
https://github.com/friendica/friendica
synced 2025-04-26 00:30:12 +00:00
Fixing Response
This commit is contained in:
parent
ae24bf8d54
commit
6a9fff5100
11 changed files with 41 additions and 12 deletions
|
@ -37,6 +37,7 @@ class ApiResponseTest extends MockedTest
|
|||
$response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser);
|
||||
$response->error(200, 'OK', 'error_message', 'xml');
|
||||
|
||||
self::assertEquals(['Content-type' => 'text/xml', 'HTTP/1.1 200 OK'], $response->getHeaders());
|
||||
self::assertEquals('<?xml version="1.0"?>' . "\n" .
|
||||
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
|
||||
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
|
||||
|
@ -59,6 +60,7 @@ class ApiResponseTest extends MockedTest
|
|||
$response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser);
|
||||
$response->error(200, 'OK', 'error_message', 'rss');
|
||||
|
||||
self::assertEquals(['Content-type' => 'application/rss+xml', 'HTTP/1.1 200 OK'], $response->getHeaders());
|
||||
self::assertEquals(
|
||||
'<?xml version="1.0"?>' . "\n" .
|
||||
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
|
||||
|
@ -82,6 +84,7 @@ class ApiResponseTest extends MockedTest
|
|||
$response = new ApiResponse($l10n, $args, new NullLogger(), $baseUrl, $twitterUser);
|
||||
$response->error(200, 'OK', 'error_message', 'atom');
|
||||
|
||||
self::assertEquals(['Content-type' => 'application/atom+xml', 'HTTP/1.1 200 OK'], $response->getHeaders());
|
||||
self::assertEquals(
|
||||
'<?xml version="1.0"?>' . "\n" .
|
||||
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Friendica;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Friendica\Notification;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
@ -68,7 +69,10 @@ XML;
|
|||
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
|
||||
$response = $notification->run();
|
||||
|
||||
print_r($response->getHeaders());
|
||||
|
||||
self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody());
|
||||
self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
}
|
||||
|
||||
public function testWithJsonResult()
|
||||
|
@ -77,5 +81,6 @@ XML;
|
|||
$response = $notification->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\GNUSocial\GNUSocial\Version;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
@ -13,6 +14,7 @@ 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(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals('"0.9.7"', $response->getBody());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\GnuSocial\Help;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\GNUSocial\Help\Test;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
@ -13,6 +14,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(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals('"ok"', $response->getBody());
|
||||
}
|
||||
|
||||
|
@ -21,6 +23,7 @@ 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::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertxml($response->getBody(), 'ok');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
@ -15,6 +16,7 @@ class RateLimitStatusTest extends ApiTest
|
|||
|
||||
$result = json_decode($response->getBody());
|
||||
|
||||
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,6 +27,7 @@ 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::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertXml($response->getBody(), 'hash');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\SavedSearches;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
@ -15,6 +16,7 @@ class SavedSearchesTest extends ApiTest
|
|||
|
||||
$result = json_decode($response->getBody());
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals(1, $result[0]->id);
|
||||
self::assertEquals(1, $result[0]->id_str);
|
||||
self::assertEquals('Saved search', $result[0]->name);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\NodeInfo110;
|
||||
use Friendica\Module\NodeInfo120;
|
||||
|
@ -19,7 +20,7 @@ class NodeInfoTest extends FixtureTest
|
|||
$response = $nodeinfo->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json']], $response->getHeaders());
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getBody());
|
||||
|
||||
|
@ -42,7 +43,7 @@ class NodeInfoTest extends FixtureTest
|
|||
$response = $nodeinfo->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8']], $response->getHeaders());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getBody());
|
||||
|
||||
|
@ -64,7 +65,7 @@ class NodeInfoTest extends FixtureTest
|
|||
$response = $nodeinfo->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8']], $response->getHeaders());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getBody());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue