6 namespace Friendica\Test\legacy;
9 use Friendica\Core\Config\Capability\IManageConfigValues;
10 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
11 use Friendica\Core\Protocol;
13 use Friendica\Module\Api\ApiResponse;
14 use Friendica\Module\BaseApi;
15 use Friendica\Network\HTTPException;
16 use Friendica\Security\BasicAuth;
17 use Friendica\Test\FixtureTest;
18 use Friendica\Util\Arrays;
19 use Friendica\Util\DateTimeFormat;
20 use Friendica\Util\Temporal;
21 use Monolog\Handler\TestHandler;
23 require_once __DIR__ . '/../../include/api.php';
26 * Tests for the API functions.
28 * Functions that use header() need to be tested in a separate process.
29 * @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
31 * @backupGlobals enabled
33 class ApiTest extends FixtureTest
36 * @var TestHandler Can handle log-outputs
43 protected $friendUser;
47 protected $wrongUserId;
52 /** @var IManageConfigValues */
56 * Create variables used by tests.
58 protected function setUp() : void
60 global $API, $called_api;
66 /** @var IManageConfigValues $config */
67 $this->config = $this->dice->create(IManageConfigValues::class);
69 $this->config->set('system', 'url', 'http://localhost');
70 $this->config->set('system', 'hostname', 'localhost');
71 $this->config->set('system', 'worker_dont_fork', true);
74 $this->config->set('config', 'hostname', 'localhost');
75 $this->config->set('system', 'throttle_limit_day', 100);
76 $this->config->set('system', 'throttle_limit_week', 100);
77 $this->config->set('system', 'throttle_limit_month', 100);
78 $this->config->set('system', 'theme', 'system_theme');
82 $this->app = DI::app();
84 DI::args()->setArgc(1);
86 // User data that the test database is populated with
89 'name' => 'Self contact',
90 'nick' => 'selfcontact',
91 'nurl' => 'http://localhost/profile/selfcontact'
95 'name' => 'Friend contact',
96 'nick' => 'friendcontact',
97 'nurl' => 'http://localhost/profile/friendcontact'
101 'name' => 'othercontact',
102 'nick' => 'othercontact',
103 'nurl' => 'http://localhost/profile/othercontact'
106 // User ID that we know is not in the database
107 $this->wrongUserId = 666;
109 DI::session()->start();
111 // Most API require login so we force the session
114 'authenticated' => true,
115 'uid' => $this->selfUser['id']
117 BasicAuth::setCurrentUserID($this->selfUser['id']);
121 * Assert that an user array contains expected keys.
123 * @param array $user User array
127 private function assertSelfUser(array $user)
129 self::assertEquals($this->selfUser['id'], $user['uid']);
130 self::assertEquals($this->selfUser['id'], $user['cid']);
131 self::assertEquals(1, $user['self']);
132 self::assertEquals('DFRN', $user['location']);
133 self::assertEquals($this->selfUser['name'], $user['name']);
134 self::assertEquals($this->selfUser['nick'], $user['screen_name']);
135 self::assertEquals('dfrn', $user['network']);
136 self::assertTrue($user['verified']);
140 * Assert that an user array contains expected keys.
142 * @param array $user User array
146 private function assertOtherUser(array $user = [])
148 self::assertEquals($this->otherUser['id'], $user['id']);
149 self::assertEquals($this->otherUser['id'], $user['id_str']);
150 self::assertEquals(0, $user['self']);
151 self::assertEquals($this->otherUser['name'], $user['name']);
152 self::assertEquals($this->otherUser['nick'], $user['screen_name']);
153 self::assertFalse($user['verified']);
157 * Assert that a status array contains expected keys.
159 * @param array $status Status array
163 private function assertStatus(array $status = [])
165 self::assertIsString($status['text'] ?? '');
166 self::assertIsInt($status['id'] ?? '');
167 // We could probably do more checks here.
171 * Assert that a list array contains expected keys.
173 * @param array $list List array
177 private function assertList(array $list = [])
179 self::assertIsString($list['name']);
180 self::assertIsInt($list['id']);
181 self::assertIsString('string', $list['id_str']);
182 self::assertContains($list['mode'], ['public', 'private']);
183 // We could probably do more checks here.
187 * Assert that the string is XML and contain the root element.
189 * @param string $result XML string
190 * @param string $root_element Root element name
194 private function assertXml($result = '', $root_element = '')
196 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
197 self::assertStringContainsString('<' . $root_element, $result);
198 // We could probably do more checks here.
202 * Get the path to a temporary empty PNG image.
204 * @return string Path
206 private function getTempImage()
208 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
212 // Empty 1x1 px PNG image
213 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
221 * Test the api_user() function.
225 public function testApiUser()
227 self::assertEquals($this->selfUser['id'], api_user());
231 * Test the api_user() function with an unallowed user.
235 public function testApiUserWithUnallowedUser()
237 $_SESSION = ['allow_api' => false];
238 self::assertEquals(false, api_user());
242 * Test the api_source() function.
246 public function testApiSource()
248 self::assertEquals('api', api_source());
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', api_source());
263 * Test the api_source() function with a GET parameter.
267 public function testApiSourceWithGet()
269 $_GET['source'] = 'source_name';
270 self::assertEquals('source_name', api_source());
274 * Test the api_date() function.
278 public function testApiDate()
280 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
284 * Test the api_register_func() function.
288 public function testApiRegisterFunc()
300 self::assertTrue($API['api_path']['auth']);
301 self::assertEquals('method', $API['api_path']['method']);
302 self::assertTrue(is_callable($API['api_path']['func']));
306 * Test the BasicAuth::getCurrentUserID() function without any login.
308 * @runInSeparateProcess
309 * @preserveGlobalState disabled
310 * @preserveGlobalState disabled
312 public function testApiLoginWithoutLogin()
314 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
315 BasicAuth::getCurrentUserID(true);
319 * Test the BasicAuth::getCurrentUserID() function with a bad login.
321 * @runInSeparateProcess
322 * @preserveGlobalState disabled
323 * @preserveGlobalState disabled
325 public function testApiLoginWithBadLogin()
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 $_SERVER['PHP_AUTH_USER'] = 'Test user';
362 $_SERVER['PHP_AUTH_PW'] = 'password';
363 BasicAuth::getCurrentUserID(true);
367 * Test the BasicAuth::getCurrentUserID() function with a remote user.
369 * @runInSeparateProcess
370 * @preserveGlobalState disabled
372 public function testApiLoginWithRemoteUser()
374 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
375 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
376 BasicAuth::getCurrentUserID(true);
380 * Test the api_check_method() function.
384 public function testApiCheckMethod()
386 self::assertFalse(api_check_method('method'));
390 * Test the api_check_method() function with a correct method.
394 public function testApiCheckMethodWithCorrectMethod()
396 $_SERVER['REQUEST_METHOD'] = 'method';
397 self::assertTrue(api_check_method('method'));
401 * Test the api_check_method() function with a wildcard.
405 public function testApiCheckMethodWithWildcard()
407 self::assertTrue(api_check_method('*'));
411 * Test the api_call() function.
413 * @runInSeparateProcess
414 * @preserveGlobalState disabled
416 public function testApiCall()
420 'method' => 'method',
421 'func' => function () {
422 return ['data' => ['some_data']];
425 $_SERVER['REQUEST_METHOD'] = 'method';
426 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
427 $_GET['callback'] = 'callback_name';
429 $args = DI::args()->determine($_SERVER, $_GET);
432 'callback_name(["some_data"])',
433 api_call($this->app, $args)
438 * Test the api_call() function with the profiled enabled.
440 * @runInSeparateProcess
441 * @preserveGlobalState disabled
443 public function testApiCallWithProfiler()
447 'method' => 'method',
448 'func' => function () {
449 return ['data' => ['some_data']];
453 $_SERVER['REQUEST_METHOD'] = 'method';
454 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
456 $args = DI::args()->determine($_SERVER, $_GET);
458 $this->config->set('system', 'profiler', true);
459 $this->config->set('rendertime', 'callstack', true);
460 $this->app->callstack = [
461 'database' => ['some_function' => 200],
462 'database_write' => ['some_function' => 200],
463 'cache' => ['some_function' => 200],
464 'cache_write' => ['some_function' => 200],
465 'network' => ['some_function' => 200]
470 api_call($this->app, $args)
475 * Test the api_call() function with a JSON result.
477 * @runInSeparateProcess
478 * @preserveGlobalState disabled
480 public function testApiCallWithJson()
484 'method' => 'method',
485 'func' => function () {
486 return ['data' => ['some_data']];
489 $_SERVER['REQUEST_METHOD'] = 'method';
490 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
492 $args = DI::args()->determine($_SERVER, $_GET);
496 api_call($this->app, $args)
501 * Test the api_call() function with an XML result.
503 * @runInSeparateProcess
504 * @preserveGlobalState disabled
506 public function testApiCallWithXml()
510 'method' => 'method',
511 'func' => function () {
515 $_SERVER['REQUEST_METHOD'] = 'method';
516 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
518 $args = DI::args()->determine($_SERVER, $_GET);
522 api_call($this->app, $args)
527 * Test the api_call() function with an RSS result.
529 * @runInSeparateProcess
530 * @preserveGlobalState disabled
532 public function testApiCallWithRss()
536 'method' => 'method',
537 'func' => function () {
541 $_SERVER['REQUEST_METHOD'] = 'method';
542 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
544 $args = DI::args()->determine($_SERVER, $_GET);
547 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
549 api_call($this->app, $args)
554 * Test the api_call() function with an Atom result.
556 * @runInSeparateProcess
557 * @preserveGlobalState disabled
559 public function testApiCallWithAtom()
563 'method' => 'method',
564 'func' => function () {
568 $_SERVER['REQUEST_METHOD'] = 'method';
569 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
571 $args = DI::args()->determine($_SERVER, $_GET);
574 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
576 api_call($this->app, $args)
581 * Test the api_rss_extra() function.
585 public function testApiRssExtra()
587 $user_info = ['url' => 'user_url', 'lang' => 'en'];
588 $result = api_rss_extra([], $user_info);
589 self::assertEquals($user_info, $result['$user']);
590 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
591 self::assertArrayHasKey('self', $result['$rss']);
592 self::assertArrayHasKey('base', $result['$rss']);
593 self::assertArrayHasKey('updated', $result['$rss']);
594 self::assertArrayHasKey('atom_updated', $result['$rss']);
595 self::assertArrayHasKey('language', $result['$rss']);
596 self::assertArrayHasKey('logo', $result['$rss']);
600 * Test the api_rss_extra() function without any user info.
604 public function testApiRssExtraWithoutUserInfo()
606 $result = api_rss_extra([], null);
607 self::assertIsArray($result['$user']);
608 self::assertArrayHasKey('alternate', $result['$rss']);
609 self::assertArrayHasKey('self', $result['$rss']);
610 self::assertArrayHasKey('base', $result['$rss']);
611 self::assertArrayHasKey('updated', $result['$rss']);
612 self::assertArrayHasKey('atom_updated', $result['$rss']);
613 self::assertArrayHasKey('language', $result['$rss']);
614 self::assertArrayHasKey('logo', $result['$rss']);
618 * Test the api_unique_id_to_nurl() function.
622 public function testApiUniqueIdToNurl()
624 self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
628 * Test the api_unique_id_to_nurl() function with a correct ID.
632 public function testApiUniqueIdToNurlWithCorrectId()
634 self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
638 * Test the api_get_user() function.
642 public function testApiGetUser()
644 $user = api_get_user();
645 self::assertSelfUser($user);
646 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
647 // self::assertEquals('6fdbe8', $user['profile_link_color']);
648 // self::assertEquals('ededed', $user['profile_background_color']);
652 * Test the api_get_user() function with a Frio schema.
656 public function testApiGetUserWithFrioSchema()
658 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
659 $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
660 $user = api_get_user();
661 self::assertSelfUser($user);
662 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
663 // self::assertEquals('6fdbe8', $user['profile_link_color']);
664 // self::assertEquals('ededed', $user['profile_background_color']);
668 * Test the api_get_user() function with an empty Frio schema.
672 public function testApiGetUserWithEmptyFrioSchema()
674 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
675 $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
676 $user = api_get_user();
677 self::assertSelfUser($user);
678 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
679 // self::assertEquals('6fdbe8', $user['profile_link_color']);
680 // self::assertEquals('ededed', $user['profile_background_color']);
684 * Test the api_get_user() function with a custom Frio schema.
688 public function testApiGetUserWithCustomFrioSchema()
690 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
691 $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
692 $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
693 $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
694 $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
695 $user = api_get_user();
696 self::assertSelfUser($user);
697 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
698 // self::assertEquals('123456', $user['profile_link_color']);
699 // self::assertEquals('123456', $user['profile_background_color']);
703 * Test the api_get_user() function with an user that is not allowed to use the API.
705 * @runInSeparateProcess
706 * @preserveGlobalState disabled
708 public function testApiGetUserWithoutApiUser()
710 $_SERVER['PHP_AUTH_USER'] = 'Test user';
711 $_SERVER['PHP_AUTH_PW'] = 'password';
712 $_SESSION['allow_api'] = false;
713 self::assertFalse(api_get_user());
717 * Test the api_get_user() function with an user ID in a GET parameter.
721 public function testApiGetUserWithGetId()
723 $_GET['user_id'] = $this->otherUser['id'];
724 self::assertOtherUser(api_get_user());
728 * Test the api_get_user() function with a wrong user ID in a GET parameter.
732 public function testApiGetUserWithWrongGetId()
734 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
735 $_GET['user_id'] = $this->wrongUserId;
736 self::assertOtherUser(api_get_user());
740 * Test the api_get_user() function with an user name in a GET parameter.
744 public function testApiGetUserWithGetName()
746 $_GET['screen_name'] = $this->selfUser['nick'];
747 self::assertSelfUser(api_get_user());
751 * Test the api_get_user() function with a profile URL in a GET parameter.
755 public function testApiGetUserWithGetUrl()
757 $_GET['profileurl'] = $this->selfUser['nurl'];
758 self::assertSelfUser(api_get_user());
762 * Test the api_get_user() function with an user ID in the API path.
766 public function testApiGetUserWithNumericCalledApi()
769 $called_api = ['api_path'];
770 DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
771 self::assertOtherUser(api_get_user());
775 * Test the api_get_user() function with the $called_api global variable.
779 public function testApiGetUserWithCalledApi()
782 $called_api = ['api', 'api_path'];
783 self::assertSelfUser(api_get_user());
787 * Test the api_get_user() function with a valid user.
791 public function testApiGetUserWithCorrectUser()
793 self::assertOtherUser(api_get_user($this->otherUser['id']));
797 * Test the api_get_user() function with a wrong user ID.
801 public function testApiGetUserWithWrongUser()
803 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
804 self::assertOtherUser(api_get_user($this->wrongUserId));
808 * Test the api_get_user() function with a 0 user ID.
812 public function testApiGetUserWithZeroUser()
814 self::assertSelfUser(api_get_user(0));
818 * Test the api_item_get_user() function.
822 public function testApiItemGetUser()
824 $users = api_item_get_user($this->app, []);
825 self::assertSelfUser($users[0]);
829 * Test the api_item_get_user() function with a different item parent.
833 public function testApiItemGetUserWithDifferentParent()
835 $users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
836 self::assertSelfUser($users[0]);
837 self::assertEquals($users[0], $users[1]);
841 * Test the Arrays::walkRecursive() function.
845 public function testApiWalkRecursive()
850 Arrays::walkRecursive(
853 // Should we test this with a callback that actually does something?
861 * Test the Arrays::walkRecursive() function with an array.
865 public function testApiWalkRecursiveWithArray()
867 $array = [['item1'], ['item2']];
870 Arrays::walkRecursive(
873 // Should we test this with a callback that actually does something?
881 * Test the BaseApi::reformatXML() function.
885 public function testApiReformatXml()
889 self::assertTrue(ApiResponse::reformatXML($item, $key));
890 self::assertEquals('true', $item);
894 * Test the BaseApi::reformatXML() function with a statusnet_api key.
898 public function testApiReformatXmlWithStatusnetKey()
901 $key = 'statusnet_api';
902 self::assertTrue(ApiResponse::reformatXML($item, $key));
903 self::assertEquals('statusnet:api', $key);
907 * Test the BaseApi::reformatXML() function with a friendica_api key.
911 public function testApiReformatXmlWithFriendicaKey()
914 $key = 'friendica_api';
915 self::assertTrue(ApiResponse::reformatXML($item, $key));
916 self::assertEquals('friendica:api', $key);
920 * Test the BaseApi::createXML() function.
924 public function testApiCreateXml()
927 '<?xml version="1.0"?>' . "\n" .
928 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
929 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
930 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
931 ' <data>some_data</data>' . "\n" .
932 '</root_element>' . "\n",
933 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
938 * Test the BaseApi::createXML() function without any XML namespace.
942 public function testApiCreateXmlWithoutNamespaces()
945 '<?xml version="1.0"?>' . "\n" .
947 ' <data>some_data</data>' . "\n" .
949 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
954 * Test the BaseApi::formatData() function.
958 public function testApiFormatData()
960 $data = ['some_data'];
961 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
965 * Test the BaseApi::formatData() function with an XML result.
969 public function testApiFormatDataWithXml()
972 '<?xml version="1.0"?>' . "\n" .
973 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
974 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
975 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
976 ' <data>some_data</data>' . "\n" .
977 '</root_element>' . "\n",
978 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
983 * Test the api_account_verify_credentials() function.
987 public function testApiAccountVerifyCredentials()
989 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
993 * Test the api_account_verify_credentials() function without an authenticated user.
997 public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
999 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1000 $_SESSION['authenticated'] = false;
1001 api_account_verify_credentials('json');
1005 * Test the requestdata() function.
1009 public function testRequestdata()
1011 self::assertNull(requestdata('variable_name'));
1015 * Test the requestdata() function with a POST parameter.
1019 public function testRequestdataWithPost()
1021 $_POST['variable_name'] = 'variable_value';
1022 self::assertEquals('variable_value', requestdata('variable_name'));
1026 * Test the requestdata() function with a GET parameter.
1030 public function testRequestdataWithGet()
1032 $_GET['variable_name'] = 'variable_value';
1033 self::assertEquals('variable_value', requestdata('variable_name'));
1037 * Test the api_statuses_mediap() function.
1041 public function testApiStatusesMediap()
1043 DI::args()->setArgc(2);
1051 'tmp_name' => $this->getTempImage(),
1052 'name' => 'spacer.png',
1053 'type' => 'image/png'
1056 $_GET['status'] = '<b>Status content</b>';
1058 $result = api_statuses_mediap('json');
1059 self::assertStatus($result['status']);
1063 * Test the api_statuses_mediap() function without an authenticated user.
1067 public function testApiStatusesMediapWithoutAuthenticatedUser()
1069 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1070 $_SESSION['authenticated'] = false;
1071 api_statuses_mediap('json');
1075 * Test the api_statuses_update() function.
1079 public function testApiStatusesUpdate()
1081 $_GET['status'] = 'Status content #friendica';
1082 $_GET['in_reply_to_status_id'] = -1;
1091 'tmp_name' => $this->getTempImage(),
1092 'name' => 'spacer.png',
1093 'type' => 'image/png'
1097 $result = api_statuses_update('json');
1098 self::assertStatus($result['status']);
1102 * Test the api_statuses_update() function with an HTML status.
1106 public function testApiStatusesUpdateWithHtml()
1108 $_GET['htmlstatus'] = '<b>Status content</b>';
1110 $result = api_statuses_update('json');
1111 self::assertStatus($result['status']);
1115 * Test the api_statuses_update() function without an authenticated user.
1119 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1121 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1122 $_SESSION['authenticated'] = false;
1123 api_statuses_update('json');
1127 * Test the api_statuses_update() function with a parent status.
1131 public function testApiStatusesUpdateWithParent()
1133 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1137 * Test the api_statuses_update() function with a media_ids parameter.
1141 public function testApiStatusesUpdateWithMediaIds()
1143 $this->markTestIncomplete();
1147 * Test the api_statuses_update() function with the throttle limit reached.
1151 public function testApiStatusesUpdateWithDayThrottleReached()
1153 $this->markTestIncomplete();
1157 * Test the api_media_upload() function.
1158 * @runInSeparateProcess
1159 * @preserveGlobalState disabled
1161 public function testApiMediaUpload()
1163 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1168 * Test the api_media_upload() function without an authenticated user.
1172 public function testApiMediaUploadWithoutAuthenticatedUser()
1174 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1175 $_SESSION['authenticated'] = false;
1180 * Test the api_media_upload() function with an invalid uploaded media.
1184 public function testApiMediaUploadWithMedia()
1186 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1190 'tmp_name' => 'tmp_name'
1197 * Test the api_media_upload() function with an valid uploaded media.
1201 public function testApiMediaUploadWithValidMedia()
1209 'tmp_name' => $this->getTempImage(),
1210 'name' => 'spacer.png',
1211 'type' => 'image/png'
1215 DI::args()->setArgc(2);
1217 $result = api_media_upload();
1218 self::assertEquals('image/png', $result['media']['image']['image_type']);
1219 self::assertEquals(1, $result['media']['image']['w']);
1220 self::assertEquals(1, $result['media']['image']['h']);
1221 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1225 * Test the api_status_show() function.
1227 public function testApiStatusShowWithJson()
1229 $result = api_status_show('json', 1);
1230 self::assertStatus($result['status']);
1234 * Test the api_status_show() function with an XML result.
1236 public function testApiStatusShowWithXml()
1238 $result = api_status_show('xml', 1);
1239 self::assertXml($result, 'statuses');
1243 * Test the api_get_last_status() function
1245 public function testApiGetLastStatus()
1247 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1249 self::assertNotNull($item);
1253 * Test the api_users_show() function.
1257 public function testApiUsersShow()
1259 $result = api_users_show('json');
1260 // We can't use assertSelfUser() here because the user object is missing some properties.
1261 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1262 self::assertEquals('DFRN', $result['user']['location']);
1263 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1264 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1265 self::assertEquals('dfrn', $result['user']['network']);
1266 self::assertTrue($result['user']['verified']);
1270 * Test the api_users_show() function with an XML result.
1274 public function testApiUsersShowWithXml()
1276 $result = api_users_show('xml');
1277 self::assertXml($result, 'statuses');
1281 * Test the api_users_search() function.
1285 public function testApiUsersSearch()
1287 $_GET['q'] = 'othercontact';
1288 $result = api_users_search('json');
1289 self::assertOtherUser($result['users'][0]);
1293 * Test the api_users_search() function with an XML result.
1297 public function testApiUsersSearchWithXml()
1299 $_GET['q'] = 'othercontact';
1300 $result = api_users_search('xml');
1301 self::assertXml($result, 'users');
1305 * Test the api_users_search() function without a GET q parameter.
1309 public function testApiUsersSearchWithoutQuery()
1311 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1312 api_users_search('json');
1316 * Test the api_users_lookup() function.
1320 public function testApiUsersLookup()
1322 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1323 api_users_lookup('json');
1327 * Test the api_users_lookup() function with an user ID.
1331 public function testApiUsersLookupWithUserId()
1333 $_REQUEST['user_id'] = $this->otherUser['id'];
1334 $result = api_users_lookup('json');
1335 self::assertOtherUser($result['users'][0]);
1339 * Test the api_search() function.
1343 public function testApiSearch()
1345 $_REQUEST['q'] = 'reply';
1346 $_REQUEST['max_id'] = 10;
1347 $result = api_search('json');
1348 foreach ($result['status'] as $status) {
1349 self::assertStatus($status);
1350 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1355 * Test the api_search() function a count parameter.
1359 public function testApiSearchWithCount()
1361 $_REQUEST['q'] = 'reply';
1362 $_REQUEST['count'] = 20;
1363 $result = api_search('json');
1364 foreach ($result['status'] as $status) {
1365 self::assertStatus($status);
1366 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1371 * Test the api_search() function with an rpp parameter.
1375 public function testApiSearchWithRpp()
1377 $_REQUEST['q'] = 'reply';
1378 $_REQUEST['rpp'] = 20;
1379 $result = api_search('json');
1380 foreach ($result['status'] as $status) {
1381 self::assertStatus($status);
1382 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1387 * Test the api_search() function with an q parameter contains hashtag.
1388 * @doesNotPerformAssertions
1390 public function testApiSearchWithHashtag()
1392 $_REQUEST['q'] = '%23friendica';
1393 $result = api_search('json');
1394 foreach ($result['status'] as $status) {
1395 self::assertStatus($status);
1396 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1401 * Test the api_search() function with an exclude_replies parameter.
1402 * @doesNotPerformAssertions
1404 public function testApiSearchWithExcludeReplies()
1406 $_REQUEST['max_id'] = 10;
1407 $_REQUEST['exclude_replies'] = true;
1408 $_REQUEST['q'] = 'friendica';
1409 $result = api_search('json');
1410 foreach ($result['status'] as $status) {
1411 self::assertStatus($status);
1416 * Test the api_search() function without an authenticated user.
1420 public function testApiSearchWithUnallowedUser()
1422 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1423 $_SESSION['allow_api'] = false;
1424 $_GET['screen_name'] = $this->selfUser['nick'];
1429 * Test the api_search() function without any GET query parameter.
1433 public function testApiSearchWithoutQuery()
1435 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1440 * Test the api_statuses_home_timeline() function.
1444 public function testApiStatusesHomeTimeline()
1446 $_REQUEST['max_id'] = 10;
1447 $_REQUEST['exclude_replies'] = true;
1448 $_REQUEST['conversation_id'] = 1;
1449 $result = api_statuses_home_timeline('json');
1450 self::assertNotEmpty($result['status']);
1451 foreach ($result['status'] as $status) {
1452 self::assertStatus($status);
1457 * Test the api_statuses_home_timeline() function with a negative page parameter.
1461 public function testApiStatusesHomeTimelineWithNegativePage()
1463 $_REQUEST['page'] = -2;
1464 $result = api_statuses_home_timeline('json');
1465 self::assertNotEmpty($result['status']);
1466 foreach ($result['status'] as $status) {
1467 self::assertStatus($status);
1472 * Test the api_statuses_home_timeline() with an unallowed user.
1476 public function testApiStatusesHomeTimelineWithUnallowedUser()
1478 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1479 $_SESSION['allow_api'] = false;
1480 $_GET['screen_name'] = $this->selfUser['nick'];
1481 api_statuses_home_timeline('json');
1485 * Test the api_statuses_home_timeline() function with an RSS result.
1489 public function testApiStatusesHomeTimelineWithRss()
1491 $result = api_statuses_home_timeline('rss');
1492 self::assertXml($result, 'statuses');
1496 * Test the api_statuses_public_timeline() function.
1500 public function testApiStatusesPublicTimeline()
1502 $_REQUEST['max_id'] = 10;
1503 $_REQUEST['conversation_id'] = 1;
1504 $result = api_statuses_public_timeline('json');
1505 self::assertNotEmpty($result['status']);
1506 foreach ($result['status'] as $status) {
1507 self::assertStatus($status);
1512 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1516 public function testApiStatusesPublicTimelineWithExcludeReplies()
1518 $_REQUEST['max_id'] = 10;
1519 $_REQUEST['exclude_replies'] = true;
1520 $result = api_statuses_public_timeline('json');
1521 self::assertNotEmpty($result['status']);
1522 foreach ($result['status'] as $status) {
1523 self::assertStatus($status);
1528 * Test the api_statuses_public_timeline() function with a negative page parameter.
1532 public function testApiStatusesPublicTimelineWithNegativePage()
1534 $_REQUEST['page'] = -2;
1535 $result = api_statuses_public_timeline('json');
1536 self::assertNotEmpty($result['status']);
1537 foreach ($result['status'] as $status) {
1538 self::assertStatus($status);
1543 * Test the api_statuses_public_timeline() function with an unallowed user.
1547 public function testApiStatusesPublicTimelineWithUnallowedUser()
1549 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1550 $_SESSION['allow_api'] = false;
1551 $_GET['screen_name'] = $this->selfUser['nick'];
1552 api_statuses_public_timeline('json');
1556 * Test the api_statuses_public_timeline() function with an RSS result.
1560 public function testApiStatusesPublicTimelineWithRss()
1562 $result = api_statuses_public_timeline('rss');
1563 self::assertXml($result, 'statuses');
1567 * Test the api_statuses_networkpublic_timeline() function.
1571 public function testApiStatusesNetworkpublicTimeline()
1573 $_REQUEST['max_id'] = 10;
1574 $result = api_statuses_networkpublic_timeline('json');
1575 self::assertNotEmpty($result['status']);
1576 foreach ($result['status'] as $status) {
1577 self::assertStatus($status);
1582 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1586 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1588 $_REQUEST['page'] = -2;
1589 $result = api_statuses_networkpublic_timeline('json');
1590 self::assertNotEmpty($result['status']);
1591 foreach ($result['status'] as $status) {
1592 self::assertStatus($status);
1597 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1601 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1603 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1604 $_SESSION['allow_api'] = false;
1605 $_GET['screen_name'] = $this->selfUser['nick'];
1606 api_statuses_networkpublic_timeline('json');
1610 * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1614 public function testApiStatusesNetworkpublicTimelineWithRss()
1616 $result = api_statuses_networkpublic_timeline('rss');
1617 self::assertXml($result, 'statuses');
1621 * Test the api_statuses_show() function.
1625 public function testApiStatusesShow()
1627 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1628 api_statuses_show('json');
1632 * Test the api_statuses_show() function with an ID.
1636 public function testApiStatusesShowWithId()
1638 DI::args()->setArgv(['', '', '', 1]);
1639 $result = api_statuses_show('json');
1640 self::assertStatus($result['status']);
1644 * Test the api_statuses_show() function with the conversation parameter.
1648 public function testApiStatusesShowWithConversation()
1650 DI::args()->setArgv(['', '', '', 1]);
1651 $_REQUEST['conversation'] = 1;
1652 $result = api_statuses_show('json');
1653 self::assertNotEmpty($result['status']);
1654 foreach ($result['status'] as $status) {
1655 self::assertStatus($status);
1660 * Test the api_statuses_show() function with an unallowed user.
1664 public function testApiStatusesShowWithUnallowedUser()
1666 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1667 $_SESSION['allow_api'] = false;
1668 $_GET['screen_name'] = $this->selfUser['nick'];
1669 api_statuses_show('json');
1673 * Test the api_conversation_show() function.
1677 public function testApiConversationShow()
1679 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1680 api_conversation_show('json');
1684 * Test the api_conversation_show() function with an ID.
1688 public function testApiConversationShowWithId()
1690 DI::args()->setArgv(['', '', '', 1]);
1691 $_REQUEST['max_id'] = 10;
1692 $_REQUEST['page'] = -2;
1693 $result = api_conversation_show('json');
1694 self::assertNotEmpty($result['status']);
1695 foreach ($result['status'] as $status) {
1696 self::assertStatus($status);
1701 * Test the api_conversation_show() function with an unallowed user.
1705 public function testApiConversationShowWithUnallowedUser()
1707 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1708 $_SESSION['allow_api'] = false;
1709 $_GET['screen_name'] = $this->selfUser['nick'];
1710 api_conversation_show('json');
1714 * Test the api_statuses_repeat() function.
1718 public function testApiStatusesRepeat()
1720 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1721 api_statuses_repeat('json');
1725 * Test the api_statuses_repeat() function without an authenticated user.
1729 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1731 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1732 $_SESSION['authenticated'] = false;
1733 api_statuses_repeat('json');
1737 * Test the api_statuses_repeat() function with an ID.
1741 public function testApiStatusesRepeatWithId()
1743 DI::args()->setArgv(['', '', '', 1]);
1744 $result = api_statuses_repeat('json');
1745 self::assertStatus($result['status']);
1747 // Also test with a shared status
1748 DI::args()->setArgv(['', '', '', 5]);
1749 $result = api_statuses_repeat('json');
1750 self::assertStatus($result['status']);
1754 * Test the api_statuses_destroy() function.
1758 public function testApiStatusesDestroy()
1760 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1761 api_statuses_destroy('json');
1765 * Test the api_statuses_destroy() function without an authenticated user.
1769 public function testApiStatusesDestroyWithoutAuthenticatedUser()
1771 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1772 $_SESSION['authenticated'] = false;
1773 api_statuses_destroy('json');
1777 * Test the api_statuses_destroy() function with an ID.
1781 public function testApiStatusesDestroyWithId()
1783 DI::args()->setArgv(['', '', '', 1]);
1784 $result = api_statuses_destroy('json');
1785 self::assertStatus($result['status']);
1789 * Test the api_statuses_mentions() function.
1793 public function testApiStatusesMentions()
1795 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1796 $_REQUEST['max_id'] = 10;
1797 $result = api_statuses_mentions('json');
1798 self::assertEmpty($result['status']);
1799 // We should test with mentions in the database.
1803 * Test the api_statuses_mentions() function with a negative page parameter.
1807 public function testApiStatusesMentionsWithNegativePage()
1809 $_REQUEST['page'] = -2;
1810 $result = api_statuses_mentions('json');
1811 self::assertEmpty($result['status']);
1815 * Test the api_statuses_mentions() function with an unallowed user.
1819 public function testApiStatusesMentionsWithUnallowedUser()
1821 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1822 $_SESSION['allow_api'] = false;
1823 $_GET['screen_name'] = $this->selfUser['nick'];
1824 api_statuses_mentions('json');
1828 * Test the api_statuses_mentions() function with an RSS result.
1832 public function testApiStatusesMentionsWithRss()
1834 $result = api_statuses_mentions('rss');
1835 self::assertXml($result, 'statuses');
1839 * Test the api_statuses_user_timeline() function.
1843 public function testApiStatusesUserTimeline()
1845 $_REQUEST['max_id'] = 10;
1846 $_REQUEST['exclude_replies'] = true;
1847 $_REQUEST['conversation_id'] = 1;
1848 $result = api_statuses_user_timeline('json');
1849 self::assertNotEmpty($result['status']);
1850 foreach ($result['status'] as $status) {
1851 self::assertStatus($status);
1856 * Test the api_statuses_user_timeline() function with a negative page parameter.
1860 public function testApiStatusesUserTimelineWithNegativePage()
1862 $_REQUEST['page'] = -2;
1863 $result = api_statuses_user_timeline('json');
1864 self::assertNotEmpty($result['status']);
1865 foreach ($result['status'] as $status) {
1866 self::assertStatus($status);
1871 * Test the api_statuses_user_timeline() function with an RSS result.
1875 public function testApiStatusesUserTimelineWithRss()
1877 $result = api_statuses_user_timeline('rss');
1878 self::assertXml($result, 'statuses');
1882 * Test the api_statuses_user_timeline() function with an unallowed user.
1886 public function testApiStatusesUserTimelineWithUnallowedUser()
1888 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1889 $_SESSION['allow_api'] = false;
1890 $_GET['screen_name'] = $this->selfUser['nick'];
1891 api_statuses_user_timeline('json');
1895 * Test the api_favorites_create_destroy() function.
1899 public function testApiFavoritesCreateDestroy()
1901 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1902 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1903 api_favorites_create_destroy('json');
1907 * Test the api_favorites_create_destroy() function with an invalid ID.
1911 public function testApiFavoritesCreateDestroyWithInvalidId()
1913 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1914 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1915 api_favorites_create_destroy('json');
1919 * Test the api_favorites_create_destroy() function with an invalid action.
1923 public function testApiFavoritesCreateDestroyWithInvalidAction()
1925 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1926 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1927 $_REQUEST['id'] = 1;
1928 api_favorites_create_destroy('json');
1932 * Test the api_favorites_create_destroy() function with the create action.
1936 public function testApiFavoritesCreateDestroyWithCreateAction()
1938 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1939 $_REQUEST['id'] = 3;
1940 $result = api_favorites_create_destroy('json');
1941 self::assertStatus($result['status']);
1945 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1949 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1951 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1952 $_REQUEST['id'] = 3;
1953 $result = api_favorites_create_destroy('rss');
1954 self::assertXml($result, 'status');
1958 * Test the api_favorites_create_destroy() function with the destroy action.
1962 public function testApiFavoritesCreateDestroyWithDestroyAction()
1964 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1965 $_REQUEST['id'] = 3;
1966 $result = api_favorites_create_destroy('json');
1967 self::assertStatus($result['status']);
1971 * Test the api_favorites_create_destroy() function without an authenticated user.
1975 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1977 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1978 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1979 $_SESSION['authenticated'] = false;
1980 api_favorites_create_destroy('json');
1984 * Test the api_favorites() function.
1988 public function testApiFavorites()
1990 $_REQUEST['page'] = -1;
1991 $_REQUEST['max_id'] = 10;
1992 $result = api_favorites('json');
1993 foreach ($result['status'] as $status) {
1994 self::assertStatus($status);
1999 * Test the api_favorites() function with an RSS result.
2003 public function testApiFavoritesWithRss()
2005 $result = api_favorites('rss');
2006 self::assertXml($result, 'statuses');
2010 * Test the api_favorites() function with an unallowed user.
2014 public function testApiFavoritesWithUnallowedUser()
2016 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2017 $_SESSION['allow_api'] = false;
2018 $_GET['screen_name'] = $this->selfUser['nick'];
2019 api_favorites('json');
2023 * Test the api_format_messages() function.
2027 public function testApiFormatMessages()
2029 $result = api_format_messages(
2030 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2031 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2032 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
2034 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
2035 self::assertEquals(1, $result['id']);
2036 self::assertEquals(2, $result['recipient_id']);
2037 self::assertEquals(3, $result['sender_id']);
2038 self::assertEquals('recipient_name', $result['recipient_screen_name']);
2039 self::assertEquals('sender_name', $result['sender_screen_name']);
2043 * Test the api_format_messages() function with HTML.
2047 public function testApiFormatMessagesWithHtmlText()
2049 $_GET['getText'] = 'html';
2050 $result = api_format_messages(
2051 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2052 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2053 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2055 self::assertEquals('item_title', $result['title']);
2056 self::assertEquals('<strong>item_body</strong>', $result['text']);
2060 * Test the api_format_messages() function with plain text.
2064 public function testApiFormatMessagesWithPlainText()
2066 $_GET['getText'] = 'plain';
2067 $result = api_format_messages(
2068 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2069 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2070 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2072 self::assertEquals('item_title', $result['title']);
2073 self::assertEquals('item_body', $result['text']);
2077 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
2081 public function testApiFormatMessagesWithoutUserObjects()
2083 $_GET['getUserObjects'] = 'false';
2084 $result = api_format_messages(
2085 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2086 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2087 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2089 self::assertTrue(!isset($result['sender']));
2090 self::assertTrue(!isset($result['recipient']));
2094 * Test the api_convert_item() function.
2098 public function testApiConvertItem()
2100 $result = api_convert_item(
2102 'network' => 'feed',
2103 'title' => 'item_title',
2105 // We need a long string to test that it is correctly cut
2106 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2107 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2108 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2109 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2110 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2111 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2112 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2113 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2114 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2115 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2116 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2117 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2118 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2119 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2120 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2121 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2122 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2123 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2124 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2125 'repellat officia illum quos impedit quam iste esse unde qui ' .
2126 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2127 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2128 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2129 'plink' => 'item_plink'
2132 self::assertStringStartsWith('item_title', $result['text']);
2133 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2137 * Test the api_convert_item() function with an empty item body.
2141 public function testApiConvertItemWithoutBody()
2143 $result = api_convert_item(
2145 'network' => 'feed',
2146 'title' => 'item_title',
2149 'plink' => 'item_plink'
2152 self::assertEquals("item_title", $result['text']);
2153 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2157 * Test the api_convert_item() function with the title in the body.
2161 public function testApiConvertItemWithTitleInBody()
2163 $result = api_convert_item(
2165 'title' => 'item_title',
2166 'body' => 'item_title item_body',
2170 self::assertEquals('item_title item_body', $result['text']);
2171 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2175 * Test the api_get_attachments() function.
2179 public function testApiGetAttachments()
2182 self::assertEmpty(api_get_attachments($body, 0));
2186 * Test the api_get_attachments() function with an img tag.
2190 public function testApiGetAttachmentsWithImage()
2192 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2193 self::assertIsArray(api_get_attachments($body, 0));
2197 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2201 public function testApiGetAttachmentsWithImageAndAndStatus()
2203 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2204 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2205 self::assertIsArray(api_get_attachments($body, 0));
2209 * Test the api_get_entitities() function.
2213 public function testApiGetEntitities()
2216 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2220 * Test the api_get_entitities() function with the include_entities parameter.
2224 public function testApiGetEntititiesWithIncludeEntities()
2226 $_REQUEST['include_entities'] = 'true';
2228 $result = api_get_entitities($text, 'bbcode', 0);
2229 self::assertIsArray($result['hashtags']);
2230 self::assertIsArray($result['symbols']);
2231 self::assertIsArray($result['urls']);
2232 self::assertIsArray($result['user_mentions']);
2236 * Test the api_format_items_embeded_images() function.
2240 public function testApiFormatItemsEmbededImages()
2243 'text ' . DI::baseUrl() . '/display/item_guid',
2244 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2249 * Test the api_contactlink_to_array() function.
2253 public function testApiContactlinkToArray()
2260 api_contactlink_to_array('text')
2265 * Test the api_contactlink_to_array() function with an URL.
2269 public function testApiContactlinkToArrayWithUrl()
2273 'name' => ['link_text'],
2276 api_contactlink_to_array('text <a href="url">link_text</a>')
2281 * Test the api_format_items_activities() function.
2285 public function testApiFormatItemsActivities()
2287 $item = ['uid' => 0, 'uri' => ''];
2288 $result = api_format_items_activities($item);
2289 self::assertArrayHasKey('like', $result);
2290 self::assertArrayHasKey('dislike', $result);
2291 self::assertArrayHasKey('attendyes', $result);
2292 self::assertArrayHasKey('attendno', $result);
2293 self::assertArrayHasKey('attendmaybe', $result);
2297 * Test the api_format_items_activities() function with an XML result.
2301 public function testApiFormatItemsActivitiesWithXml()
2303 $item = ['uid' => 0, 'uri' => ''];
2304 $result = api_format_items_activities($item, 'xml');
2305 self::assertArrayHasKey('friendica:like', $result);
2306 self::assertArrayHasKey('friendica:dislike', $result);
2307 self::assertArrayHasKey('friendica:attendyes', $result);
2308 self::assertArrayHasKey('friendica:attendno', $result);
2309 self::assertArrayHasKey('friendica:attendmaybe', $result);
2313 * Test the api_format_items() function.
2314 * @doesNotPerformAssertions
2316 public function testApiFormatItems()
2320 'item_network' => 'item_network',
2326 'author-network' => Protocol::DFRN,
2327 'author-link' => 'http://localhost/profile/othercontact',
2331 $result = api_format_items($items, ['id' => 0], true);
2332 foreach ($result as $status) {
2333 self::assertStatus($status);
2338 * Test the api_format_items() function with an XML result.
2339 * @doesNotPerformAssertions
2341 public function testApiFormatItemsWithXml()
2349 'author-network' => Protocol::DFRN,
2350 'author-link' => 'http://localhost/profile/othercontact',
2354 $result = api_format_items($items, ['id' => 0], true, 'xml');
2355 foreach ($result as $status) {
2356 self::assertStatus($status);
2361 * Test the api_lists_list() function.
2365 public function testApiListsList()
2367 $result = api_lists_list('json');
2368 self::assertEquals(['lists_list' => []], $result);
2372 * Test the api_lists_ownerships() function.
2376 public function testApiListsOwnerships()
2378 $result = api_lists_ownerships('json');
2379 foreach ($result['lists']['lists'] as $list) {
2380 self::assertList($list);
2385 * Test the api_lists_ownerships() function without an authenticated user.
2389 public function testApiListsOwnershipsWithoutAuthenticatedUser()
2391 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2392 $_SESSION['authenticated'] = false;
2393 api_lists_ownerships('json');
2397 * Test the api_lists_statuses() function.
2401 public function testApiListsStatuses()
2403 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2404 api_lists_statuses('json');
2408 * Test the api_lists_statuses() function with a list ID.
2409 * @doesNotPerformAssertions
2411 public function testApiListsStatusesWithListId()
2413 $_REQUEST['list_id'] = 1;
2414 $_REQUEST['page'] = -1;
2415 $_REQUEST['max_id'] = 10;
2416 $result = api_lists_statuses('json');
2417 foreach ($result['status'] as $status) {
2418 self::assertStatus($status);
2423 * Test the api_lists_statuses() function with a list ID and a RSS result.
2427 public function testApiListsStatusesWithListIdAndRss()
2429 $_REQUEST['list_id'] = 1;
2430 $result = api_lists_statuses('rss');
2431 self::assertXml($result, 'statuses');
2435 * Test the api_lists_statuses() function with an unallowed user.
2439 public function testApiListsStatusesWithUnallowedUser()
2441 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2442 $_SESSION['allow_api'] = false;
2443 $_GET['screen_name'] = $this->selfUser['nick'];
2444 api_lists_statuses('json');
2448 * Test the api_statuses_f() function.
2452 public function testApiStatusesFWithFriends()
2455 $result = api_statuses_f('friends');
2456 self::assertArrayHasKey('user', $result);
2460 * Test the api_statuses_f() function.
2464 public function testApiStatusesFWithFollowers()
2466 $result = api_statuses_f('followers');
2467 self::assertArrayHasKey('user', $result);
2471 * Test the api_statuses_f() function.
2475 public function testApiStatusesFWithBlocks()
2477 $result = api_statuses_f('blocks');
2478 self::assertArrayHasKey('user', $result);
2482 * Test the api_statuses_f() function.
2486 public function testApiStatusesFWithIncoming()
2488 $result = api_statuses_f('incoming');
2489 self::assertArrayHasKey('user', $result);
2493 * Test the api_statuses_f() function an undefined cursor GET variable.
2497 public function testApiStatusesFWithUndefinedCursor()
2499 $_GET['cursor'] = 'undefined';
2500 self::assertFalse(api_statuses_f('friends'));
2504 * Test the api_statuses_friends() function.
2508 public function testApiStatusesFriends()
2510 $result = api_statuses_friends('json');
2511 self::assertArrayHasKey('user', $result);
2515 * Test the api_statuses_friends() function an undefined cursor GET variable.
2519 public function testApiStatusesFriendsWithUndefinedCursor()
2521 $_GET['cursor'] = 'undefined';
2522 self::assertFalse(api_statuses_friends('json'));
2526 * Test the api_statuses_followers() function.
2530 public function testApiStatusesFollowers()
2532 $result = api_statuses_followers('json');
2533 self::assertArrayHasKey('user', $result);
2537 * Test the api_statuses_followers() function an undefined cursor GET variable.
2541 public function testApiStatusesFollowersWithUndefinedCursor()
2543 $_GET['cursor'] = 'undefined';
2544 self::assertFalse(api_statuses_followers('json'));
2548 * Test the api_blocks_list() function.
2552 public function testApiBlocksList()
2554 $result = api_blocks_list('json');
2555 self::assertArrayHasKey('user', $result);
2559 * Test the api_blocks_list() function an undefined cursor GET variable.
2563 public function testApiBlocksListWithUndefinedCursor()
2565 $_GET['cursor'] = 'undefined';
2566 self::assertFalse(api_blocks_list('json'));
2570 * Test the api_friendships_incoming() function.
2574 public function testApiFriendshipsIncoming()
2576 $result = api_friendships_incoming('json');
2577 self::assertArrayHasKey('id', $result);
2581 * Test the api_friendships_incoming() function an undefined cursor GET variable.
2585 public function testApiFriendshipsIncomingWithUndefinedCursor()
2587 $_GET['cursor'] = 'undefined';
2588 self::assertFalse(api_friendships_incoming('json'));
2592 * Test the api_statusnet_config() function.
2596 public function testApiStatusnetConfig()
2599 $result = api_statusnet_config('json');
2600 self::assertEquals('localhost', $result['config']['site']['server']);
2601 self::assertEquals('default', $result['config']['site']['theme']);
2602 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2603 self::assertTrue($result['config']['site']['fancy']);
2604 self::assertEquals('en', $result['config']['site']['language']);
2605 self::assertEquals('UTC', $result['config']['site']['timezone']);
2606 self::assertEquals(200000, $result['config']['site']['textlimit']);
2607 self::assertEquals('false', $result['config']['site']['private']);
2608 self::assertEquals('false', $result['config']['site']['ssl']);
2609 self::assertEquals(30, $result['config']['site']['shorturllength']);
2614 * Test the api_direct_messages_new() function.
2618 public function testApiDirectMessagesNew()
2620 $result = api_direct_messages_new('json');
2621 self::assertNull($result);
2625 * Test the api_direct_messages_new() function without an authenticated user.
2629 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2631 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2632 $_SESSION['authenticated'] = false;
2633 api_direct_messages_new('json');
2637 * Test the api_direct_messages_new() function with an user ID.
2641 public function testApiDirectMessagesNewWithUserId()
2643 $_POST['text'] = 'message_text';
2644 $_POST['user_id'] = $this->otherUser['id'];
2645 $result = api_direct_messages_new('json');
2646 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2650 * Test the api_direct_messages_new() function with a screen name.
2654 public function testApiDirectMessagesNewWithScreenName()
2656 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2657 $_POST['text'] = 'message_text';
2658 $_POST['screen_name'] = $this->friendUser['nick'];
2659 $result = api_direct_messages_new('json');
2660 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2661 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2662 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2666 * Test the api_direct_messages_new() function with a title.
2670 public function testApiDirectMessagesNewWithTitle()
2672 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2673 $_POST['text'] = 'message_text';
2674 $_POST['screen_name'] = $this->friendUser['nick'];
2675 $_REQUEST['title'] = 'message_title';
2676 $result = api_direct_messages_new('json');
2677 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2678 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2679 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2680 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2684 * Test the api_direct_messages_new() function with an RSS result.
2688 public function testApiDirectMessagesNewWithRss()
2690 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2691 $_POST['text'] = 'message_text';
2692 $_POST['screen_name'] = $this->friendUser['nick'];
2693 $result = api_direct_messages_new('rss');
2694 self::assertXml($result, 'direct-messages');
2698 * Test the api_direct_messages_destroy() function.
2702 public function testApiDirectMessagesDestroy()
2704 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2705 api_direct_messages_destroy('json');
2709 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2713 public function testApiDirectMessagesDestroyWithVerbose()
2715 $_GET['friendica_verbose'] = 'true';
2716 $result = api_direct_messages_destroy('json');
2720 'result' => 'error',
2721 'message' => 'message id or parenturi not specified'
2729 * Test the api_direct_messages_destroy() function without an authenticated user.
2733 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2735 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2736 $_SESSION['authenticated'] = false;
2737 api_direct_messages_destroy('json');
2741 * Test the api_direct_messages_destroy() function with a non-zero ID.
2745 public function testApiDirectMessagesDestroyWithId()
2747 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2748 $_REQUEST['id'] = 1;
2749 api_direct_messages_destroy('json');
2753 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2757 public function testApiDirectMessagesDestroyWithIdAndVerbose()
2759 $_REQUEST['id'] = 1;
2760 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2761 $_GET['friendica_verbose'] = 'true';
2762 $result = api_direct_messages_destroy('json');
2766 'result' => 'error',
2767 'message' => 'message id not in database'
2775 * Test the api_direct_messages_destroy() function with a non-zero ID.
2779 public function testApiDirectMessagesDestroyWithCorrectId()
2781 $this->markTestIncomplete('We need to add a dataset for this.');
2785 * Test the api_direct_messages_box() function.
2789 public function testApiDirectMessagesBoxWithSentbox()
2791 $_REQUEST['page'] = -1;
2792 $_REQUEST['max_id'] = 10;
2793 $result = api_direct_messages_box('json', 'sentbox', 'false');
2794 self::assertArrayHasKey('direct_message', $result);
2798 * Test the api_direct_messages_box() function.
2802 public function testApiDirectMessagesBoxWithConversation()
2804 $result = api_direct_messages_box('json', 'conversation', 'false');
2805 self::assertArrayHasKey('direct_message', $result);
2809 * Test the api_direct_messages_box() function.
2813 public function testApiDirectMessagesBoxWithAll()
2815 $result = api_direct_messages_box('json', 'all', 'false');
2816 self::assertArrayHasKey('direct_message', $result);
2820 * Test the api_direct_messages_box() function.
2824 public function testApiDirectMessagesBoxWithInbox()
2826 $result = api_direct_messages_box('json', 'inbox', 'false');
2827 self::assertArrayHasKey('direct_message', $result);
2831 * Test the api_direct_messages_box() function.
2835 public function testApiDirectMessagesBoxWithVerbose()
2837 $result = api_direct_messages_box('json', 'sentbox', 'true');
2841 'result' => 'error',
2842 'message' => 'no mails available'
2850 * Test the api_direct_messages_box() function with a RSS result.
2854 public function testApiDirectMessagesBoxWithRss()
2856 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2857 self::assertXml($result, 'direct-messages');
2861 * Test the api_direct_messages_box() function without an authenticated user.
2865 public function testApiDirectMessagesBoxWithUnallowedUser()
2867 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2868 $_SESSION['allow_api'] = false;
2869 $_GET['screen_name'] = $this->selfUser['nick'];
2870 api_direct_messages_box('json', 'sentbox', 'false');
2874 * Test the api_direct_messages_sentbox() function.
2878 public function testApiDirectMessagesSentbox()
2880 $result = api_direct_messages_sentbox('json');
2881 self::assertArrayHasKey('direct_message', $result);
2885 * Test the api_direct_messages_inbox() function.
2889 public function testApiDirectMessagesInbox()
2891 $result = api_direct_messages_inbox('json');
2892 self::assertArrayHasKey('direct_message', $result);
2896 * Test the api_direct_messages_all() function.
2900 public function testApiDirectMessagesAll()
2902 $result = api_direct_messages_all('json');
2903 self::assertArrayHasKey('direct_message', $result);
2907 * Test the api_direct_messages_conversation() function.
2911 public function testApiDirectMessagesConversation()
2913 $result = api_direct_messages_conversation('json');
2914 self::assertArrayHasKey('direct_message', $result);
2918 * Test the api_oauth_request_token() function.
2922 public function testApiOauthRequestToken()
2924 $this->markTestIncomplete('exit() kills phpunit as well');
2928 * Test the api_oauth_access_token() function.
2932 public function testApiOauthAccessToken()
2934 $this->markTestIncomplete('exit() kills phpunit as well');
2938 * Test the api_fr_photos_list() function.
2942 public function testApiFrPhotosList()
2944 $result = api_fr_photos_list('json');
2945 self::assertArrayHasKey('photo', $result);
2949 * Test the api_fr_photos_list() function without an authenticated user.
2953 public function testApiFrPhotosListWithoutAuthenticatedUser()
2955 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2956 $_SESSION['authenticated'] = false;
2957 api_fr_photos_list('json');
2961 * Test the api_fr_photo_create_update() function.
2963 public function testApiFrPhotoCreateUpdate()
2965 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2966 api_fr_photo_create_update('json');
2970 * Test the api_fr_photo_create_update() function without an authenticated user.
2974 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2976 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2977 $_SESSION['authenticated'] = false;
2978 api_fr_photo_create_update('json');
2982 * Test the api_fr_photo_create_update() function with an album name.
2986 public function testApiFrPhotoCreateUpdateWithAlbum()
2988 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2989 $_REQUEST['album'] = 'album_name';
2990 api_fr_photo_create_update('json');
2994 * Test the api_fr_photo_create_update() function with the update mode.
2998 public function testApiFrPhotoCreateUpdateWithUpdate()
3000 $this->markTestIncomplete('We need to create a dataset for this');
3004 * Test the api_fr_photo_create_update() function with an uploaded file.
3008 public function testApiFrPhotoCreateUpdateWithFile()
3010 $this->markTestIncomplete();
3014 * Test the api_fr_photo_detail() function.
3018 public function testApiFrPhotoDetail()
3020 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3021 api_fr_photo_detail('json');
3025 * Test the api_fr_photo_detail() function without an authenticated user.
3029 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
3031 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3032 $_SESSION['authenticated'] = false;
3033 api_fr_photo_detail('json');
3037 * Test the api_fr_photo_detail() function with a photo ID.
3041 public function testApiFrPhotoDetailWithPhotoId()
3043 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
3044 $_REQUEST['photo_id'] = 1;
3045 api_fr_photo_detail('json');
3049 * Test the api_fr_photo_detail() function with a correct photo ID.
3053 public function testApiFrPhotoDetailCorrectPhotoId()
3055 $this->markTestIncomplete('We need to create a dataset for this.');
3059 * Test the api_account_update_profile_image() function.
3063 public function testApiAccountUpdateProfileImage()
3065 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3066 api_account_update_profile_image('json');
3070 * Test the api_account_update_profile_image() function without an authenticated user.
3074 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
3076 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3077 $_SESSION['authenticated'] = false;
3078 api_account_update_profile_image('json');
3082 * Test the api_account_update_profile_image() function with an uploaded file.
3086 public function testApiAccountUpdateProfileImageWithUpload()
3088 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3089 $this->markTestIncomplete();
3094 * Test the api_account_update_profile() function.
3098 public function testApiAccountUpdateProfile()
3100 $_POST['name'] = 'new_name';
3101 $_POST['description'] = 'new_description';
3102 $result = api_account_update_profile('json');
3103 // We can't use assertSelfUser() here because the user object is missing some properties.
3104 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
3105 self::assertEquals('DFRN', $result['user']['location']);
3106 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
3107 self::assertEquals('dfrn', $result['user']['network']);
3108 self::assertEquals('new_name', $result['user']['name']);
3109 self::assertEquals('new_description', $result['user']['description']);
3113 * Test the check_acl_input() function.
3117 public function testCheckAclInput()
3119 $result = check_acl_input('<aclstring>');
3120 // Where does this result come from?
3121 self::assertEquals(1, $result);
3125 * Test the check_acl_input() function with an empty ACL string.
3129 public function testCheckAclInputWithEmptyAclString()
3131 $result = check_acl_input(' ');
3132 self::assertFalse($result);
3136 * Test the save_media_to_database() function.
3140 public function testSaveMediaToDatabase()
3142 $this->markTestIncomplete();
3146 * Test the post_photo_item() function.
3150 public function testPostPhotoItem()
3152 $this->markTestIncomplete();
3156 * Test the prepare_photo_data() function.
3160 public function testPreparePhotoData()
3162 $this->markTestIncomplete();
3166 * Test the api_share_as_retweet() function with a valid item.
3170 public function testApiShareAsRetweetWithValidItem()
3172 $this->markTestIncomplete();
3176 * Test the api_in_reply_to() function.
3180 public function testApiInReplyTo()
3182 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3183 self::assertArrayHasKey('status_id', $result);
3184 self::assertArrayHasKey('user_id', $result);
3185 self::assertArrayHasKey('status_id_str', $result);
3186 self::assertArrayHasKey('user_id_str', $result);
3187 self::assertArrayHasKey('screen_name', $result);
3191 * Test the api_in_reply_to() function with a valid item.
3195 public function testApiInReplyToWithValidItem()
3197 $this->markTestIncomplete();
3201 * Test the api_clean_plain_items() function.
3205 public function testApiCleanPlainItems()
3207 $_REQUEST['include_entities'] = 'true';
3208 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3209 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3213 * Test the api_best_nickname() function.
3217 public function testApiBestNickname()
3220 $result = api_best_nickname($contacts);
3221 self::assertNull($result);
3225 * Test the api_best_nickname() function with contacts.
3229 public function testApiBestNicknameWithContacts()
3231 $this->markTestIncomplete();
3235 * Test the api_friendica_group_show() function.
3239 public function testApiFriendicaGroupShow()
3241 $this->markTestIncomplete();
3245 * Test the api_friendica_group_delete() function.
3249 public function testApiFriendicaGroupDelete()
3251 $this->markTestIncomplete();
3255 * Test the api_lists_destroy() function.
3259 public function testApiListsDestroy()
3261 $this->markTestIncomplete();
3265 * Test the group_create() function.
3269 public function testGroupCreate()
3271 $this->markTestIncomplete();
3275 * Test the api_friendica_group_create() function.
3279 public function testApiFriendicaGroupCreate()
3281 $this->markTestIncomplete();
3285 * Test the api_lists_create() function.
3289 public function testApiListsCreate()
3291 $this->markTestIncomplete();
3295 * Test the api_friendica_group_update() function.
3299 public function testApiFriendicaGroupUpdate()
3301 $this->markTestIncomplete();
3305 * Test the api_lists_update() function.
3309 public function testApiListsUpdate()
3311 $this->markTestIncomplete();
3315 * Test the api_friendica_activity() function.
3319 public function testApiFriendicaActivity()
3321 $this->markTestIncomplete();
3325 * Test the api_friendica_notification_seen() function.
3329 public function testApiFriendicaNotificationSeen()
3331 $this->markTestIncomplete();
3335 * Test the api_friendica_direct_messages_setseen() function.
3339 public function testApiFriendicaDirectMessagesSetseen()
3341 $this->markTestIncomplete();
3345 * Test the api_friendica_direct_messages_search() function.
3349 public function testApiFriendicaDirectMessagesSearch()
3351 $this->markTestIncomplete();