Move Api\Help

This commit is contained in:
Philipp 2021-11-12 22:03:41 +01:00
parent 9482ef3c34
commit 0757c00d52
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
3 changed files with 39 additions and 24 deletions

View File

@ -2567,30 +2567,6 @@ class ApiTest extends FixtureTest
// self::assertXml($result, 'hash');
}
/**
* Test the api_help_test() function.
*
* @return void
*/
public function testApiHelpTest()
{
// @todo How to test the new API?
// $result = \Friendica\Module\Api\Friendica\Help\Test::rawcontent(['extension' => 'json']);
// self::assertEquals(['ok' => 'ok'], $result);
}
/**
* Test the api_help_test() function with an XML result.
*
* @return void
*/
public function testApiHelpTestWithXml()
{
// @todo How to test the new API?
// $result = api_help_test('xml');
// self::assertXml($result, 'ok');
}
/**
* Test the api_lists_list() function.
*

View File

@ -33,6 +33,21 @@ use Friendica\Test\Util\AuthenticationDouble;
class ApiTest extends FixtureTest
{
/**
* Assert that the string is XML and contain the root element.
*
* @param string $result XML string
* @param string $root_element Root element name
*
* @return void
*/
protected function assertXml(string $result = '', string $root_element = '')
{
self::assertStringStartsWith('<?xml version="1.0"?>', $result);
self::assertStringContainsString('<' . $root_element, $result);
// We could probably do more checks here.
}
protected function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub

View File

@ -0,0 +1,24 @@
<?php
namespace Friendica\Test\src\Module\Api\GnuSocial\Help;
use Friendica\Module\Api\GNUSocial\Help\Test;
use Friendica\Test\src\Module\Api\ApiTest;
use Friendica\Test\Util\ApiResponseDouble;
class TestTest extends ApiTest
{
public function testJson()
{
Test::rawContent(['extension' => 'json']);
self::assertEquals('"ok"', ApiResponseDouble::getOutput());
}
public function testXml()
{
Test::rawContent(['extension' => 'xml']);
self::assertxml(ApiResponseDouble::getOutput(), 'ok');
}
}