// 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.
*
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
--- /dev/null
+<?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');
+ }
+}