]> git.mxchange.org Git - friendica.git/commitdiff
Move Api\Help
authorPhilipp <admin@philipp.info>
Fri, 12 Nov 2021 21:03:41 +0000 (22:03 +0100)
committerPhilipp <admin@philipp.info>
Fri, 12 Nov 2021 21:03:41 +0000 (22:03 +0100)
tests/legacy/ApiTest.php
tests/src/Module/Api/ApiTest.php
tests/src/Module/Api/GnuSocial/Help/TestTest.php [new file with mode: 0644]

index 0c1af085ca3ad57826332b869b78515b49a83a32..800bc772e457e424ffd8f32c387d07d69ef5103d 100644 (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.
         *
index 23a109e6f8162cac29612dab67c0d9fb836fcdff..58bbb5c388323ac35510b33aeb57649f0c0bd3b9 100644 (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
diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php
new file mode 100644 (file)
index 0000000..c962cac
--- /dev/null
@@ -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');
+       }
+}