2021-11-21 21:07:23 +00:00
|
|
|
<?php
|
2022-01-06 23:30:59 +00:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
namespace Friendica\Test\src\Module;
|
|
|
|
|
2022-10-17 10:37:48 +00:00
|
|
|
use Friendica\App;
|
2021-11-21 23:07:09 +00:00
|
|
|
use Friendica\Capabilities\ICanCreateResponses;
|
2021-11-21 21:07:23 +00:00
|
|
|
use Friendica\DI;
|
|
|
|
use Friendica\Module\NodeInfo110;
|
|
|
|
use Friendica\Module\NodeInfo120;
|
|
|
|
use Friendica\Module\NodeInfo210;
|
|
|
|
use Friendica\Test\FixtureTest;
|
|
|
|
|
|
|
|
class NodeInfoTest extends FixtureTest
|
|
|
|
{
|
|
|
|
public function testNodeInfo110()
|
|
|
|
{
|
2022-01-02 00:04:04 +00:00
|
|
|
$response = (new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
|
|
|
->run();
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
self::assertJson($response->getBody());
|
2021-11-21 23:07:09 +00:00
|
|
|
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
$json = json_decode($response->getBody());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertEquals('1.0', $json->version);
|
|
|
|
|
|
|
|
self::assertEquals('friendica', $json->software->name);
|
2022-10-17 10:37:48 +00:00
|
|
|
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertIsArray($json->protocols->inbound);
|
|
|
|
self::assertIsArray($json->protocols->outbound);
|
|
|
|
self::assertIsArray($json->services->inbound);
|
|
|
|
self::assertIsArray($json->services->outbound);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNodeInfo120()
|
|
|
|
{
|
2022-01-02 00:04:04 +00:00
|
|
|
$response = (new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
|
|
|
->run();
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
self::assertJson($response->getBody());
|
2021-11-21 23:07:09 +00:00
|
|
|
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
$json = json_decode($response->getBody());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertEquals('2.0', $json->version);
|
|
|
|
|
|
|
|
self::assertEquals('friendica', $json->software->name);
|
2022-10-17 10:37:48 +00:00
|
|
|
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertIsArray($json->protocols);
|
|
|
|
self::assertIsArray($json->services->inbound);
|
|
|
|
self::assertIsArray($json->services->outbound);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNodeInfo210()
|
|
|
|
{
|
2022-01-02 00:04:04 +00:00
|
|
|
$response = (new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
|
|
|
->run();
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
self::assertJson($response->getBody());
|
2021-11-21 23:07:09 +00:00
|
|
|
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
2021-11-21 22:37:17 +00:00
|
|
|
$json = json_decode($response->getBody());
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertEquals('1.0', $json->version);
|
|
|
|
|
|
|
|
self::assertEquals('friendica', $json->server->software);
|
2022-10-17 10:37:48 +00:00
|
|
|
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
|
2021-11-21 21:07:23 +00:00
|
|
|
|
|
|
|
self::assertIsArray($json->protocols);
|
|
|
|
self::assertIsArray($json->services->inbound);
|
|
|
|
self::assertIsArray($json->services->outbound);
|
|
|
|
}
|
|
|
|
}
|