3 namespace Friendica\Test\src\Module;
5 use Friendica\Capabilities\IRespondToRequests;
7 use Friendica\Module\NodeInfo110;
8 use Friendica\Module\NodeInfo120;
9 use Friendica\Module\NodeInfo210;
10 use Friendica\Module\Response;
11 use Friendica\Test\FixtureTest;
13 class NodeInfoTest extends FixtureTest
15 public function testNodeInfo110()
17 $response = new Response();
19 $nodeinfo = new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
20 $response = $nodeinfo->run();
22 self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
23 self::assertJson($response->getContent());
24 self::assertEquals(['Content-type' => 'application/json'], $response->getHeaders());
26 $json = json_decode($response->getContent());
28 self::assertEquals('1.0', $json->version);
30 self::assertEquals('friendica', $json->software->name);
31 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
33 self::assertIsArray($json->protocols->inbound);
34 self::assertIsArray($json->protocols->outbound);
35 self::assertIsArray($json->services->inbound);
36 self::assertIsArray($json->services->outbound);
39 public function testNodeInfo120()
41 $response = new Response();
43 $nodeinfo = new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
44 $response = $nodeinfo->run();
46 self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
47 self::assertJson($response->getContent());
48 self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
50 $json = json_decode($response->getContent());
52 self::assertEquals('2.0', $json->version);
54 self::assertEquals('friendica', $json->software->name);
55 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
57 self::assertIsArray($json->protocols);
58 self::assertIsArray($json->services->inbound);
59 self::assertIsArray($json->services->outbound);
62 public function testNodeInfo210()
64 $response = new Response();
66 $nodeinfo = new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
67 $response = $nodeinfo->run();
69 self::assertEquals(IRespondToRequests::TYPE_JSON, $response->getType());
70 self::assertJson($response->getContent());
71 self::assertEquals(['Content-type' => 'application/json; charset=utf-8'], $response->getHeaders());
73 $json = json_decode($response->getContent());
75 self::assertEquals('1.0', $json->version);
77 self::assertEquals('friendica', $json->server->software);
78 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
80 self::assertIsArray($json->protocols);
81 self::assertIsArray($json->services->inbound);
82 self::assertIsArray($json->services->outbound);