6 namespace Friendica\Test\legacy;
9 use Friendica\App\Router;
10 use Friendica\Core\Config\Capability\IManageConfigValues;
11 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
12 use Friendica\Core\Protocol;
14 use Friendica\Model\Post;
15 use Friendica\Module\Api\ApiResponse;
16 use Friendica\Module\Api\Twitter\Media\Upload;
17 use Friendica\Module\BaseApi;
18 use Friendica\Network\HTTPException;
19 use Friendica\Security\BasicAuth;
20 use Friendica\Test\FixtureTest;
21 use Friendica\Util\Arrays;
22 use Friendica\Util\DateTimeFormat;
23 use Friendica\Util\Temporal;
24 use Monolog\Handler\TestHandler;
26 require_once __DIR__ . '/../../include/api.php';
29 * Tests for the API functions.
31 * Functions that use header() need to be tested in a separate process.
32 * @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
34 * @backupGlobals enabled
36 class ApiTest extends FixtureTest
39 * @var TestHandler Can handle log-outputs
46 protected $friendUser;
50 protected $wrongUserId;
55 /** @var IManageConfigValues */
59 * Create variables used by tests.
61 protected function setUp() : void
63 global $API, $called_api;
69 /** @var IManageConfigValues $config */
70 $this->config = $this->dice->create(IManageConfigValues::class);
72 $this->config->set('system', 'url', 'http://localhost');
73 $this->config->set('system', 'hostname', 'localhost');
74 $this->config->set('system', 'worker_dont_fork', true);
77 $this->config->set('config', 'hostname', 'localhost');
78 $this->config->set('system', 'throttle_limit_day', 100);
79 $this->config->set('system', 'throttle_limit_week', 100);
80 $this->config->set('system', 'throttle_limit_month', 100);
81 $this->config->set('system', 'theme', 'system_theme');
85 $this->app = DI::app();
87 DI::args()->setArgc(1);
89 // User data that the test database is populated with
92 'name' => 'Self contact',
93 'nick' => 'selfcontact',
94 'nurl' => 'http://localhost/profile/selfcontact'
98 'name' => 'Friend contact',
99 'nick' => 'friendcontact',
100 'nurl' => 'http://localhost/profile/friendcontact'
104 'name' => 'othercontact',
105 'nick' => 'othercontact',
106 'nurl' => 'http://localhost/profile/othercontact'
109 // User ID that we know is not in the database
110 $this->wrongUserId = 666;
112 DI::session()->start();
114 // Most API require login so we force the session
116 'authenticated' => true,
117 'uid' => $this->selfUser['id']
119 BasicAuth::setCurrentUserID($this->selfUser['id']);
123 * Assert that an user array contains expected keys.
125 * @param array $user User array
129 private function assertSelfUser(array $user)
131 self::assertEquals($this->selfUser['id'], $user['uid']);
132 self::assertEquals($this->selfUser['id'], $user['cid']);
133 self::assertEquals(1, $user['self']);
134 self::assertEquals('DFRN', $user['location']);
135 self::assertEquals($this->selfUser['name'], $user['name']);
136 self::assertEquals($this->selfUser['nick'], $user['screen_name']);
137 self::assertEquals('dfrn', $user['network']);
138 self::assertTrue($user['verified']);
142 * Assert that an user array contains expected keys.
144 * @param array $user User array
148 private function assertOtherUser(array $user = [])
150 self::assertEquals($this->otherUser['id'], $user['id']);
151 self::assertEquals($this->otherUser['id'], $user['id_str']);
152 self::assertEquals($this->otherUser['name'], $user['name']);
153 self::assertEquals($this->otherUser['nick'], $user['screen_name']);
154 self::assertFalse($user['verified']);
158 * Assert that a status array contains expected keys.
160 * @param array $status Status array
164 private function assertStatus(array $status = [])
166 self::assertIsString($status['text'] ?? '');
167 self::assertIsInt($status['id'] ?? '');
168 // We could probably do more checks here.
172 * Assert that a list array contains expected keys.
174 * @param array $list List array
178 private function assertList(array $list = [])
180 self::assertIsString($list['name']);
181 self::assertIsInt($list['id']);
182 self::assertIsString('string', $list['id_str']);
183 self::assertContains($list['mode'], ['public', 'private']);
184 // We could probably do more checks here.
188 * Assert that the string is XML and contain the root element.
190 * @param string $result XML string
191 * @param string $root_element Root element name
195 private function assertXml($result = '', $root_element = '')
197 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
198 self::assertStringContainsString('<' . $root_element, $result);
199 // We could probably do more checks here.
203 * Get the path to a temporary empty PNG image.
205 * @return string Path
207 private function getTempImage()
209 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
213 // Empty 1x1 px PNG image
214 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
222 * Test the api_user() function.
226 public function testApiUser()
228 self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
232 * Test the api_user() function with an unallowed user.
236 public function testApiUserWithUnallowedUser()
238 // self::assertEquals(false, api_user());
242 * Test the api_source() function.
246 public function testApiSource()
248 self::assertEquals('api', BasicAuth::getCurrentApplicationToken()['name']);
252 * Test the api_source() function with a Twidere user agent.
256 public function testApiSourceWithTwidere()
258 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
259 self::assertEquals('Twidere', BasicAuth::getCurrentApplicationToken()['name']);
263 * Test the api_source() function with a GET parameter.
267 public function testApiSourceWithGet()
269 $_REQUEST['source'] = 'source_name';
270 self::assertEquals('source_name', BasicAuth::getCurrentApplicationToken()['name']);
274 * Test the api_date() function.
278 public function testApiDate()
280 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', DateTimeFormat::utc('1990-10-10', DateTimeFormat::API));
284 * Test the api_register_func() function.
288 public function testApiRegisterFunc()
300 self::assertTrue(is_callable($API['api_path']['func']));
304 * Test the BasicAuth::getCurrentUserID() function without any login.
306 * @runInSeparateProcess
307 * @preserveGlobalState disabled
308 * @preserveGlobalState disabled
310 public function testApiLoginWithoutLogin()
312 BasicAuth::setCurrentUserID();
313 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
314 BasicAuth::getCurrentUserID(true);
318 * Test the BasicAuth::getCurrentUserID() function with a bad login.
320 * @runInSeparateProcess
321 * @preserveGlobalState disabled
322 * @preserveGlobalState disabled
324 public function testApiLoginWithBadLogin()
326 BasicAuth::setCurrentUserID();
327 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
328 $_SERVER['PHP_AUTH_USER'] = 'user@server';
329 BasicAuth::getCurrentUserID(true);
333 * Test the BasicAuth::getCurrentUserID() function with oAuth.
337 public function testApiLoginWithOauth()
339 $this->markTestIncomplete('Can we test this easily?');
343 * Test the BasicAuth::getCurrentUserID() function with authentication provided by an addon.
347 public function testApiLoginWithAddonAuth()
349 $this->markTestIncomplete('Can we test this easily?');
353 * Test the BasicAuth::getCurrentUserID() function with a correct login.
355 * @runInSeparateProcess
356 * @preserveGlobalState disabled
357 * @doesNotPerformAssertions
359 public function testApiLoginWithCorrectLogin()
361 BasicAuth::setCurrentUserID();
362 $_SERVER['PHP_AUTH_USER'] = 'Test user';
363 $_SERVER['PHP_AUTH_PW'] = 'password';
364 BasicAuth::getCurrentUserID(true);
368 * Test the BasicAuth::getCurrentUserID() function with a remote user.
370 * @runInSeparateProcess
371 * @preserveGlobalState disabled
373 public function testApiLoginWithRemoteUser()
375 BasicAuth::setCurrentUserID();
376 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
377 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
378 BasicAuth::getCurrentUserID(true);
382 * Test the api_call() function.
384 * @runInSeparateProcess
385 * @preserveGlobalState disabled
387 public function testApiCall()
391 'method' => 'method',
392 'func' => function () {
393 return ['data' => ['some_data']];
396 $_SERVER['REQUEST_METHOD'] = 'method';
397 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
398 $_GET['callback'] = 'callback_name';
401 'callback_name(["some_data"])',
402 api_call('api_path', 'json')
407 * Test the api_call() function with the profiled enabled.
409 * @runInSeparateProcess
410 * @preserveGlobalState disabled
412 public function testApiCallWithProfiler()
416 'method' => 'method',
417 'func' => function () {
418 return ['data' => ['some_data']];
422 $_SERVER['REQUEST_METHOD'] = 'method';
423 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
425 $this->config->set('system', 'profiler', true);
426 $this->config->set('rendertime', 'callstack', true);
427 $this->app->callstack = [
428 'database' => ['some_function' => 200],
429 'database_write' => ['some_function' => 200],
430 'cache' => ['some_function' => 200],
431 'cache_write' => ['some_function' => 200],
432 'network' => ['some_function' => 200]
437 api_call('api_path', 'json')
442 * Test the api_call() function with a JSON result.
444 * @runInSeparateProcess
445 * @preserveGlobalState disabled
447 public function testApiCallWithJson()
451 'method' => 'method',
452 'func' => function () {
453 return ['data' => ['some_data']];
456 $_SERVER['REQUEST_METHOD'] = 'method';
457 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
461 api_call('api_path.json', 'json')
466 * Test the api_call() function with an XML result.
468 * @runInSeparateProcess
469 * @preserveGlobalState disabled
471 public function testApiCallWithXml()
475 'method' => 'method',
476 'func' => function () {
480 $_SERVER['REQUEST_METHOD'] = 'method';
481 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
483 $args = DI::args()->determine($_SERVER, $_GET);
487 api_call('api_path.xml', 'xml')
492 * Test the api_call() function with an RSS result.
494 * @runInSeparateProcess
495 * @preserveGlobalState disabled
497 public function testApiCallWithRss()
501 'method' => 'method',
502 'func' => function () {
506 $_SERVER['REQUEST_METHOD'] = 'method';
507 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
510 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
512 api_call('api_path.rss', 'rss')
517 * Test the api_call() function with an Atom result.
519 * @runInSeparateProcess
520 * @preserveGlobalState disabled
522 public function testApiCallWithAtom()
526 'method' => 'method',
527 'func' => function () {
531 $_SERVER['REQUEST_METHOD'] = 'method';
532 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
535 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
537 api_call('api_path.atom', 'atom')
542 * Test the api_rss_extra() function.
546 public function testApiRssExtra()
549 $user_info = ['url' => 'user_url', 'lang' => 'en'];
550 $result = api_rss_extra([], $user_info);
551 self::assertEquals($user_info, $result['$user']);
552 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
553 self::assertArrayHasKey('self', $result['$rss']);
554 self::assertArrayHasKey('base', $result['$rss']);
555 self::assertArrayHasKey('updated', $result['$rss']);
556 self::assertArrayHasKey('atom_updated', $result['$rss']);
557 self::assertArrayHasKey('language', $result['$rss']);
558 self::assertArrayHasKey('logo', $result['$rss']);
563 * Test the api_rss_extra() function without any user info.
567 public function testApiRssExtraWithoutUserInfo()
570 $result = api_rss_extra([], null);
571 self::assertIsArray($result['$user']);
572 self::assertArrayHasKey('alternate', $result['$rss']);
573 self::assertArrayHasKey('self', $result['$rss']);
574 self::assertArrayHasKey('base', $result['$rss']);
575 self::assertArrayHasKey('updated', $result['$rss']);
576 self::assertArrayHasKey('atom_updated', $result['$rss']);
577 self::assertArrayHasKey('language', $result['$rss']);
578 self::assertArrayHasKey('logo', $result['$rss']);
583 * Test the api_get_user() function.
587 public function testApiGetUser()
589 // $user = api_get_user();
590 // self::assertSelfUser($user);
591 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
592 // self::assertEquals('6fdbe8', $user['profile_link_color']);
593 // self::assertEquals('ededed', $user['profile_background_color']);
597 * Test the api_get_user() function with a Frio schema.
601 public function testApiGetUserWithFrioSchema()
603 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
604 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
605 // $user = api_get_user();
606 // self::assertSelfUser($user);
607 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
608 // self::assertEquals('6fdbe8', $user['profile_link_color']);
609 // self::assertEquals('ededed', $user['profile_background_color']);
613 * Test the api_get_user() function with an empty Frio schema.
617 public function testApiGetUserWithEmptyFrioSchema()
619 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
620 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
621 // $user = api_get_user();
622 // self::assertSelfUser($user);
623 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
624 // self::assertEquals('6fdbe8', $user['profile_link_color']);
625 // self::assertEquals('ededed', $user['profile_background_color']);
629 * Test the api_get_user() function with a custom Frio schema.
633 public function testApiGetUserWithCustomFrioSchema()
635 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
636 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
637 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
638 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
639 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
640 // $user = api_get_user();
641 // self::assertSelfUser($user);
642 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
643 // self::assertEquals('123456', $user['profile_link_color']);
644 // self::assertEquals('123456', $user['profile_background_color']);
648 * Test the api_get_user() function with an user that is not allowed to use the API.
650 * @runInSeparateProcess
651 * @preserveGlobalState disabled
653 public function testApiGetUserWithoutApiUser()
655 // api_get_user() with empty parameters is not used anymore
657 $_SERVER['PHP_AUTH_USER'] = 'Test user';
658 $_SERVER['PHP_AUTH_PW'] = 'password';
659 BasicAuth::setCurrentUserID();
660 self::assertFalse(api_get_user());
665 * Test the api_get_user() function with an user ID in a GET parameter.
669 public function testApiGetUserWithGetId()
671 // self::assertOtherUser(api_get_user());
675 * Test the api_get_user() function with a wrong user ID in a GET parameter.
679 public function testApiGetUserWithWrongGetId()
681 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
682 // self::assertOtherUser(api_get_user());
686 * Test the api_get_user() function with an user name in a GET parameter.
690 public function testApiGetUserWithGetName()
692 // self::assertSelfUser(api_get_user());
696 * Test the api_get_user() function with a profile URL in a GET parameter.
700 public function testApiGetUserWithGetUrl()
702 // self::assertSelfUser(api_get_user());
706 * Test the api_get_user() function with an user ID in the API path.
710 public function testApiGetUserWithNumericCalledApi()
712 // global $called_api;
713 // $called_api = ['api_path'];
714 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
715 // self::assertOtherUser(api_get_user());
719 * Test the api_get_user() function with the $called_api global variable.
723 public function testApiGetUserWithCalledApi()
725 // global $called_api;
726 // $called_api = ['api', 'api_path'];
727 // self::assertSelfUser(api_get_user());
731 * Test the Arrays::walkRecursive() function.
735 public function testApiWalkRecursive()
740 Arrays::walkRecursive(
743 // Should we test this with a callback that actually does something?
751 * Test the Arrays::walkRecursive() function with an array.
755 public function testApiWalkRecursiveWithArray()
757 $array = [['item1'], ['item2']];
760 Arrays::walkRecursive(
763 // Should we test this with a callback that actually does something?
771 * Test the BaseApi::reformatXML() function.
775 public function testApiReformatXml()
779 self::assertTrue(ApiResponse::reformatXML($item, $key));
780 self::assertEquals('true', $item);
784 * Test the BaseApi::reformatXML() function with a statusnet_api key.
788 public function testApiReformatXmlWithStatusnetKey()
791 $key = 'statusnet_api';
792 self::assertTrue(ApiResponse::reformatXML($item, $key));
793 self::assertEquals('statusnet:api', $key);
797 * Test the BaseApi::reformatXML() function with a friendica_api key.
801 public function testApiReformatXmlWithFriendicaKey()
804 $key = 'friendica_api';
805 self::assertTrue(ApiResponse::reformatXML($item, $key));
806 self::assertEquals('friendica:api', $key);
810 * Test the BaseApi::createXML() function.
814 public function testApiCreateXml()
817 '<?xml version="1.0"?>' . "\n" .
818 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
819 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
820 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
821 ' <data>some_data</data>' . "\n" .
822 '</root_element>' . "\n",
823 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
828 * Test the BaseApi::createXML() function without any XML namespace.
832 public function testApiCreateXmlWithoutNamespaces()
835 '<?xml version="1.0"?>' . "\n" .
837 ' <data>some_data</data>' . "\n" .
839 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
844 * Test the BaseApi::formatData() function.
848 public function testApiFormatData()
850 $data = ['some_data'];
851 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
855 * Test the BaseApi::formatData() function with an XML result.
859 public function testApiFormatDataWithXml()
862 '<?xml version="1.0"?>' . "\n" .
863 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
864 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
865 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
866 ' <data>some_data</data>' . "\n" .
867 '</root_element>' . "\n",
868 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
873 * Test the api_statuses_mediap() function.
877 public function testApiStatusesMediap()
880 DI::args()->setArgc(2);
888 'tmp_name' => $this->getTempImage(),
889 'name' => 'spacer.png',
890 'type' => 'image/png'
893 $_GET['status'] = '<b>Status content</b>';
895 $result = api_statuses_mediap('json');
896 self::assertStatus($result['status']);
901 * Test the api_statuses_mediap() function without an authenticated user.
905 public function testApiStatusesMediapWithoutAuthenticatedUser()
907 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
908 // BasicAuth::setCurrentUserID();
909 // $_SESSION['authenticated'] = false;
910 // api_statuses_mediap('json');
914 * Test the api_statuses_update() function.
918 public function testApiStatusesUpdate()
921 $_REQUEST['status'] = 'Status content #friendica';
922 $_REQUEST['in_reply_to_status_id'] = -1;
923 $_REQUEST['lat'] = 48;
924 $_REQUEST['long'] = 7;
931 'tmp_name' => $this->getTempImage(),
932 'name' => 'spacer.png',
933 'type' => 'image/png'
937 $result = api_statuses_update('json');
938 self::assertStatus($result['status']);
943 * Test the api_statuses_update() function with an HTML status.
947 public function testApiStatusesUpdateWithHtml()
950 $_REQUEST['htmlstatus'] = '<b>Status content</b>';
952 $result = api_statuses_update('json');
953 self::assertStatus($result['status']);
958 * Test the api_statuses_update() function without an authenticated user.
962 public function testApiStatusesUpdateWithoutAuthenticatedUser()
965 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
966 BasicAuth::setCurrentUserID();
967 $_SESSION['authenticated'] = false;
968 api_statuses_update('json');
973 * Test the api_statuses_update() function with a parent status.
977 public function testApiStatusesUpdateWithParent()
979 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
983 * Test the api_statuses_update() function with a media_ids parameter.
987 public function testApiStatusesUpdateWithMediaIds()
989 $this->markTestIncomplete();
993 * Test the api_statuses_update() function with the throttle limit reached.
997 public function testApiStatusesUpdateWithDayThrottleReached()
999 $this->markTestIncomplete();
1003 * Test the \Friendica\Module\Api\Twitter\Media\Upload module.
1004 * @runInSeparateProcess
1005 * @preserveGlobalState disabled
1007 public function testApiMediaUpload()
1009 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1010 (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
1014 * Test the \Friendica\Module\Api\Twitter\Media\Upload module without an authenticated user.
1018 public function testApiMediaUploadWithoutAuthenticatedUser()
1020 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1021 BasicAuth::setCurrentUserID();
1022 $_SESSION['authenticated'] = false;
1023 (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
1027 * Test the \Friendica\Module\Api\Twitter\Media\Upload module with an invalid uploaded media.
1031 public function testApiMediaUploadWithMedia()
1033 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1037 'tmp_name' => 'tmp_name'
1040 (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
1044 * Test the \Friendica\Module\Api\Twitter\Media\Upload module with an valid uploaded media.
1048 public function testApiMediaUploadWithValidMedia()
1056 'tmp_name' => $this->getTempImage(),
1057 'name' => 'spacer.png',
1058 'type' => 'image/png'
1062 $response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
1063 $media = json_decode($response->getBody(), true);
1065 self::assertEquals('image/png', $media['image']['image_type']);
1066 self::assertEquals(1, $media['image']['w']);
1067 self::assertEquals(1, $media['image']['h']);
1068 self::assertNotEmpty($media['image']['friendica_preview_url']);
1072 * Test the api_statuses_repeat() function.
1076 public function testApiStatusesRepeat()
1078 // $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1079 // api_statuses_repeat('json');
1083 * Test the api_statuses_repeat() function without an authenticated user.
1087 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1089 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1090 // BasicAuth::setCurrentUserID();
1091 // $_SESSION['authenticated'] = false;
1092 // api_statuses_repeat('json');
1096 * Test the api_statuses_repeat() function with an ID.
1100 public function testApiStatusesRepeatWithId()
1102 // DI::args()->setArgv(['', '', '', 1]);
1103 // $result = api_statuses_repeat('json');
1104 // self::assertStatus($result['status']);
1106 // Also test with a shared status
1107 // DI::args()->setArgv(['', '', '', 5]);
1108 // $result = api_statuses_repeat('json');
1109 // self::assertStatus($result['status']);
1113 * Test the api_favorites_create_destroy() function.
1117 public function testApiFavoritesCreateDestroy()
1119 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1120 // DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1121 // api_favorites_create_destroy('json');
1125 * Test the api_favorites_create_destroy() function with an invalid ID.
1129 public function testApiFavoritesCreateDestroyWithInvalidId()
1131 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1132 // DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1133 // api_favorites_create_destroy('json');
1137 * Test the api_favorites_create_destroy() function with an invalid action.
1141 public function testApiFavoritesCreateDestroyWithInvalidAction()
1143 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1144 // DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1145 // $_REQUEST['id'] = 1;
1146 // api_favorites_create_destroy('json');
1150 * Test the api_favorites_create_destroy() function with the create action.
1154 public function testApiFavoritesCreateDestroyWithCreateAction()
1156 // DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1157 // $_REQUEST['id'] = 3;
1158 // $result = api_favorites_create_destroy('json');
1159 // self::assertStatus($result['status']);
1163 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1167 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1169 // DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1170 // $_REQUEST['id'] = 3;
1171 // $result = api_favorites_create_destroy('rss');
1172 // self::assertXml($result, 'status');
1176 * Test the api_favorites_create_destroy() function with the destroy action.
1180 public function testApiFavoritesCreateDestroyWithDestroyAction()
1182 // DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1183 // $_REQUEST['id'] = 3;
1184 // $result = api_favorites_create_destroy('json');
1185 // self::assertStatus($result['status']);
1189 * Test the api_favorites_create_destroy() function without an authenticated user.
1193 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1196 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1197 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1198 BasicAuth::setCurrentUserID();
1199 $_SESSION['authenticated'] = false;
1200 api_favorites_create_destroy('json');
1207 * Test the api_format_messages() function.
1211 public function testApiFormatMessages()
1213 $result = api_format_messages(
1214 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1215 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1216 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1218 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1219 self::assertEquals(1, $result['id']);
1220 self::assertEquals(2, $result['recipient_id']);
1221 self::assertEquals(3, $result['sender_id']);
1222 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1223 self::assertEquals('sender_name', $result['sender_screen_name']);
1227 * Test the api_format_messages() function with HTML.
1231 public function testApiFormatMessagesWithHtmlText()
1233 $_GET['getText'] = 'html';
1234 $result = api_format_messages(
1235 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1236 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1237 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1239 self::assertEquals('item_title', $result['title']);
1240 self::assertEquals('<strong>item_body</strong>', $result['text']);
1244 * Test the api_format_messages() function with plain text.
1248 public function testApiFormatMessagesWithPlainText()
1250 $_GET['getText'] = 'plain';
1251 $result = api_format_messages(
1252 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1253 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1254 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1256 self::assertEquals('item_title', $result['title']);
1257 self::assertEquals('item_body', $result['text']);
1261 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1265 public function testApiFormatMessagesWithoutUserObjects()
1267 $_GET['getUserObjects'] = 'false';
1268 $result = api_format_messages(
1269 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1270 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1271 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1273 self::assertTrue(!isset($result['sender']));
1274 self::assertTrue(!isset($result['recipient']));
1278 * Test the api_convert_item() function.
1282 public function testApiConvertItem()
1285 $result = api_convert_item(
1287 'network' => 'feed',
1288 'title' => 'item_title',
1290 // We need a long string to test that it is correctly cut
1291 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
1292 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
1293 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
1294 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
1295 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
1296 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
1297 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
1298 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
1299 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
1300 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
1301 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
1302 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
1303 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
1304 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
1305 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
1306 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
1307 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
1308 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
1309 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
1310 'repellat officia illum quos impedit quam iste esse unde qui ' .
1311 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
1312 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
1313 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
1314 'plink' => 'item_plink'
1317 self::assertStringStartsWith('item_title', $result['text']);
1318 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
1323 * Test the api_convert_item() function with an empty item body.
1327 public function testApiConvertItemWithoutBody()
1330 $result = api_convert_item(
1332 'network' => 'feed',
1333 'title' => 'item_title',
1336 'plink' => 'item_plink'
1339 self::assertEquals("item_title", $result['text']);
1340 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
1345 * Test the api_convert_item() function with the title in the body.
1349 public function testApiConvertItemWithTitleInBody()
1352 $result = api_convert_item(
1354 'title' => 'item_title',
1355 'body' => 'item_title item_body',
1359 self::assertEquals('item_title item_body', $result['text']);
1360 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
1365 * Test the api_get_attachments() function.
1369 public function testApiGetAttachments()
1372 // self::assertEmpty(api_get_attachments($body, 0));
1376 * Test the api_get_attachments() function with an img tag.
1380 public function testApiGetAttachmentsWithImage()
1382 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
1383 // self::assertIsArray(api_get_attachments($body, 0));
1387 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
1391 public function testApiGetAttachmentsWithImageAndAndStatus()
1393 // $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
1394 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
1395 // self::assertIsArray(api_get_attachments($body, 0));
1399 * Test the api_get_entitities() function.
1403 public function testApiGetEntitities()
1406 // self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
1410 * Test the api_get_entitities() function with the include_entities parameter.
1414 public function testApiGetEntititiesWithIncludeEntities()
1417 $_REQUEST['include_entities'] = 'true';
1419 $result = api_get_entitities($text, 'bbcode', 0);
1420 self::assertIsArray($result['hashtags']);
1421 self::assertIsArray($result['symbols']);
1422 self::assertIsArray($result['urls']);
1423 self::assertIsArray($result['user_mentions']);
1428 * Test the api_format_items_embeded_images() function.
1432 public function testApiFormatItemsEmbededImages()
1436 'text ' . DI::baseUrl() . '/display/item_guid',
1437 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
1443 * Test the api_format_items_activities() function.
1447 public function testApiFormatItemsActivities()
1449 $item = ['uid' => 0, 'uri-id' => 1];
1450 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid']);
1451 self::assertArrayHasKey('like', $result);
1452 self::assertArrayHasKey('dislike', $result);
1453 self::assertArrayHasKey('attendyes', $result);
1454 self::assertArrayHasKey('attendno', $result);
1455 self::assertArrayHasKey('attendmaybe', $result);
1459 * Test the api_format_items_activities() function with an XML result.
1463 public function testApiFormatItemsActivitiesWithXml()
1465 $item = ['uid' => 0, 'uri-id' => 1];
1466 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid'], 'xml');
1467 self::assertArrayHasKey('friendica:like', $result);
1468 self::assertArrayHasKey('friendica:dislike', $result);
1469 self::assertArrayHasKey('friendica:attendyes', $result);
1470 self::assertArrayHasKey('friendica:attendno', $result);
1471 self::assertArrayHasKey('friendica:attendmaybe', $result);
1475 * Test the api_format_items() function.
1476 * @doesNotPerformAssertions
1478 public function testApiFormatItems()
1481 $items = Post::selectToArray([], ['uid' => 42]);
1482 foreach ($items as $item) {
1483 $status = api_format_item($item);
1484 self::assertStatus($status);
1490 * Test the api_format_items() function with an XML result.
1491 * @doesNotPerformAssertions
1493 public function testApiFormatItemsWithXml()
1496 $items = Post::selectToArray([], ['uid' => 42]);
1497 foreach ($items as $item) {
1498 $status = api_format_item($item, 'xml');
1499 self::assertStatus($status);
1505 * Test the api_lists_list() function.
1509 public function testApiListsList()
1511 $result = api_lists_list('json');
1512 self::assertEquals(['lists_list' => []], $result);
1516 * Test the api_lists_ownerships() function.
1520 public function testApiListsOwnerships()
1522 $result = api_lists_ownerships('json');
1523 foreach ($result['lists']['lists'] as $list) {
1524 self::assertList($list);
1529 * Test the api_lists_ownerships() function without an authenticated user.
1533 public function testApiListsOwnershipsWithoutAuthenticatedUser()
1535 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1536 BasicAuth::setCurrentUserID();
1537 $_SESSION['authenticated'] = false;
1538 api_lists_ownerships('json');
1542 * Test the api_statuses_f() function.
1546 public function testApiStatusesFWithIncoming()
1548 // $result = api_statuses_f('incoming');
1549 // self::assertArrayHasKey('user', $result);
1554 * Test the api_direct_messages_new() function.
1558 public function testApiDirectMessagesNew()
1560 $result = api_direct_messages_new('json');
1561 self::assertNull($result);
1565 * Test the api_direct_messages_new() function without an authenticated user.
1569 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
1571 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1572 BasicAuth::setCurrentUserID();
1573 $_SESSION['authenticated'] = false;
1574 api_direct_messages_new('json');
1578 * Test the api_direct_messages_new() function with an user ID.
1582 public function testApiDirectMessagesNewWithUserId()
1584 $_POST['text'] = 'message_text';
1585 $_REQUEST['user_id'] = $this->otherUser['id'];
1586 $result = api_direct_messages_new('json');
1587 self::assertEquals(['direct_message' => ['error' => -1]], $result);
1591 * Test the api_direct_messages_new() function with a screen name.
1595 public function testApiDirectMessagesNewWithScreenName()
1597 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1598 $_POST['text'] = 'message_text';
1599 $_REQUEST['user_id'] = $this->friendUser['id'];
1600 $result = api_direct_messages_new('json');
1601 self::assertStringContainsString('message_text', $result['direct_message']['text']);
1602 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
1603 self::assertEquals(1, $result['direct_message']['friendica_seen']);
1607 * Test the api_direct_messages_new() function with a title.
1611 public function testApiDirectMessagesNewWithTitle()
1613 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1614 $_POST['text'] = 'message_text';
1615 $_REQUEST['user_id'] = $this->friendUser['id'];
1616 $_REQUEST['title'] = 'message_title';
1617 $result = api_direct_messages_new('json');
1618 self::assertStringContainsString('message_text', $result['direct_message']['text']);
1619 self::assertStringContainsString('message_title', $result['direct_message']['text']);
1620 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
1621 self::assertEquals(1, $result['direct_message']['friendica_seen']);
1625 * Test the api_direct_messages_new() function with an RSS result.
1629 public function testApiDirectMessagesNewWithRss()
1631 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1632 $_POST['text'] = 'message_text';
1633 $_REQUEST['user_id'] = $this->friendUser['id'];
1634 $result = api_direct_messages_new('rss');
1635 self::assertXml($result, 'direct-messages');
1639 * Test the api_direct_messages_destroy() function.
1643 public function testApiDirectMessagesDestroy()
1645 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1646 api_direct_messages_destroy('json');
1650 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
1654 public function testApiDirectMessagesDestroyWithVerbose()
1656 $_GET['friendica_verbose'] = 'true';
1657 $result = api_direct_messages_destroy('json');
1661 'result' => 'error',
1662 'message' => 'message id or parenturi not specified'
1670 * Test the api_direct_messages_destroy() function without an authenticated user.
1674 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
1676 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1677 BasicAuth::setCurrentUserID();
1678 $_SESSION['authenticated'] = false;
1679 api_direct_messages_destroy('json');
1683 * Test the api_direct_messages_destroy() function with a non-zero ID.
1687 public function testApiDirectMessagesDestroyWithId()
1689 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1690 $_REQUEST['id'] = 1;
1691 api_direct_messages_destroy('json');
1695 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
1699 public function testApiDirectMessagesDestroyWithIdAndVerbose()
1701 $_REQUEST['id'] = 1;
1702 $_REQUEST['friendica_parenturi'] = 'parent_uri';
1703 $_GET['friendica_verbose'] = 'true';
1704 $result = api_direct_messages_destroy('json');
1708 'result' => 'error',
1709 'message' => 'message id not in database'
1717 * Test the api_direct_messages_destroy() function with a non-zero ID.
1721 public function testApiDirectMessagesDestroyWithCorrectId()
1723 $this->markTestIncomplete('We need to add a dataset for this.');
1727 * Test the api_direct_messages_box() function.
1731 public function testApiDirectMessagesBoxWithSentbox()
1733 $_REQUEST['page'] = -1;
1734 $_REQUEST['max_id'] = 10;
1735 $result = api_direct_messages_box('json', 'sentbox', 'false');
1736 self::assertArrayHasKey('direct_message', $result);
1740 * Test the api_direct_messages_box() function.
1744 public function testApiDirectMessagesBoxWithConversation()
1746 $result = api_direct_messages_box('json', 'conversation', 'false');
1747 self::assertArrayHasKey('direct_message', $result);
1751 * Test the api_direct_messages_box() function.
1755 public function testApiDirectMessagesBoxWithAll()
1757 $result = api_direct_messages_box('json', 'all', 'false');
1758 self::assertArrayHasKey('direct_message', $result);
1762 * Test the api_direct_messages_box() function.
1766 public function testApiDirectMessagesBoxWithInbox()
1768 $result = api_direct_messages_box('json', 'inbox', 'false');
1769 self::assertArrayHasKey('direct_message', $result);
1773 * Test the api_direct_messages_box() function.
1777 public function testApiDirectMessagesBoxWithVerbose()
1779 $result = api_direct_messages_box('json', 'sentbox', 'true');
1783 'result' => 'error',
1784 'message' => 'no mails available'
1792 * Test the api_direct_messages_box() function with a RSS result.
1796 public function testApiDirectMessagesBoxWithRss()
1798 $result = api_direct_messages_box('rss', 'sentbox', 'false');
1799 self::assertXml($result, 'direct-messages');
1803 * Test the api_direct_messages_box() function without an authenticated user.
1807 public function testApiDirectMessagesBoxWithUnallowedUser()
1809 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1810 BasicAuth::setCurrentUserID();
1811 api_direct_messages_box('json', 'sentbox', 'false');
1815 * Test the api_direct_messages_sentbox() function.
1819 public function testApiDirectMessagesSentbox()
1821 $result = api_direct_messages_sentbox('json');
1822 self::assertArrayHasKey('direct_message', $result);
1826 * Test the api_direct_messages_inbox() function.
1830 public function testApiDirectMessagesInbox()
1832 $result = api_direct_messages_inbox('json');
1833 self::assertArrayHasKey('direct_message', $result);
1837 * Test the api_direct_messages_all() function.
1841 public function testApiDirectMessagesAll()
1843 $result = api_direct_messages_all('json');
1844 self::assertArrayHasKey('direct_message', $result);
1848 * Test the api_direct_messages_conversation() function.
1852 public function testApiDirectMessagesConversation()
1854 $result = api_direct_messages_conversation('json');
1855 self::assertArrayHasKey('direct_message', $result);
1859 * Test the api_oauth_request_token() function.
1863 public function testApiOauthRequestToken()
1865 $this->markTestIncomplete('exit() kills phpunit as well');
1869 * Test the api_oauth_access_token() function.
1873 public function testApiOauthAccessToken()
1875 $this->markTestIncomplete('exit() kills phpunit as well');
1879 * Test the api_fr_photos_list() function.
1883 public function testApiFrPhotosList()
1885 $result = api_fr_photos_list('json');
1886 self::assertArrayHasKey('photo', $result);
1890 * Test the api_fr_photos_list() function without an authenticated user.
1894 public function testApiFrPhotosListWithoutAuthenticatedUser()
1896 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1897 BasicAuth::setCurrentUserID();
1898 $_SESSION['authenticated'] = false;
1899 api_fr_photos_list('json');
1903 * Test the api_fr_photo_create_update() function.
1905 public function testApiFrPhotoCreateUpdate()
1907 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1908 api_fr_photo_create_update('json');
1912 * Test the api_fr_photo_create_update() function without an authenticated user.
1916 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
1918 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1919 BasicAuth::setCurrentUserID();
1920 $_SESSION['authenticated'] = false;
1921 api_fr_photo_create_update('json');
1925 * Test the api_fr_photo_create_update() function with an album name.
1929 public function testApiFrPhotoCreateUpdateWithAlbum()
1931 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1932 $_REQUEST['album'] = 'album_name';
1933 api_fr_photo_create_update('json');
1937 * Test the api_fr_photo_create_update() function with the update mode.
1941 public function testApiFrPhotoCreateUpdateWithUpdate()
1943 $this->markTestIncomplete('We need to create a dataset for this');
1947 * Test the api_fr_photo_create_update() function with an uploaded file.
1951 public function testApiFrPhotoCreateUpdateWithFile()
1953 $this->markTestIncomplete();
1957 * Test the api_fr_photo_detail() function.
1961 public function testApiFrPhotoDetail()
1963 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1964 api_fr_photo_detail('json');
1968 * Test the api_fr_photo_detail() function without an authenticated user.
1972 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
1974 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1975 BasicAuth::setCurrentUserID();
1976 $_SESSION['authenticated'] = false;
1977 api_fr_photo_detail('json');
1981 * Test the api_fr_photo_detail() function with a photo ID.
1985 public function testApiFrPhotoDetailWithPhotoId()
1987 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1988 $_REQUEST['photo_id'] = 1;
1989 api_fr_photo_detail('json');
1993 * Test the api_fr_photo_detail() function with a correct photo ID.
1997 public function testApiFrPhotoDetailCorrectPhotoId()
1999 $this->markTestIncomplete('We need to create a dataset for this.');
2003 * Test the api_account_update_profile_image() function.
2007 public function testApiAccountUpdateProfileImage()
2009 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2010 api_account_update_profile_image('json');
2014 * Test the api_account_update_profile_image() function without an authenticated user.
2018 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
2020 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2021 BasicAuth::setCurrentUserID();
2022 $_SESSION['authenticated'] = false;
2023 api_account_update_profile_image('json');
2027 * Test the api_account_update_profile_image() function with an uploaded file.
2031 public function testApiAccountUpdateProfileImageWithUpload()
2033 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2034 $this->markTestIncomplete();
2038 * Test the check_acl_input() function.
2042 public function testCheckAclInput()
2044 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
2045 // Where does this result come from?
2046 self::assertEquals(1, $result);
2050 * Test the check_acl_input() function with an empty ACL string.
2054 public function testCheckAclInputWithEmptyAclString()
2056 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
2057 self::assertFalse($result);
2061 * Test the save_media_to_database() function.
2065 public function testSaveMediaToDatabase()
2067 $this->markTestIncomplete();
2071 * Test the post_photo_item() function.
2075 public function testPostPhotoItem()
2077 $this->markTestIncomplete();
2081 * Test the prepare_photo_data() function.
2085 public function testPreparePhotoData()
2087 $this->markTestIncomplete();
2091 * Test the api_share_as_retweet() function with a valid item.
2095 public function testApiShareAsRetweetWithValidItem()
2097 $this->markTestIncomplete();
2101 * Test the api_in_reply_to() function with a valid item.
2105 public function testApiInReplyToWithValidItem()
2107 $this->markTestIncomplete();
2111 * Test the api_clean_plain_items() function.
2115 public function testApiCleanPlainItems()
2117 $_REQUEST['include_entities'] = 'true';
2118 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
2119 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
2123 * Test the api_best_nickname() function with contacts.
2127 public function testApiBestNicknameWithContacts()
2129 $this->markTestIncomplete();
2133 * Test the api_friendica_group_show() function.
2137 public function testApiFriendicaGroupShow()
2139 $this->markTestIncomplete();
2143 * Test the api_friendica_group_delete() function.
2147 public function testApiFriendicaGroupDelete()
2149 $this->markTestIncomplete();
2153 * Test the api_lists_destroy() function.
2157 public function testApiListsDestroy()
2159 $this->markTestIncomplete();
2163 * Test the group_create() function.
2167 public function testGroupCreate()
2169 $this->markTestIncomplete();
2173 * Test the api_friendica_group_create() function.
2177 public function testApiFriendicaGroupCreate()
2179 $this->markTestIncomplete();
2183 * Test the api_lists_create() function.
2187 public function testApiListsCreate()
2189 $this->markTestIncomplete();
2193 * Test the api_friendica_group_update() function.
2197 public function testApiFriendicaGroupUpdate()
2199 $this->markTestIncomplete();
2203 * Test the api_lists_update() function.
2207 public function testApiListsUpdate()
2209 $this->markTestIncomplete();
2213 * Test the api_friendica_activity() function.
2217 public function testApiFriendicaActivity()
2219 $this->markTestIncomplete();
2223 * Test the api_friendica_notification_seen() function.
2227 public function testApiFriendicaNotificationSeen()
2229 $this->markTestIncomplete();
2233 * Test the api_friendica_direct_messages_setseen() function.
2237 public function testApiFriendicaDirectMessagesSetseen()
2239 $this->markTestIncomplete();
2243 * Test the api_friendica_direct_messages_search() function.
2247 public function testApiFriendicaDirectMessagesSearch()
2249 $this->markTestIncomplete();