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
113 'authenticated' => true,
114 'uid' => $this->selfUser['id']
116 BasicAuth::setCurrentUserID($this->selfUser['id']);
120 * Assert that an user array contains expected keys.
122 * @param array $user User array
126 private function assertSelfUser(array $user)
128 self::assertEquals($this->selfUser['id'], $user['uid']);
129 self::assertEquals($this->selfUser['id'], $user['cid']);
130 self::assertEquals(1, $user['self']);
131 self::assertEquals('DFRN', $user['location']);
132 self::assertEquals($this->selfUser['name'], $user['name']);
133 self::assertEquals($this->selfUser['nick'], $user['screen_name']);
134 self::assertEquals('dfrn', $user['network']);
135 self::assertTrue($user['verified']);
139 * Assert that an user array contains expected keys.
141 * @param array $user User array
145 private function assertOtherUser(array $user = [])
147 self::assertEquals($this->otherUser['id'], $user['id']);
148 self::assertEquals($this->otherUser['id'], $user['id_str']);
149 self::assertEquals(0, $user['self']);
150 self::assertEquals($this->otherUser['name'], $user['name']);
151 self::assertEquals($this->otherUser['nick'], $user['screen_name']);
152 self::assertFalse($user['verified']);
156 * Assert that a status array contains expected keys.
158 * @param array $status Status array
162 private function assertStatus(array $status = [])
164 self::assertIsString($status['text'] ?? '');
165 self::assertIsInt($status['id'] ?? '');
166 // We could probably do more checks here.
170 * Assert that a list array contains expected keys.
172 * @param array $list List array
176 private function assertList(array $list = [])
178 self::assertIsString($list['name']);
179 self::assertIsInt($list['id']);
180 self::assertIsString('string', $list['id_str']);
181 self::assertContains($list['mode'], ['public', 'private']);
182 // We could probably do more checks here.
186 * Assert that the string is XML and contain the root element.
188 * @param string $result XML string
189 * @param string $root_element Root element name
193 private function assertXml($result = '', $root_element = '')
195 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
196 self::assertStringContainsString('<' . $root_element, $result);
197 // We could probably do more checks here.
201 * Get the path to a temporary empty PNG image.
203 * @return string Path
205 private function getTempImage()
207 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
211 // Empty 1x1 px PNG image
212 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
220 * Test the api_user() function.
224 public function testApiUser()
226 self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
230 * Test the api_user() function with an unallowed user.
234 public function testApiUserWithUnallowedUser()
236 // self::assertEquals(false, api_user());
240 * Test the api_source() function.
244 public function testApiSource()
246 self::assertEquals('api', api_source());
250 * Test the api_source() function with a Twidere user agent.
254 public function testApiSourceWithTwidere()
256 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
257 self::assertEquals('Twidere', api_source());
261 * Test the api_source() function with a GET parameter.
265 public function testApiSourceWithGet()
267 $_GET['source'] = 'source_name';
268 self::assertEquals('source_name', api_source());
272 * Test the api_date() function.
276 public function testApiDate()
278 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
282 * Test the api_register_func() function.
286 public function testApiRegisterFunc()
298 self::assertTrue($API['api_path']['auth']);
299 self::assertEquals('method', $API['api_path']['method']);
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_check_method() function.
386 public function testApiCheckMethod()
388 self::assertFalse(api_check_method('method'));
392 * Test the api_check_method() function with a correct method.
396 public function testApiCheckMethodWithCorrectMethod()
398 $_SERVER['REQUEST_METHOD'] = 'method';
399 self::assertTrue(api_check_method('method'));
403 * Test the api_check_method() function with a wildcard.
407 public function testApiCheckMethodWithWildcard()
409 self::assertTrue(api_check_method('*'));
413 * Test the api_call() function.
415 * @runInSeparateProcess
416 * @preserveGlobalState disabled
418 public function testApiCall()
422 'method' => 'method',
423 'func' => function () {
424 return ['data' => ['some_data']];
427 $_SERVER['REQUEST_METHOD'] = 'method';
428 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
429 $_GET['callback'] = 'callback_name';
431 $args = DI::args()->determine($_SERVER, $_GET);
434 'callback_name(["some_data"])',
435 api_call($this->app, $args)
440 * Test the api_call() function with the profiled enabled.
442 * @runInSeparateProcess
443 * @preserveGlobalState disabled
445 public function testApiCallWithProfiler()
449 'method' => 'method',
450 'func' => function () {
451 return ['data' => ['some_data']];
455 $_SERVER['REQUEST_METHOD'] = 'method';
456 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
458 $args = DI::args()->determine($_SERVER, $_GET);
460 $this->config->set('system', 'profiler', true);
461 $this->config->set('rendertime', 'callstack', true);
462 $this->app->callstack = [
463 'database' => ['some_function' => 200],
464 'database_write' => ['some_function' => 200],
465 'cache' => ['some_function' => 200],
466 'cache_write' => ['some_function' => 200],
467 'network' => ['some_function' => 200]
472 api_call($this->app, $args)
477 * Test the api_call() function with a JSON result.
479 * @runInSeparateProcess
480 * @preserveGlobalState disabled
482 public function testApiCallWithJson()
486 'method' => 'method',
487 'func' => function () {
488 return ['data' => ['some_data']];
491 $_SERVER['REQUEST_METHOD'] = 'method';
492 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
494 $args = DI::args()->determine($_SERVER, $_GET);
498 api_call($this->app, $args)
503 * Test the api_call() function with an XML result.
505 * @runInSeparateProcess
506 * @preserveGlobalState disabled
508 public function testApiCallWithXml()
512 'method' => 'method',
513 'func' => function () {
517 $_SERVER['REQUEST_METHOD'] = 'method';
518 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
520 $args = DI::args()->determine($_SERVER, $_GET);
524 api_call($this->app, $args)
529 * Test the api_call() function with an RSS result.
531 * @runInSeparateProcess
532 * @preserveGlobalState disabled
534 public function testApiCallWithRss()
538 'method' => 'method',
539 'func' => function () {
543 $_SERVER['REQUEST_METHOD'] = 'method';
544 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
546 $args = DI::args()->determine($_SERVER, $_GET);
549 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
551 api_call($this->app, $args)
556 * Test the api_call() function with an Atom result.
558 * @runInSeparateProcess
559 * @preserveGlobalState disabled
561 public function testApiCallWithAtom()
565 'method' => 'method',
566 'func' => function () {
570 $_SERVER['REQUEST_METHOD'] = 'method';
571 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
573 $args = DI::args()->determine($_SERVER, $_GET);
576 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
578 api_call($this->app, $args)
583 * Test the api_rss_extra() function.
587 public function testApiRssExtra()
589 $user_info = ['url' => 'user_url', 'lang' => 'en'];
590 $result = api_rss_extra([], $user_info);
591 self::assertEquals($user_info, $result['$user']);
592 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
593 self::assertArrayHasKey('self', $result['$rss']);
594 self::assertArrayHasKey('base', $result['$rss']);
595 self::assertArrayHasKey('updated', $result['$rss']);
596 self::assertArrayHasKey('atom_updated', $result['$rss']);
597 self::assertArrayHasKey('language', $result['$rss']);
598 self::assertArrayHasKey('logo', $result['$rss']);
602 * Test the api_rss_extra() function without any user info.
606 public function testApiRssExtraWithoutUserInfo()
608 $result = api_rss_extra([], null);
609 self::assertIsArray($result['$user']);
610 self::assertArrayHasKey('alternate', $result['$rss']);
611 self::assertArrayHasKey('self', $result['$rss']);
612 self::assertArrayHasKey('base', $result['$rss']);
613 self::assertArrayHasKey('updated', $result['$rss']);
614 self::assertArrayHasKey('atom_updated', $result['$rss']);
615 self::assertArrayHasKey('language', $result['$rss']);
616 self::assertArrayHasKey('logo', $result['$rss']);
620 * Test the api_unique_id_to_nurl() function.
624 public function testApiUniqueIdToNurl()
626 self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
630 * Test the api_unique_id_to_nurl() function with a correct ID.
634 public function testApiUniqueIdToNurlWithCorrectId()
636 self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
640 * Test the api_get_user() function.
644 public function testApiGetUser()
646 // $user = api_get_user();
647 // self::assertSelfUser($user);
648 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
649 // self::assertEquals('6fdbe8', $user['profile_link_color']);
650 // self::assertEquals('ededed', $user['profile_background_color']);
654 * Test the api_get_user() function with a Frio schema.
658 public function testApiGetUserWithFrioSchema()
660 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
661 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
662 // $user = api_get_user();
663 // self::assertSelfUser($user);
664 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
665 // self::assertEquals('6fdbe8', $user['profile_link_color']);
666 // self::assertEquals('ededed', $user['profile_background_color']);
670 * Test the api_get_user() function with an empty Frio schema.
674 public function testApiGetUserWithEmptyFrioSchema()
676 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
677 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
678 // $user = api_get_user();
679 // self::assertSelfUser($user);
680 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
681 // self::assertEquals('6fdbe8', $user['profile_link_color']);
682 // self::assertEquals('ededed', $user['profile_background_color']);
686 * Test the api_get_user() function with a custom Frio schema.
690 public function testApiGetUserWithCustomFrioSchema()
692 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
693 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
694 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
695 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
696 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
697 // $user = api_get_user();
698 // self::assertSelfUser($user);
699 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
700 // self::assertEquals('123456', $user['profile_link_color']);
701 // self::assertEquals('123456', $user['profile_background_color']);
705 * Test the api_get_user() function with an user that is not allowed to use the API.
707 * @runInSeparateProcess
708 * @preserveGlobalState disabled
710 public function testApiGetUserWithoutApiUser()
712 // api_get_user() with empty parameters is not used anymore
714 $_SERVER['PHP_AUTH_USER'] = 'Test user';
715 $_SERVER['PHP_AUTH_PW'] = 'password';
716 BasicAuth::setCurrentUserID();
717 self::assertFalse(api_get_user());
722 * Test the api_get_user() function with an user ID in a GET parameter.
726 public function testApiGetUserWithGetId()
728 // self::assertOtherUser(api_get_user());
732 * Test the api_get_user() function with a wrong user ID in a GET parameter.
736 public function testApiGetUserWithWrongGetId()
738 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
739 // self::assertOtherUser(api_get_user());
743 * Test the api_get_user() function with an user name in a GET parameter.
747 public function testApiGetUserWithGetName()
749 // self::assertSelfUser(api_get_user());
753 * Test the api_get_user() function with a profile URL in a GET parameter.
757 public function testApiGetUserWithGetUrl()
759 // self::assertSelfUser(api_get_user());
763 * Test the api_get_user() function with an user ID in the API path.
767 public function testApiGetUserWithNumericCalledApi()
769 // global $called_api;
770 // $called_api = ['api_path'];
771 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
772 // self::assertOtherUser(api_get_user());
776 * Test the api_get_user() function with the $called_api global variable.
780 public function testApiGetUserWithCalledApi()
782 // global $called_api;
783 // $called_api = ['api', 'api_path'];
784 // self::assertSelfUser(api_get_user());
788 * Test the api_get_user() function with a valid user.
792 public function testApiGetUserWithCorrectUser()
794 self::assertOtherUser(api_get_user($this->otherUser['id']));
798 * Test the api_get_user() function with a wrong user ID.
802 public function testApiGetUserWithWrongUser()
804 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
805 self::assertOtherUser(api_get_user($this->wrongUserId));
809 * Test the api_get_user() function with a 0 user ID.
813 public function testApiGetUserWithZeroUser()
815 self::assertSelfUser(DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray());
819 * Test the api_item_get_user() function.
823 public function testApiItemGetUser()
825 $users = api_item_get_user($this->app, []);
826 self::assertSelfUser($users[0]);
830 * Test the api_item_get_user() function with a different item parent.
834 public function testApiItemGetUserWithDifferentParent()
836 $users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
837 self::assertSelfUser($users[0]);
838 self::assertEquals($users[0], $users[1]);
842 * Test the Arrays::walkRecursive() function.
846 public function testApiWalkRecursive()
851 Arrays::walkRecursive(
854 // Should we test this with a callback that actually does something?
862 * Test the Arrays::walkRecursive() function with an array.
866 public function testApiWalkRecursiveWithArray()
868 $array = [['item1'], ['item2']];
871 Arrays::walkRecursive(
874 // Should we test this with a callback that actually does something?
882 * Test the BaseApi::reformatXML() function.
886 public function testApiReformatXml()
890 self::assertTrue(ApiResponse::reformatXML($item, $key));
891 self::assertEquals('true', $item);
895 * Test the BaseApi::reformatXML() function with a statusnet_api key.
899 public function testApiReformatXmlWithStatusnetKey()
902 $key = 'statusnet_api';
903 self::assertTrue(ApiResponse::reformatXML($item, $key));
904 self::assertEquals('statusnet:api', $key);
908 * Test the BaseApi::reformatXML() function with a friendica_api key.
912 public function testApiReformatXmlWithFriendicaKey()
915 $key = 'friendica_api';
916 self::assertTrue(ApiResponse::reformatXML($item, $key));
917 self::assertEquals('friendica:api', $key);
921 * Test the BaseApi::createXML() function.
925 public function testApiCreateXml()
928 '<?xml version="1.0"?>' . "\n" .
929 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
930 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
931 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
932 ' <data>some_data</data>' . "\n" .
933 '</root_element>' . "\n",
934 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
939 * Test the BaseApi::createXML() function without any XML namespace.
943 public function testApiCreateXmlWithoutNamespaces()
946 '<?xml version="1.0"?>' . "\n" .
948 ' <data>some_data</data>' . "\n" .
950 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
955 * Test the BaseApi::formatData() function.
959 public function testApiFormatData()
961 $data = ['some_data'];
962 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
966 * Test the BaseApi::formatData() function with an XML result.
970 public function testApiFormatDataWithXml()
973 '<?xml version="1.0"?>' . "\n" .
974 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
975 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
976 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
977 ' <data>some_data</data>' . "\n" .
978 '</root_element>' . "\n",
979 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
984 * Test the api_account_verify_credentials() function.
988 public function testApiAccountVerifyCredentials()
990 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
994 * Test the api_account_verify_credentials() function without an authenticated user.
998 public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
1000 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1001 BasicAuth::setCurrentUserID();
1002 $_SESSION['authenticated'] = false;
1003 api_account_verify_credentials('json');
1007 * Test the requestdata() function.
1011 public function testRequestdata()
1013 self::assertNull(requestdata('variable_name'));
1017 * Test the requestdata() function with a POST parameter.
1021 public function testRequestdataWithPost()
1023 $_POST['variable_name'] = 'variable_value';
1024 self::assertEquals('variable_value', requestdata('variable_name'));
1028 * Test the requestdata() function with a GET parameter.
1032 public function testRequestdataWithGet()
1034 $_GET['variable_name'] = 'variable_value';
1035 self::assertEquals('variable_value', requestdata('variable_name'));
1039 * Test the api_statuses_mediap() function.
1043 public function testApiStatusesMediap()
1045 DI::args()->setArgc(2);
1053 'tmp_name' => $this->getTempImage(),
1054 'name' => 'spacer.png',
1055 'type' => 'image/png'
1058 $_GET['status'] = '<b>Status content</b>';
1060 $result = api_statuses_mediap('json');
1061 self::assertStatus($result['status']);
1065 * Test the api_statuses_mediap() function without an authenticated user.
1069 public function testApiStatusesMediapWithoutAuthenticatedUser()
1071 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1072 BasicAuth::setCurrentUserID();
1073 $_SESSION['authenticated'] = false;
1074 api_statuses_mediap('json');
1078 * Test the api_statuses_update() function.
1082 public function testApiStatusesUpdate()
1084 $_GET['status'] = 'Status content #friendica';
1085 $_GET['in_reply_to_status_id'] = -1;
1094 'tmp_name' => $this->getTempImage(),
1095 'name' => 'spacer.png',
1096 'type' => 'image/png'
1100 $result = api_statuses_update('json');
1101 self::assertStatus($result['status']);
1105 * Test the api_statuses_update() function with an HTML status.
1109 public function testApiStatusesUpdateWithHtml()
1111 $_GET['htmlstatus'] = '<b>Status content</b>';
1113 $result = api_statuses_update('json');
1114 self::assertStatus($result['status']);
1118 * Test the api_statuses_update() function without an authenticated user.
1122 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1124 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1125 BasicAuth::setCurrentUserID();
1126 $_SESSION['authenticated'] = false;
1127 api_statuses_update('json');
1131 * Test the api_statuses_update() function with a parent status.
1135 public function testApiStatusesUpdateWithParent()
1137 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1141 * Test the api_statuses_update() function with a media_ids parameter.
1145 public function testApiStatusesUpdateWithMediaIds()
1147 $this->markTestIncomplete();
1151 * Test the api_statuses_update() function with the throttle limit reached.
1155 public function testApiStatusesUpdateWithDayThrottleReached()
1157 $this->markTestIncomplete();
1161 * Test the api_media_upload() function.
1162 * @runInSeparateProcess
1163 * @preserveGlobalState disabled
1165 public function testApiMediaUpload()
1167 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1172 * Test the api_media_upload() function without an authenticated user.
1176 public function testApiMediaUploadWithoutAuthenticatedUser()
1178 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1179 BasicAuth::setCurrentUserID();
1180 $_SESSION['authenticated'] = false;
1185 * Test the api_media_upload() function with an invalid uploaded media.
1189 public function testApiMediaUploadWithMedia()
1191 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1195 'tmp_name' => 'tmp_name'
1202 * Test the api_media_upload() function with an valid uploaded media.
1206 public function testApiMediaUploadWithValidMedia()
1214 'tmp_name' => $this->getTempImage(),
1215 'name' => 'spacer.png',
1216 'type' => 'image/png'
1220 DI::args()->setArgc(2);
1222 $result = api_media_upload();
1223 self::assertEquals('image/png', $result['media']['image']['image_type']);
1224 self::assertEquals(1, $result['media']['image']['w']);
1225 self::assertEquals(1, $result['media']['image']['h']);
1226 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1230 * Test the api_status_show() function.
1232 public function testApiStatusShowWithJson()
1234 $result = api_status_show('json', 1);
1235 self::assertStatus($result['status']);
1239 * Test the api_status_show() function with an XML result.
1241 public function testApiStatusShowWithXml()
1243 $result = api_status_show('xml', 1);
1244 self::assertXml($result, 'statuses');
1248 * Test the api_get_last_status() function
1250 public function testApiGetLastStatus()
1252 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1254 self::assertNotNull($item);
1258 * Test the api_users_show() function.
1262 public function testApiUsersShow()
1264 $result = api_users_show('json');
1265 // We can't use assertSelfUser() here because the user object is missing some properties.
1266 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1267 self::assertEquals('DFRN', $result['user']['location']);
1268 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1269 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1270 self::assertEquals('dfrn', $result['user']['network']);
1271 self::assertTrue($result['user']['verified']);
1275 * Test the api_users_show() function with an XML result.
1279 public function testApiUsersShowWithXml()
1281 $result = api_users_show('xml');
1282 self::assertXml($result, 'statuses');
1286 * Test the api_users_search() function.
1290 public function testApiUsersSearch()
1292 $_GET['q'] = 'othercontact';
1293 $result = api_users_search('json');
1294 self::assertOtherUser($result['users'][0]);
1298 * Test the api_users_search() function with an XML result.
1302 public function testApiUsersSearchWithXml()
1304 $_GET['q'] = 'othercontact';
1305 $result = api_users_search('xml');
1306 self::assertXml($result, 'users');
1310 * Test the api_users_search() function without a GET q parameter.
1314 public function testApiUsersSearchWithoutQuery()
1316 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1317 api_users_search('json');
1321 * Test the api_users_lookup() function.
1325 public function testApiUsersLookup()
1327 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1328 api_users_lookup('json');
1332 * Test the api_users_lookup() function with an user ID.
1336 public function testApiUsersLookupWithUserId()
1338 $_REQUEST['user_id'] = $this->otherUser['id'];
1339 $result = api_users_lookup('json');
1340 self::assertOtherUser($result['users'][0]);
1344 * Test the api_search() function.
1348 public function testApiSearch()
1350 $_REQUEST['q'] = 'reply';
1351 $_REQUEST['max_id'] = 10;
1352 $result = api_search('json');
1353 foreach ($result['status'] as $status) {
1354 self::assertStatus($status);
1355 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1360 * Test the api_search() function a count parameter.
1364 public function testApiSearchWithCount()
1366 $_REQUEST['q'] = 'reply';
1367 $_REQUEST['count'] = 20;
1368 $result = api_search('json');
1369 foreach ($result['status'] as $status) {
1370 self::assertStatus($status);
1371 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1376 * Test the api_search() function with an rpp parameter.
1380 public function testApiSearchWithRpp()
1382 $_REQUEST['q'] = 'reply';
1383 $_REQUEST['rpp'] = 20;
1384 $result = api_search('json');
1385 foreach ($result['status'] as $status) {
1386 self::assertStatus($status);
1387 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1392 * Test the api_search() function with an q parameter contains hashtag.
1393 * @doesNotPerformAssertions
1395 public function testApiSearchWithHashtag()
1397 $_REQUEST['q'] = '%23friendica';
1398 $result = api_search('json');
1399 foreach ($result['status'] as $status) {
1400 self::assertStatus($status);
1401 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1406 * Test the api_search() function with an exclude_replies parameter.
1407 * @doesNotPerformAssertions
1409 public function testApiSearchWithExcludeReplies()
1411 $_REQUEST['max_id'] = 10;
1412 $_REQUEST['exclude_replies'] = true;
1413 $_REQUEST['q'] = 'friendica';
1414 $result = api_search('json');
1415 foreach ($result['status'] as $status) {
1416 self::assertStatus($status);
1421 * Test the api_search() function without an authenticated user.
1425 public function testApiSearchWithUnallowedUser()
1427 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1428 BasicAuth::setCurrentUserID();
1433 * Test the api_search() function without any GET query parameter.
1437 public function testApiSearchWithoutQuery()
1439 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1444 * Test the api_statuses_home_timeline() function.
1448 public function testApiStatusesHomeTimeline()
1450 $_REQUEST['max_id'] = 10;
1451 $_REQUEST['exclude_replies'] = true;
1452 $_REQUEST['conversation_id'] = 1;
1453 $result = api_statuses_home_timeline('json');
1454 self::assertNotEmpty($result['status']);
1455 foreach ($result['status'] as $status) {
1456 self::assertStatus($status);
1461 * Test the api_statuses_home_timeline() function with a negative page parameter.
1465 public function testApiStatusesHomeTimelineWithNegativePage()
1467 $_REQUEST['page'] = -2;
1468 $result = api_statuses_home_timeline('json');
1469 self::assertNotEmpty($result['status']);
1470 foreach ($result['status'] as $status) {
1471 self::assertStatus($status);
1476 * Test the api_statuses_home_timeline() with an unallowed user.
1480 public function testApiStatusesHomeTimelineWithUnallowedUser()
1482 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1483 BasicAuth::setCurrentUserID();
1484 api_statuses_home_timeline('json');
1488 * Test the api_statuses_home_timeline() function with an RSS result.
1492 public function testApiStatusesHomeTimelineWithRss()
1494 $result = api_statuses_home_timeline('rss');
1495 self::assertXml($result, 'statuses');
1499 * Test the api_statuses_public_timeline() function.
1503 public function testApiStatusesPublicTimeline()
1505 $_REQUEST['max_id'] = 10;
1506 $_REQUEST['conversation_id'] = 1;
1507 $result = api_statuses_public_timeline('json');
1508 self::assertNotEmpty($result['status']);
1509 foreach ($result['status'] as $status) {
1510 self::assertStatus($status);
1515 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1519 public function testApiStatusesPublicTimelineWithExcludeReplies()
1521 $_REQUEST['max_id'] = 10;
1522 $_REQUEST['exclude_replies'] = true;
1523 $result = api_statuses_public_timeline('json');
1524 self::assertNotEmpty($result['status']);
1525 foreach ($result['status'] as $status) {
1526 self::assertStatus($status);
1531 * Test the api_statuses_public_timeline() function with a negative page parameter.
1535 public function testApiStatusesPublicTimelineWithNegativePage()
1537 $_REQUEST['page'] = -2;
1538 $result = api_statuses_public_timeline('json');
1539 self::assertNotEmpty($result['status']);
1540 foreach ($result['status'] as $status) {
1541 self::assertStatus($status);
1546 * Test the api_statuses_public_timeline() function with an unallowed user.
1550 public function testApiStatusesPublicTimelineWithUnallowedUser()
1552 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1553 BasicAuth::setCurrentUserID();
1554 api_statuses_public_timeline('json');
1558 * Test the api_statuses_public_timeline() function with an RSS result.
1562 public function testApiStatusesPublicTimelineWithRss()
1564 $result = api_statuses_public_timeline('rss');
1565 self::assertXml($result, 'statuses');
1569 * Test the api_statuses_networkpublic_timeline() function.
1573 public function testApiStatusesNetworkpublicTimeline()
1575 $_REQUEST['max_id'] = 10;
1576 $result = api_statuses_networkpublic_timeline('json');
1577 self::assertNotEmpty($result['status']);
1578 foreach ($result['status'] as $status) {
1579 self::assertStatus($status);
1584 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1588 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1590 $_REQUEST['page'] = -2;
1591 $result = api_statuses_networkpublic_timeline('json');
1592 self::assertNotEmpty($result['status']);
1593 foreach ($result['status'] as $status) {
1594 self::assertStatus($status);
1599 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1603 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1605 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1606 BasicAuth::setCurrentUserID();
1607 api_statuses_networkpublic_timeline('json');
1611 * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1615 public function testApiStatusesNetworkpublicTimelineWithRss()
1617 $result = api_statuses_networkpublic_timeline('rss');
1618 self::assertXml($result, 'statuses');
1622 * Test the api_statuses_show() function.
1626 public function testApiStatusesShow()
1628 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1629 api_statuses_show('json');
1633 * Test the api_statuses_show() function with an ID.
1637 public function testApiStatusesShowWithId()
1639 DI::args()->setArgv(['', '', '', 1]);
1640 $result = api_statuses_show('json');
1641 self::assertStatus($result['status']);
1645 * Test the api_statuses_show() function with the conversation parameter.
1649 public function testApiStatusesShowWithConversation()
1651 DI::args()->setArgv(['', '', '', 1]);
1652 $_REQUEST['conversation'] = 1;
1653 $result = api_statuses_show('json');
1654 self::assertNotEmpty($result['status']);
1655 foreach ($result['status'] as $status) {
1656 self::assertStatus($status);
1661 * Test the api_statuses_show() function with an unallowed user.
1665 public function testApiStatusesShowWithUnallowedUser()
1667 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1668 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
1708 BasicAuth::setCurrentUserID();
1709 api_conversation_show('json');
1713 * Test the api_statuses_repeat() function.
1717 public function testApiStatusesRepeat()
1719 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1720 api_statuses_repeat('json');
1724 * Test the api_statuses_repeat() function without an authenticated user.
1728 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1730 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1731 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
1772 BasicAuth::setCurrentUserID();
1773 $_SESSION['authenticated'] = false;
1774 api_statuses_destroy('json');
1778 * Test the api_statuses_destroy() function with an ID.
1782 public function testApiStatusesDestroyWithId()
1784 DI::args()->setArgv(['', '', '', 1]);
1785 $result = api_statuses_destroy('json');
1786 self::assertStatus($result['status']);
1790 * Test the api_statuses_mentions() function.
1794 public function testApiStatusesMentions()
1796 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1797 $_REQUEST['max_id'] = 10;
1798 $result = api_statuses_mentions('json');
1799 self::assertEmpty($result['status']);
1800 // We should test with mentions in the database.
1804 * Test the api_statuses_mentions() function with a negative page parameter.
1808 public function testApiStatusesMentionsWithNegativePage()
1810 $_REQUEST['page'] = -2;
1811 $result = api_statuses_mentions('json');
1812 self::assertEmpty($result['status']);
1816 * Test the api_statuses_mentions() function with an unallowed user.
1820 public function testApiStatusesMentionsWithUnallowedUser()
1822 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1823 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
1889 BasicAuth::setCurrentUserID();
1890 api_statuses_user_timeline('json');
1894 * Test the api_favorites_create_destroy() function.
1898 public function testApiFavoritesCreateDestroy()
1900 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1901 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1902 api_favorites_create_destroy('json');
1906 * Test the api_favorites_create_destroy() function with an invalid ID.
1910 public function testApiFavoritesCreateDestroyWithInvalidId()
1912 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1913 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1914 api_favorites_create_destroy('json');
1918 * Test the api_favorites_create_destroy() function with an invalid action.
1922 public function testApiFavoritesCreateDestroyWithInvalidAction()
1924 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1925 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1926 $_REQUEST['id'] = 1;
1927 api_favorites_create_destroy('json');
1931 * Test the api_favorites_create_destroy() function with the create action.
1935 public function testApiFavoritesCreateDestroyWithCreateAction()
1937 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1938 $_REQUEST['id'] = 3;
1939 $result = api_favorites_create_destroy('json');
1940 self::assertStatus($result['status']);
1944 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1948 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1950 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1951 $_REQUEST['id'] = 3;
1952 $result = api_favorites_create_destroy('rss');
1953 self::assertXml($result, 'status');
1957 * Test the api_favorites_create_destroy() function with the destroy action.
1961 public function testApiFavoritesCreateDestroyWithDestroyAction()
1963 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1964 $_REQUEST['id'] = 3;
1965 $result = api_favorites_create_destroy('json');
1966 self::assertStatus($result['status']);
1970 * Test the api_favorites_create_destroy() function without an authenticated user.
1974 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1976 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1977 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1978 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
2017 BasicAuth::setCurrentUserID();
2018 api_favorites('json');
2022 * Test the api_format_messages() function.
2026 public function testApiFormatMessages()
2028 $result = api_format_messages(
2029 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2030 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2031 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
2033 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
2034 self::assertEquals(1, $result['id']);
2035 self::assertEquals(2, $result['recipient_id']);
2036 self::assertEquals(3, $result['sender_id']);
2037 self::assertEquals('recipient_name', $result['recipient_screen_name']);
2038 self::assertEquals('sender_name', $result['sender_screen_name']);
2042 * Test the api_format_messages() function with HTML.
2046 public function testApiFormatMessagesWithHtmlText()
2048 $_GET['getText'] = 'html';
2049 $result = api_format_messages(
2050 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2051 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2052 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2054 self::assertEquals('item_title', $result['title']);
2055 self::assertEquals('<strong>item_body</strong>', $result['text']);
2059 * Test the api_format_messages() function with plain text.
2063 public function testApiFormatMessagesWithPlainText()
2065 $_GET['getText'] = 'plain';
2066 $result = api_format_messages(
2067 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2068 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2069 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2071 self::assertEquals('item_title', $result['title']);
2072 self::assertEquals('item_body', $result['text']);
2076 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
2080 public function testApiFormatMessagesWithoutUserObjects()
2082 $_GET['getUserObjects'] = 'false';
2083 $result = api_format_messages(
2084 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2085 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2086 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2088 self::assertTrue(!isset($result['sender']));
2089 self::assertTrue(!isset($result['recipient']));
2093 * Test the api_convert_item() function.
2097 public function testApiConvertItem()
2099 $result = api_convert_item(
2101 'network' => 'feed',
2102 'title' => 'item_title',
2104 // We need a long string to test that it is correctly cut
2105 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2106 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2107 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2108 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2109 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2110 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2111 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2112 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2113 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2114 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2115 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2116 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2117 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2118 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2119 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2120 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2121 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2122 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2123 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2124 'repellat officia illum quos impedit quam iste esse unde qui ' .
2125 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2126 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2127 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2128 'plink' => 'item_plink'
2131 self::assertStringStartsWith('item_title', $result['text']);
2132 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2136 * Test the api_convert_item() function with an empty item body.
2140 public function testApiConvertItemWithoutBody()
2142 $result = api_convert_item(
2144 'network' => 'feed',
2145 'title' => 'item_title',
2148 'plink' => 'item_plink'
2151 self::assertEquals("item_title", $result['text']);
2152 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2156 * Test the api_convert_item() function with the title in the body.
2160 public function testApiConvertItemWithTitleInBody()
2162 $result = api_convert_item(
2164 'title' => 'item_title',
2165 'body' => 'item_title item_body',
2169 self::assertEquals('item_title item_body', $result['text']);
2170 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2174 * Test the api_get_attachments() function.
2178 public function testApiGetAttachments()
2181 self::assertEmpty(api_get_attachments($body, 0));
2185 * Test the api_get_attachments() function with an img tag.
2189 public function testApiGetAttachmentsWithImage()
2191 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2192 self::assertIsArray(api_get_attachments($body, 0));
2196 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2200 public function testApiGetAttachmentsWithImageAndAndStatus()
2202 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2203 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2204 self::assertIsArray(api_get_attachments($body, 0));
2208 * Test the api_get_entitities() function.
2212 public function testApiGetEntitities()
2215 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2219 * Test the api_get_entitities() function with the include_entities parameter.
2223 public function testApiGetEntititiesWithIncludeEntities()
2225 $_REQUEST['include_entities'] = 'true';
2227 $result = api_get_entitities($text, 'bbcode', 0);
2228 self::assertIsArray($result['hashtags']);
2229 self::assertIsArray($result['symbols']);
2230 self::assertIsArray($result['urls']);
2231 self::assertIsArray($result['user_mentions']);
2235 * Test the api_format_items_embeded_images() function.
2239 public function testApiFormatItemsEmbededImages()
2242 'text ' . DI::baseUrl() . '/display/item_guid',
2243 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2248 * Test the api_contactlink_to_array() function.
2252 public function testApiContactlinkToArray()
2259 api_contactlink_to_array('text')
2264 * Test the api_contactlink_to_array() function with an URL.
2268 public function testApiContactlinkToArrayWithUrl()
2272 'name' => ['link_text'],
2275 api_contactlink_to_array('text <a href="url">link_text</a>')
2280 * Test the api_format_items_activities() function.
2284 public function testApiFormatItemsActivities()
2286 $item = ['uid' => 0, 'uri' => ''];
2287 $result = api_format_items_activities($item);
2288 self::assertArrayHasKey('like', $result);
2289 self::assertArrayHasKey('dislike', $result);
2290 self::assertArrayHasKey('attendyes', $result);
2291 self::assertArrayHasKey('attendno', $result);
2292 self::assertArrayHasKey('attendmaybe', $result);
2296 * Test the api_format_items_activities() function with an XML result.
2300 public function testApiFormatItemsActivitiesWithXml()
2302 $item = ['uid' => 0, 'uri' => ''];
2303 $result = api_format_items_activities($item, 'xml');
2304 self::assertArrayHasKey('friendica:like', $result);
2305 self::assertArrayHasKey('friendica:dislike', $result);
2306 self::assertArrayHasKey('friendica:attendyes', $result);
2307 self::assertArrayHasKey('friendica:attendno', $result);
2308 self::assertArrayHasKey('friendica:attendmaybe', $result);
2312 * Test the api_format_items() function.
2313 * @doesNotPerformAssertions
2315 public function testApiFormatItems()
2319 'item_network' => 'item_network',
2325 'author-network' => Protocol::DFRN,
2326 'author-link' => 'http://localhost/profile/othercontact',
2330 $result = api_format_items($items, ['id' => 0], true);
2331 foreach ($result as $status) {
2332 self::assertStatus($status);
2337 * Test the api_format_items() function with an XML result.
2338 * @doesNotPerformAssertions
2340 public function testApiFormatItemsWithXml()
2348 'author-network' => Protocol::DFRN,
2349 'author-link' => 'http://localhost/profile/othercontact',
2353 $result = api_format_items($items, ['id' => 0], true, 'xml');
2354 foreach ($result as $status) {
2355 self::assertStatus($status);
2360 * Test the api_lists_list() function.
2364 public function testApiListsList()
2366 $result = api_lists_list('json');
2367 self::assertEquals(['lists_list' => []], $result);
2371 * Test the api_lists_ownerships() function.
2375 public function testApiListsOwnerships()
2377 $result = api_lists_ownerships('json');
2378 foreach ($result['lists']['lists'] as $list) {
2379 self::assertList($list);
2384 * Test the api_lists_ownerships() function without an authenticated user.
2388 public function testApiListsOwnershipsWithoutAuthenticatedUser()
2390 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2391 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
2442 BasicAuth::setCurrentUserID();
2443 api_lists_statuses('json');
2447 * Test the api_statuses_f() function.
2451 public function testApiStatusesFWithFriends()
2454 $result = api_statuses_f('friends');
2455 self::assertArrayHasKey('user', $result);
2459 * Test the api_statuses_f() function.
2463 public function testApiStatusesFWithFollowers()
2465 $result = api_statuses_f('followers');
2466 self::assertArrayHasKey('user', $result);
2470 * Test the api_statuses_f() function.
2474 public function testApiStatusesFWithBlocks()
2476 $result = api_statuses_f('blocks');
2477 self::assertArrayHasKey('user', $result);
2481 * Test the api_statuses_f() function.
2485 public function testApiStatusesFWithIncoming()
2487 $result = api_statuses_f('incoming');
2488 self::assertArrayHasKey('user', $result);
2492 * Test the api_statuses_f() function an undefined cursor GET variable.
2496 public function testApiStatusesFWithUndefinedCursor()
2498 $_GET['cursor'] = 'undefined';
2499 self::assertFalse(api_statuses_f('friends'));
2503 * Test the api_statuses_friends() function.
2507 public function testApiStatusesFriends()
2509 $result = api_statuses_friends('json');
2510 self::assertArrayHasKey('user', $result);
2514 * Test the api_statuses_friends() function an undefined cursor GET variable.
2518 public function testApiStatusesFriendsWithUndefinedCursor()
2520 $_GET['cursor'] = 'undefined';
2521 self::assertFalse(api_statuses_friends('json'));
2525 * Test the api_statuses_followers() function.
2529 public function testApiStatusesFollowers()
2531 $result = api_statuses_followers('json');
2532 self::assertArrayHasKey('user', $result);
2536 * Test the api_statuses_followers() function an undefined cursor GET variable.
2540 public function testApiStatusesFollowersWithUndefinedCursor()
2542 $_GET['cursor'] = 'undefined';
2543 self::assertFalse(api_statuses_followers('json'));
2547 * Test the api_blocks_list() function.
2551 public function testApiBlocksList()
2553 $result = api_blocks_list('json');
2554 self::assertArrayHasKey('user', $result);
2558 * Test the api_blocks_list() function an undefined cursor GET variable.
2562 public function testApiBlocksListWithUndefinedCursor()
2564 $_GET['cursor'] = 'undefined';
2565 self::assertFalse(api_blocks_list('json'));
2569 * Test the api_friendships_incoming() function.
2573 public function testApiFriendshipsIncoming()
2575 $result = api_friendships_incoming('json');
2576 self::assertArrayHasKey('id', $result);
2580 * Test the api_friendships_incoming() function an undefined cursor GET variable.
2584 public function testApiFriendshipsIncomingWithUndefinedCursor()
2586 $_GET['cursor'] = 'undefined';
2587 self::assertFalse(api_friendships_incoming('json'));
2591 * Test the api_statusnet_config() function.
2595 public function testApiStatusnetConfig()
2598 $result = api_statusnet_config('json');
2599 self::assertEquals('localhost', $result['config']['site']['server']);
2600 self::assertEquals('default', $result['config']['site']['theme']);
2601 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2602 self::assertTrue($result['config']['site']['fancy']);
2603 self::assertEquals('en', $result['config']['site']['language']);
2604 self::assertEquals('UTC', $result['config']['site']['timezone']);
2605 self::assertEquals(200000, $result['config']['site']['textlimit']);
2606 self::assertEquals('false', $result['config']['site']['private']);
2607 self::assertEquals('false', $result['config']['site']['ssl']);
2608 self::assertEquals(30, $result['config']['site']['shorturllength']);
2613 * Test the api_direct_messages_new() function.
2617 public function testApiDirectMessagesNew()
2619 $result = api_direct_messages_new('json');
2620 self::assertNull($result);
2624 * Test the api_direct_messages_new() function without an authenticated user.
2628 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2630 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2631 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
2736 BasicAuth::setCurrentUserID();
2737 $_SESSION['authenticated'] = false;
2738 api_direct_messages_destroy('json');
2742 * Test the api_direct_messages_destroy() function with a non-zero ID.
2746 public function testApiDirectMessagesDestroyWithId()
2748 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2749 $_REQUEST['id'] = 1;
2750 api_direct_messages_destroy('json');
2754 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2758 public function testApiDirectMessagesDestroyWithIdAndVerbose()
2760 $_REQUEST['id'] = 1;
2761 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2762 $_GET['friendica_verbose'] = 'true';
2763 $result = api_direct_messages_destroy('json');
2767 'result' => 'error',
2768 'message' => 'message id not in database'
2776 * Test the api_direct_messages_destroy() function with a non-zero ID.
2780 public function testApiDirectMessagesDestroyWithCorrectId()
2782 $this->markTestIncomplete('We need to add a dataset for this.');
2786 * Test the api_direct_messages_box() function.
2790 public function testApiDirectMessagesBoxWithSentbox()
2792 $_REQUEST['page'] = -1;
2793 $_REQUEST['max_id'] = 10;
2794 $result = api_direct_messages_box('json', 'sentbox', 'false');
2795 self::assertArrayHasKey('direct_message', $result);
2799 * Test the api_direct_messages_box() function.
2803 public function testApiDirectMessagesBoxWithConversation()
2805 $result = api_direct_messages_box('json', 'conversation', 'false');
2806 self::assertArrayHasKey('direct_message', $result);
2810 * Test the api_direct_messages_box() function.
2814 public function testApiDirectMessagesBoxWithAll()
2816 $result = api_direct_messages_box('json', 'all', 'false');
2817 self::assertArrayHasKey('direct_message', $result);
2821 * Test the api_direct_messages_box() function.
2825 public function testApiDirectMessagesBoxWithInbox()
2827 $result = api_direct_messages_box('json', 'inbox', 'false');
2828 self::assertArrayHasKey('direct_message', $result);
2832 * Test the api_direct_messages_box() function.
2836 public function testApiDirectMessagesBoxWithVerbose()
2838 $result = api_direct_messages_box('json', 'sentbox', 'true');
2842 'result' => 'error',
2843 'message' => 'no mails available'
2851 * Test the api_direct_messages_box() function with a RSS result.
2855 public function testApiDirectMessagesBoxWithRss()
2857 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2858 self::assertXml($result, 'direct-messages');
2862 * Test the api_direct_messages_box() function without an authenticated user.
2866 public function testApiDirectMessagesBoxWithUnallowedUser()
2868 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2869 BasicAuth::setCurrentUserID();
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\UnauthorizedException::class);
2956 BasicAuth::setCurrentUserID();
2957 $_SESSION['authenticated'] = false;
2958 api_fr_photos_list('json');
2962 * Test the api_fr_photo_create_update() function.
2964 public function testApiFrPhotoCreateUpdate()
2966 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2967 api_fr_photo_create_update('json');
2971 * Test the api_fr_photo_create_update() function without an authenticated user.
2975 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2977 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2978 BasicAuth::setCurrentUserID();
2979 $_SESSION['authenticated'] = false;
2980 api_fr_photo_create_update('json');
2984 * Test the api_fr_photo_create_update() function with an album name.
2988 public function testApiFrPhotoCreateUpdateWithAlbum()
2990 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2991 $_REQUEST['album'] = 'album_name';
2992 api_fr_photo_create_update('json');
2996 * Test the api_fr_photo_create_update() function with the update mode.
3000 public function testApiFrPhotoCreateUpdateWithUpdate()
3002 $this->markTestIncomplete('We need to create a dataset for this');
3006 * Test the api_fr_photo_create_update() function with an uploaded file.
3010 public function testApiFrPhotoCreateUpdateWithFile()
3012 $this->markTestIncomplete();
3016 * Test the api_fr_photo_detail() function.
3020 public function testApiFrPhotoDetail()
3022 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3023 api_fr_photo_detail('json');
3027 * Test the api_fr_photo_detail() function without an authenticated user.
3031 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
3033 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
3034 BasicAuth::setCurrentUserID();
3035 $_SESSION['authenticated'] = false;
3036 api_fr_photo_detail('json');
3040 * Test the api_fr_photo_detail() function with a photo ID.
3044 public function testApiFrPhotoDetailWithPhotoId()
3046 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
3047 $_REQUEST['photo_id'] = 1;
3048 api_fr_photo_detail('json');
3052 * Test the api_fr_photo_detail() function with a correct photo ID.
3056 public function testApiFrPhotoDetailCorrectPhotoId()
3058 $this->markTestIncomplete('We need to create a dataset for this.');
3062 * Test the api_account_update_profile_image() function.
3066 public function testApiAccountUpdateProfileImage()
3068 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3069 api_account_update_profile_image('json');
3073 * Test the api_account_update_profile_image() function without an authenticated user.
3077 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
3079 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
3080 BasicAuth::setCurrentUserID();
3081 $_SESSION['authenticated'] = false;
3082 api_account_update_profile_image('json');
3086 * Test the api_account_update_profile_image() function with an uploaded file.
3090 public function testApiAccountUpdateProfileImageWithUpload()
3092 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3093 $this->markTestIncomplete();
3098 * Test the api_account_update_profile() function.
3102 public function testApiAccountUpdateProfile()
3104 $_POST['name'] = 'new_name';
3105 $_POST['description'] = 'new_description';
3106 $result = api_account_update_profile('json');
3107 // We can't use assertSelfUser() here because the user object is missing some properties.
3108 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
3109 self::assertEquals('DFRN', $result['user']['location']);
3110 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
3111 self::assertEquals('dfrn', $result['user']['network']);
3112 self::assertEquals('new_name', $result['user']['name']);
3113 self::assertEquals('new_description', $result['user']['description']);
3117 * Test the check_acl_input() function.
3121 public function testCheckAclInput()
3123 $result = check_acl_input('<aclstring>');
3124 // Where does this result come from?
3125 self::assertEquals(1, $result);
3129 * Test the check_acl_input() function with an empty ACL string.
3133 public function testCheckAclInputWithEmptyAclString()
3135 $result = check_acl_input(' ');
3136 self::assertFalse($result);
3140 * Test the save_media_to_database() function.
3144 public function testSaveMediaToDatabase()
3146 $this->markTestIncomplete();
3150 * Test the post_photo_item() function.
3154 public function testPostPhotoItem()
3156 $this->markTestIncomplete();
3160 * Test the prepare_photo_data() function.
3164 public function testPreparePhotoData()
3166 $this->markTestIncomplete();
3170 * Test the api_share_as_retweet() function with a valid item.
3174 public function testApiShareAsRetweetWithValidItem()
3176 $this->markTestIncomplete();
3180 * Test the api_in_reply_to() function.
3184 public function testApiInReplyTo()
3186 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3187 self::assertArrayHasKey('status_id', $result);
3188 self::assertArrayHasKey('user_id', $result);
3189 self::assertArrayHasKey('status_id_str', $result);
3190 self::assertArrayHasKey('user_id_str', $result);
3191 self::assertArrayHasKey('screen_name', $result);
3195 * Test the api_in_reply_to() function with a valid item.
3199 public function testApiInReplyToWithValidItem()
3201 $this->markTestIncomplete();
3205 * Test the api_clean_plain_items() function.
3209 public function testApiCleanPlainItems()
3211 $_REQUEST['include_entities'] = 'true';
3212 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3213 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3217 * Test the api_best_nickname() function.
3221 public function testApiBestNickname()
3224 $result = api_best_nickname($contacts);
3225 self::assertNull($result);
3229 * Test the api_best_nickname() function with contacts.
3233 public function testApiBestNicknameWithContacts()
3235 $this->markTestIncomplete();
3239 * Test the api_friendica_group_show() function.
3243 public function testApiFriendicaGroupShow()
3245 $this->markTestIncomplete();
3249 * Test the api_friendica_group_delete() function.
3253 public function testApiFriendicaGroupDelete()
3255 $this->markTestIncomplete();
3259 * Test the api_lists_destroy() function.
3263 public function testApiListsDestroy()
3265 $this->markTestIncomplete();
3269 * Test the group_create() function.
3273 public function testGroupCreate()
3275 $this->markTestIncomplete();
3279 * Test the api_friendica_group_create() function.
3283 public function testApiFriendicaGroupCreate()
3285 $this->markTestIncomplete();
3289 * Test the api_lists_create() function.
3293 public function testApiListsCreate()
3295 $this->markTestIncomplete();
3299 * Test the api_friendica_group_update() function.
3303 public function testApiFriendicaGroupUpdate()
3305 $this->markTestIncomplete();
3309 * Test the api_lists_update() function.
3313 public function testApiListsUpdate()
3315 $this->markTestIncomplete();
3319 * Test the api_friendica_activity() function.
3323 public function testApiFriendicaActivity()
3325 $this->markTestIncomplete();
3329 * Test the api_friendica_notification_seen() function.
3333 public function testApiFriendicaNotificationSeen()
3335 $this->markTestIncomplete();
3339 * Test the api_friendica_direct_messages_setseen() function.
3343 public function testApiFriendicaDirectMessagesSetseen()
3345 $this->markTestIncomplete();
3349 * Test the api_friendica_direct_messages_search() function.
3353 public function testApiFriendicaDirectMessagesSearch()
3355 $this->markTestIncomplete();