mirror of
https://github.com/friendica/friendica
synced 2025-04-26 00:30:12 +00:00
Add NodeInfo Module test as an example
This commit is contained in:
parent
537b74f307
commit
78c45bd142
2 changed files with 87 additions and 1 deletions
84
tests/src/Module/NodeInfoTest.php
Normal file
84
tests/src/Module/NodeInfoTest.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module;
|
||||
|
||||
use Friendica\Capabilities\IRespondToRequests;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\NodeInfo110;
|
||||
use Friendica\Module\NodeInfo120;
|
||||
use Friendica\Module\NodeInfo210;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Test\FixtureTest;
|
||||
|
||||
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();
|
||||
|
||||
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
|
||||
self::assertJson($response->getContent());
|
||||
self::assertEquals(['Content-type' => 'application/json'], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getContent());
|
||||
|
||||
self::assertEquals('1.0', $json->version);
|
||||
|
||||
self::assertEquals('friendica', $json->software->name);
|
||||
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
|
||||
|
||||
self::assertIsArray($json->protocols->inbound);
|
||||
self::assertIsArray($json->protocols->outbound);
|
||||
self::assertIsArray($json->services->inbound);
|
||||
self::assertIsArray($json->services->outbound);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
|
||||
self::assertJson($response->getContent());
|
||||
self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getContent());
|
||||
|
||||
self::assertEquals('2.0', $json->version);
|
||||
|
||||
self::assertEquals('friendica', $json->software->name);
|
||||
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
|
||||
|
||||
self::assertIsArray($json->protocols);
|
||||
self::assertIsArray($json->services->inbound);
|
||||
self::assertIsArray($json->services->outbound);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
|
||||
self::assertJson($response->getContent());
|
||||
self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
|
||||
|
||||
$json = json_decode($response->getContent());
|
||||
|
||||
self::assertEquals('1.0', $json->version);
|
||||
|
||||
self::assertEquals('friendica', $json->server->software);
|
||||
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
|
||||
|
||||
self::assertIsArray($json->protocols);
|
||||
self::assertIsArray($json->services->inbound);
|
||||
self::assertIsArray($json->services->outbound);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue