From 0757c00d52c8fb7113c18da77451027563a46214 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 12 Nov 2021 22:03:41 +0100 Subject: [PATCH] Move Api\Help --- tests/legacy/ApiTest.php | 24 ------------------- tests/src/Module/Api/ApiTest.php | 15 ++++++++++++ .../Module/Api/GnuSocial/Help/TestTest.php | 24 +++++++++++++++++++ 3 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 tests/src/Module/Api/GnuSocial/Help/TestTest.php diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index 0c1af085ca..800bc772e4 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -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. * diff --git a/tests/src/Module/Api/ApiTest.php b/tests/src/Module/Api/ApiTest.php index 23a109e6f8..58bbb5c388 100644 --- a/tests/src/Module/Api/ApiTest.php +++ b/tests/src/Module/Api/ApiTest.php @@ -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('', $result); + self::assertStringContainsString('<' . $root_element, $result); + // We could probably do more checks here. + } + protected function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php new file mode 100644 index 0000000000..c962cac302 --- /dev/null +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -0,0 +1,24 @@ + 'json']); + + self::assertEquals('"ok"', ApiResponseDouble::getOutput()); + } + + public function testXml() + { + Test::rawContent(['extension' => 'xml']); + + self::assertxml(ApiResponseDouble::getOutput(), 'ok'); + } +}