diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index 0c1af085c..800bc772e 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 23a109e6f..58bbb5c38 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 000000000..c962cac30 --- /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'); + } +}