3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Module;
24 use Friendica\Capabilities\ICanCreateResponses;
26 use Friendica\Module\NodeInfo110;
27 use Friendica\Module\NodeInfo120;
28 use Friendica\Module\NodeInfo210;
29 use Friendica\Module\Response;
30 use Friendica\Test\FixtureTest;
32 class NodeInfoTest extends FixtureTest
34 public function testNodeInfo110()
36 $response = (new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
39 self::assertJson($response->getBody());
40 self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
42 $json = json_decode($response->getBody());
44 self::assertEquals('1.0', $json->version);
46 self::assertEquals('friendica', $json->software->name);
47 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
49 self::assertIsArray($json->protocols->inbound);
50 self::assertIsArray($json->protocols->outbound);
51 self::assertIsArray($json->services->inbound);
52 self::assertIsArray($json->services->outbound);
55 public function testNodeInfo120()
57 $response = (new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
60 self::assertJson($response->getBody());
61 self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
63 $json = json_decode($response->getBody());
65 self::assertEquals('2.0', $json->version);
67 self::assertEquals('friendica', $json->software->name);
68 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
70 self::assertIsArray($json->protocols);
71 self::assertIsArray($json->services->inbound);
72 self::assertIsArray($json->services->outbound);
75 public function testNodeInfo210()
77 $response = (new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
80 self::assertJson($response->getBody());
81 self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
83 $json = json_decode($response->getBody());
85 self::assertEquals('1.0', $json->version);
87 self::assertEquals('friendica', $json->server->software);
88 self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
90 self::assertIsArray($json->protocols);
91 self::assertIsArray($json->services->inbound);
92 self::assertIsArray($json->services->outbound);