]> git.mxchange.org Git - friendica.git/blob - tests/src/Module/NodeInfoTest.php
Adapt UserSession
[friendica.git] / tests / src / Module / NodeInfoTest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
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.
11  *
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.
16  *
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/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Module;
23
24 use Friendica\App;
25 use Friendica\Capabilities\ICanCreateResponses;
26 use Friendica\DI;
27 use Friendica\Module\NodeInfo110;
28 use Friendica\Module\NodeInfo120;
29 use Friendica\Module\NodeInfo210;
30 use Friendica\Test\FixtureTest;
31
32 class NodeInfoTest extends FixtureTest
33 {
34         public function testNodeInfo110()
35         {
36                 $response = (new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
37                         ->run();
38
39                 self::assertJson($response->getBody());
40                 self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
41
42                 $json = json_decode($response->getBody());
43
44                 self::assertEquals('1.0', $json->version);
45
46                 self::assertEquals('friendica', $json->software->name);
47                 self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
48
49                 self::assertIsArray($json->protocols->inbound);
50                 self::assertIsArray($json->protocols->outbound);
51                 self::assertIsArray($json->services->inbound);
52                 self::assertIsArray($json->services->outbound);
53         }
54
55         public function testNodeInfo120()
56         {
57                 $response = (new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
58                         ->run();
59
60                 self::assertJson($response->getBody());
61                 self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
62
63                 $json = json_decode($response->getBody());
64
65                 self::assertEquals('2.0', $json->version);
66
67                 self::assertEquals('friendica', $json->software->name);
68                 self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
69
70                 self::assertIsArray($json->protocols);
71                 self::assertIsArray($json->services->inbound);
72                 self::assertIsArray($json->services->outbound);
73         }
74
75         public function testNodeInfo210()
76         {
77                 $response = (new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
78                         ->run();
79
80                 self::assertJson($response->getBody());
81                 self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
82
83                 $json = json_decode($response->getBody());
84
85                 self::assertEquals('1.0', $json->version);
86
87                 self::assertEquals('friendica', $json->server->software);
88                 self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
89
90                 self::assertIsArray($json->protocols);
91                 self::assertIsArray($json->services->inbound);
92                 self::assertIsArray($json->services->outbound);
93         }
94 }