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 BasicAuth::setCurrentUserID();
1072 api_statuses_mediap('json');
1076 * Test the api_statuses_update() function.
1080 public function testApiStatusesUpdate()
1082 $_GET['status'] = 'Status content #friendica';
1083 $_GET['in_reply_to_status_id'] = -1;
1092 'tmp_name' => $this->getTempImage(),
1093 'name' => 'spacer.png',
1094 'type' => 'image/png'
1098 $result = api_statuses_update('json');
1099 self::assertStatus($result['status']);
1103 * Test the api_statuses_update() function with an HTML status.
1107 public function testApiStatusesUpdateWithHtml()
1109 $_GET['htmlstatus'] = '<b>Status content</b>';
1111 $result = api_statuses_update('json');
1112 self::assertStatus($result['status']);
1116 * Test the api_statuses_update() function without an authenticated user.
1120 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1122 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1123 $_SESSION['authenticated'] = false;
1124 api_statuses_update('json');
1128 * Test the api_statuses_update() function with a parent status.
1132 public function testApiStatusesUpdateWithParent()
1134 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1138 * Test the api_statuses_update() function with a media_ids parameter.
1142 public function testApiStatusesUpdateWithMediaIds()
1144 $this->markTestIncomplete();
1148 * Test the api_statuses_update() function with the throttle limit reached.
1152 public function testApiStatusesUpdateWithDayThrottleReached()
1154 $this->markTestIncomplete();
1158 * Test the api_media_upload() function.
1159 * @runInSeparateProcess
1160 * @preserveGlobalState disabled
1162 public function testApiMediaUpload()
1164 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1169 * Test the api_media_upload() function without an authenticated user.
1173 public function testApiMediaUploadWithoutAuthenticatedUser()
1175 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1176 $_SESSION['authenticated'] = false;
1181 * Test the api_media_upload() function with an invalid uploaded media.
1185 public function testApiMediaUploadWithMedia()
1187 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1191 'tmp_name' => 'tmp_name'
1198 * Test the api_media_upload() function with an valid uploaded media.
1202 public function testApiMediaUploadWithValidMedia()
1210 'tmp_name' => $this->getTempImage(),
1211 'name' => 'spacer.png',
1212 'type' => 'image/png'
1216 DI::args()->setArgc(2);
1218 $result = api_media_upload();
1219 self::assertEquals('image/png', $result['media']['image']['image_type']);
1220 self::assertEquals(1, $result['media']['image']['w']);
1221 self::assertEquals(1, $result['media']['image']['h']);
1222 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1226 * Test the api_status_show() function.
1228 public function testApiStatusShowWithJson()
1230 $result = api_status_show('json', 1);
1231 self::assertStatus($result['status']);
1235 * Test the api_status_show() function with an XML result.
1237 public function testApiStatusShowWithXml()
1239 $result = api_status_show('xml', 1);
1240 self::assertXml($result, 'statuses');
1244 * Test the api_get_last_status() function
1246 public function testApiGetLastStatus()
1248 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1250 self::assertNotNull($item);
1254 * Test the api_users_show() function.
1258 public function testApiUsersShow()
1260 $result = api_users_show('json');
1261 // We can't use assertSelfUser() here because the user object is missing some properties.
1262 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1263 self::assertEquals('DFRN', $result['user']['location']);
1264 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1265 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1266 self::assertEquals('dfrn', $result['user']['network']);
1267 self::assertTrue($result['user']['verified']);
1271 * Test the api_users_show() function with an XML result.
1275 public function testApiUsersShowWithXml()
1277 $result = api_users_show('xml');
1278 self::assertXml($result, 'statuses');
1282 * Test the api_users_search() function.
1286 public function testApiUsersSearch()
1288 $_GET['q'] = 'othercontact';
1289 $result = api_users_search('json');
1290 self::assertOtherUser($result['users'][0]);
1294 * Test the api_users_search() function with an XML result.
1298 public function testApiUsersSearchWithXml()
1300 $_GET['q'] = 'othercontact';
1301 $result = api_users_search('xml');
1302 self::assertXml($result, 'users');
1306 * Test the api_users_search() function without a GET q parameter.
1310 public function testApiUsersSearchWithoutQuery()
1312 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1313 api_users_search('json');
1317 * Test the api_users_lookup() function.
1321 public function testApiUsersLookup()
1323 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1324 api_users_lookup('json');
1328 * Test the api_users_lookup() function with an user ID.
1332 public function testApiUsersLookupWithUserId()
1334 $_REQUEST['user_id'] = $this->otherUser['id'];
1335 $result = api_users_lookup('json');
1336 self::assertOtherUser($result['users'][0]);
1340 * Test the api_search() function.
1344 public function testApiSearch()
1346 $_REQUEST['q'] = 'reply';
1347 $_REQUEST['max_id'] = 10;
1348 $result = api_search('json');
1349 foreach ($result['status'] as $status) {
1350 self::assertStatus($status);
1351 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1356 * Test the api_search() function a count parameter.
1360 public function testApiSearchWithCount()
1362 $_REQUEST['q'] = 'reply';
1363 $_REQUEST['count'] = 20;
1364 $result = api_search('json');
1365 foreach ($result['status'] as $status) {
1366 self::assertStatus($status);
1367 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1372 * Test the api_search() function with an rpp parameter.
1376 public function testApiSearchWithRpp()
1378 $_REQUEST['q'] = 'reply';
1379 $_REQUEST['rpp'] = 20;
1380 $result = api_search('json');
1381 foreach ($result['status'] as $status) {
1382 self::assertStatus($status);
1383 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1388 * Test the api_search() function with an q parameter contains hashtag.
1389 * @doesNotPerformAssertions
1391 public function testApiSearchWithHashtag()
1393 $_REQUEST['q'] = '%23friendica';
1394 $result = api_search('json');
1395 foreach ($result['status'] as $status) {
1396 self::assertStatus($status);
1397 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1402 * Test the api_search() function with an exclude_replies parameter.
1403 * @doesNotPerformAssertions
1405 public function testApiSearchWithExcludeReplies()
1407 $_REQUEST['max_id'] = 10;
1408 $_REQUEST['exclude_replies'] = true;
1409 $_REQUEST['q'] = 'friendica';
1410 $result = api_search('json');
1411 foreach ($result['status'] as $status) {
1412 self::assertStatus($status);
1417 * Test the api_search() function without an authenticated user.
1421 public function testApiSearchWithUnallowedUser()
1423 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1424 $_SESSION['allow_api'] = false;
1425 $_GET['screen_name'] = $this->selfUser['nick'];
1430 * Test the api_search() function without any GET query parameter.
1434 public function testApiSearchWithoutQuery()
1436 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1441 * Test the api_statuses_home_timeline() function.
1445 public function testApiStatusesHomeTimeline()
1447 $_REQUEST['max_id'] = 10;
1448 $_REQUEST['exclude_replies'] = true;
1449 $_REQUEST['conversation_id'] = 1;
1450 $result = api_statuses_home_timeline('json');
1451 self::assertNotEmpty($result['status']);
1452 foreach ($result['status'] as $status) {
1453 self::assertStatus($status);
1458 * Test the api_statuses_home_timeline() function with a negative page parameter.
1462 public function testApiStatusesHomeTimelineWithNegativePage()
1464 $_REQUEST['page'] = -2;
1465 $result = api_statuses_home_timeline('json');
1466 self::assertNotEmpty($result['status']);
1467 foreach ($result['status'] as $status) {
1468 self::assertStatus($status);
1473 * Test the api_statuses_home_timeline() with an unallowed user.
1477 public function testApiStatusesHomeTimelineWithUnallowedUser()
1479 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1480 $_SESSION['allow_api'] = false;
1481 $_GET['screen_name'] = $this->selfUser['nick'];
1482 api_statuses_home_timeline('json');
1486 * Test the api_statuses_home_timeline() function with an RSS result.
1490 public function testApiStatusesHomeTimelineWithRss()
1492 $result = api_statuses_home_timeline('rss');
1493 self::assertXml($result, 'statuses');
1497 * Test the api_statuses_public_timeline() function.
1501 public function testApiStatusesPublicTimeline()
1503 $_REQUEST['max_id'] = 10;
1504 $_REQUEST['conversation_id'] = 1;
1505 $result = api_statuses_public_timeline('json');
1506 self::assertNotEmpty($result['status']);
1507 foreach ($result['status'] as $status) {
1508 self::assertStatus($status);
1513 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1517 public function testApiStatusesPublicTimelineWithExcludeReplies()
1519 $_REQUEST['max_id'] = 10;
1520 $_REQUEST['exclude_replies'] = true;
1521 $result = api_statuses_public_timeline('json');
1522 self::assertNotEmpty($result['status']);
1523 foreach ($result['status'] as $status) {
1524 self::assertStatus($status);
1529 * Test the api_statuses_public_timeline() function with a negative page parameter.
1533 public function testApiStatusesPublicTimelineWithNegativePage()
1535 $_REQUEST['page'] = -2;
1536 $result = api_statuses_public_timeline('json');
1537 self::assertNotEmpty($result['status']);
1538 foreach ($result['status'] as $status) {
1539 self::assertStatus($status);
1544 * Test the api_statuses_public_timeline() function with an unallowed user.
1548 public function testApiStatusesPublicTimelineWithUnallowedUser()
1550 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1551 $_SESSION['allow_api'] = false;
1552 $_GET['screen_name'] = $this->selfUser['nick'];
1553 api_statuses_public_timeline('json');
1557 * Test the api_statuses_public_timeline() function with an RSS result.
1561 public function testApiStatusesPublicTimelineWithRss()
1563 $result = api_statuses_public_timeline('rss');
1564 self::assertXml($result, 'statuses');
1568 * Test the api_statuses_networkpublic_timeline() function.
1572 public function testApiStatusesNetworkpublicTimeline()
1574 $_REQUEST['max_id'] = 10;
1575 $result = api_statuses_networkpublic_timeline('json');
1576 self::assertNotEmpty($result['status']);
1577 foreach ($result['status'] as $status) {
1578 self::assertStatus($status);
1583 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1587 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1589 $_REQUEST['page'] = -2;
1590 $result = api_statuses_networkpublic_timeline('json');
1591 self::assertNotEmpty($result['status']);
1592 foreach ($result['status'] as $status) {
1593 self::assertStatus($status);
1598 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1602 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1604 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1605 $_SESSION['allow_api'] = false;
1606 $_GET['screen_name'] = $this->selfUser['nick'];
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\ForbiddenException::class);
1668 $_SESSION['allow_api'] = false;
1669 $_GET['screen_name'] = $this->selfUser['nick'];
1670 api_statuses_show('json');
1674 * Test the api_conversation_show() function.
1678 public function testApiConversationShow()
1680 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1681 api_conversation_show('json');
1685 * Test the api_conversation_show() function with an ID.
1689 public function testApiConversationShowWithId()
1691 DI::args()->setArgv(['', '', '', 1]);
1692 $_REQUEST['max_id'] = 10;
1693 $_REQUEST['page'] = -2;
1694 $result = api_conversation_show('json');
1695 self::assertNotEmpty($result['status']);
1696 foreach ($result['status'] as $status) {
1697 self::assertStatus($status);
1702 * Test the api_conversation_show() function with an unallowed user.
1706 public function testApiConversationShowWithUnallowedUser()
1708 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1709 $_SESSION['allow_api'] = false;
1710 $_GET['screen_name'] = $this->selfUser['nick'];
1711 api_conversation_show('json');
1715 * Test the api_statuses_repeat() function.
1719 public function testApiStatusesRepeat()
1721 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1722 api_statuses_repeat('json');
1726 * Test the api_statuses_repeat() function without an authenticated user.
1730 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1732 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1733 $_SESSION['authenticated'] = false;
1734 api_statuses_repeat('json');
1738 * Test the api_statuses_repeat() function with an ID.
1742 public function testApiStatusesRepeatWithId()
1744 DI::args()->setArgv(['', '', '', 1]);
1745 $result = api_statuses_repeat('json');
1746 self::assertStatus($result['status']);
1748 // Also test with a shared status
1749 DI::args()->setArgv(['', '', '', 5]);
1750 $result = api_statuses_repeat('json');
1751 self::assertStatus($result['status']);
1755 * Test the api_statuses_destroy() function.
1759 public function testApiStatusesDestroy()
1761 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1762 api_statuses_destroy('json');
1766 * Test the api_statuses_destroy() function without an authenticated user.
1770 public function testApiStatusesDestroyWithoutAuthenticatedUser()
1772 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
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\ForbiddenException::class);
1823 $_SESSION['allow_api'] = false;
1824 $_GET['screen_name'] = $this->selfUser['nick'];
1825 api_statuses_mentions('json');
1829 * Test the api_statuses_mentions() function with an RSS result.
1833 public function testApiStatusesMentionsWithRss()
1835 $result = api_statuses_mentions('rss');
1836 self::assertXml($result, 'statuses');
1840 * Test the api_statuses_user_timeline() function.
1844 public function testApiStatusesUserTimeline()
1846 $_REQUEST['max_id'] = 10;
1847 $_REQUEST['exclude_replies'] = true;
1848 $_REQUEST['conversation_id'] = 1;
1849 $result = api_statuses_user_timeline('json');
1850 self::assertNotEmpty($result['status']);
1851 foreach ($result['status'] as $status) {
1852 self::assertStatus($status);
1857 * Test the api_statuses_user_timeline() function with a negative page parameter.
1861 public function testApiStatusesUserTimelineWithNegativePage()
1863 $_REQUEST['page'] = -2;
1864 $result = api_statuses_user_timeline('json');
1865 self::assertNotEmpty($result['status']);
1866 foreach ($result['status'] as $status) {
1867 self::assertStatus($status);
1872 * Test the api_statuses_user_timeline() function with an RSS result.
1876 public function testApiStatusesUserTimelineWithRss()
1878 $result = api_statuses_user_timeline('rss');
1879 self::assertXml($result, 'statuses');
1883 * Test the api_statuses_user_timeline() function with an unallowed user.
1887 public function testApiStatusesUserTimelineWithUnallowedUser()
1889 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1890 $_SESSION['allow_api'] = false;
1891 $_GET['screen_name'] = $this->selfUser['nick'];
1892 api_statuses_user_timeline('json');
1896 * Test the api_favorites_create_destroy() function.
1900 public function testApiFavoritesCreateDestroy()
1902 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1903 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1904 api_favorites_create_destroy('json');
1908 * Test the api_favorites_create_destroy() function with an invalid ID.
1912 public function testApiFavoritesCreateDestroyWithInvalidId()
1914 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1915 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1916 api_favorites_create_destroy('json');
1920 * Test the api_favorites_create_destroy() function with an invalid action.
1924 public function testApiFavoritesCreateDestroyWithInvalidAction()
1926 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1927 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1928 $_REQUEST['id'] = 1;
1929 api_favorites_create_destroy('json');
1933 * Test the api_favorites_create_destroy() function with the create action.
1937 public function testApiFavoritesCreateDestroyWithCreateAction()
1939 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1940 $_REQUEST['id'] = 3;
1941 $result = api_favorites_create_destroy('json');
1942 self::assertStatus($result['status']);
1946 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1950 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1952 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1953 $_REQUEST['id'] = 3;
1954 $result = api_favorites_create_destroy('rss');
1955 self::assertXml($result, 'status');
1959 * Test the api_favorites_create_destroy() function with the destroy action.
1963 public function testApiFavoritesCreateDestroyWithDestroyAction()
1965 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1966 $_REQUEST['id'] = 3;
1967 $result = api_favorites_create_destroy('json');
1968 self::assertStatus($result['status']);
1972 * Test the api_favorites_create_destroy() function without an authenticated user.
1976 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1978 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1979 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1980 $_SESSION['authenticated'] = false;
1981 api_favorites_create_destroy('json');
1985 * Test the api_favorites() function.
1989 public function testApiFavorites()
1991 $_REQUEST['page'] = -1;
1992 $_REQUEST['max_id'] = 10;
1993 $result = api_favorites('json');
1994 foreach ($result['status'] as $status) {
1995 self::assertStatus($status);
2000 * Test the api_favorites() function with an RSS result.
2004 public function testApiFavoritesWithRss()
2006 $result = api_favorites('rss');
2007 self::assertXml($result, 'statuses');
2011 * Test the api_favorites() function with an unallowed user.
2015 public function testApiFavoritesWithUnallowedUser()
2017 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2018 $_SESSION['allow_api'] = false;
2019 $_GET['screen_name'] = $this->selfUser['nick'];
2020 api_favorites('json');
2024 * Test the api_format_messages() function.
2028 public function testApiFormatMessages()
2030 $result = api_format_messages(
2031 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2032 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2033 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
2035 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
2036 self::assertEquals(1, $result['id']);
2037 self::assertEquals(2, $result['recipient_id']);
2038 self::assertEquals(3, $result['sender_id']);
2039 self::assertEquals('recipient_name', $result['recipient_screen_name']);
2040 self::assertEquals('sender_name', $result['sender_screen_name']);
2044 * Test the api_format_messages() function with HTML.
2048 public function testApiFormatMessagesWithHtmlText()
2050 $_GET['getText'] = 'html';
2051 $result = api_format_messages(
2052 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2053 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2054 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2056 self::assertEquals('item_title', $result['title']);
2057 self::assertEquals('<strong>item_body</strong>', $result['text']);
2061 * Test the api_format_messages() function with plain text.
2065 public function testApiFormatMessagesWithPlainText()
2067 $_GET['getText'] = 'plain';
2068 $result = api_format_messages(
2069 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2070 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2071 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2073 self::assertEquals('item_title', $result['title']);
2074 self::assertEquals('item_body', $result['text']);
2078 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
2082 public function testApiFormatMessagesWithoutUserObjects()
2084 $_GET['getUserObjects'] = 'false';
2085 $result = api_format_messages(
2086 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2087 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2088 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2090 self::assertTrue(!isset($result['sender']));
2091 self::assertTrue(!isset($result['recipient']));
2095 * Test the api_convert_item() function.
2099 public function testApiConvertItem()
2101 $result = api_convert_item(
2103 'network' => 'feed',
2104 'title' => 'item_title',
2106 // We need a long string to test that it is correctly cut
2107 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2108 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2109 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2110 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2111 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2112 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2113 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2114 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2115 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2116 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2117 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2118 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2119 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2120 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2121 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2122 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2123 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2124 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2125 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2126 'repellat officia illum quos impedit quam iste esse unde qui ' .
2127 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2128 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2129 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2130 'plink' => 'item_plink'
2133 self::assertStringStartsWith('item_title', $result['text']);
2134 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2138 * Test the api_convert_item() function with an empty item body.
2142 public function testApiConvertItemWithoutBody()
2144 $result = api_convert_item(
2146 'network' => 'feed',
2147 'title' => 'item_title',
2150 'plink' => 'item_plink'
2153 self::assertEquals("item_title", $result['text']);
2154 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2158 * Test the api_convert_item() function with the title in the body.
2162 public function testApiConvertItemWithTitleInBody()
2164 $result = api_convert_item(
2166 'title' => 'item_title',
2167 'body' => 'item_title item_body',
2171 self::assertEquals('item_title item_body', $result['text']);
2172 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2176 * Test the api_get_attachments() function.
2180 public function testApiGetAttachments()
2183 self::assertEmpty(api_get_attachments($body, 0));
2187 * Test the api_get_attachments() function with an img tag.
2191 public function testApiGetAttachmentsWithImage()
2193 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2194 self::assertIsArray(api_get_attachments($body, 0));
2198 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2202 public function testApiGetAttachmentsWithImageAndAndStatus()
2204 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2205 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2206 self::assertIsArray(api_get_attachments($body, 0));
2210 * Test the api_get_entitities() function.
2214 public function testApiGetEntitities()
2217 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2221 * Test the api_get_entitities() function with the include_entities parameter.
2225 public function testApiGetEntititiesWithIncludeEntities()
2227 $_REQUEST['include_entities'] = 'true';
2229 $result = api_get_entitities($text, 'bbcode', 0);
2230 self::assertIsArray($result['hashtags']);
2231 self::assertIsArray($result['symbols']);
2232 self::assertIsArray($result['urls']);
2233 self::assertIsArray($result['user_mentions']);
2237 * Test the api_format_items_embeded_images() function.
2241 public function testApiFormatItemsEmbededImages()
2244 'text ' . DI::baseUrl() . '/display/item_guid',
2245 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2250 * Test the api_contactlink_to_array() function.
2254 public function testApiContactlinkToArray()
2261 api_contactlink_to_array('text')
2266 * Test the api_contactlink_to_array() function with an URL.
2270 public function testApiContactlinkToArrayWithUrl()
2274 'name' => ['link_text'],
2277 api_contactlink_to_array('text <a href="url">link_text</a>')
2282 * Test the api_format_items_activities() function.
2286 public function testApiFormatItemsActivities()
2288 $item = ['uid' => 0, 'uri' => ''];
2289 $result = api_format_items_activities($item);
2290 self::assertArrayHasKey('like', $result);
2291 self::assertArrayHasKey('dislike', $result);
2292 self::assertArrayHasKey('attendyes', $result);
2293 self::assertArrayHasKey('attendno', $result);
2294 self::assertArrayHasKey('attendmaybe', $result);
2298 * Test the api_format_items_activities() function with an XML result.
2302 public function testApiFormatItemsActivitiesWithXml()
2304 $item = ['uid' => 0, 'uri' => ''];
2305 $result = api_format_items_activities($item, 'xml');
2306 self::assertArrayHasKey('friendica:like', $result);
2307 self::assertArrayHasKey('friendica:dislike', $result);
2308 self::assertArrayHasKey('friendica:attendyes', $result);
2309 self::assertArrayHasKey('friendica:attendno', $result);
2310 self::assertArrayHasKey('friendica:attendmaybe', $result);
2314 * Test the api_format_items() function.
2315 * @doesNotPerformAssertions
2317 public function testApiFormatItems()
2321 'item_network' => 'item_network',
2327 'author-network' => Protocol::DFRN,
2328 'author-link' => 'http://localhost/profile/othercontact',
2332 $result = api_format_items($items, ['id' => 0], true);
2333 foreach ($result as $status) {
2334 self::assertStatus($status);
2339 * Test the api_format_items() function with an XML result.
2340 * @doesNotPerformAssertions
2342 public function testApiFormatItemsWithXml()
2350 'author-network' => Protocol::DFRN,
2351 'author-link' => 'http://localhost/profile/othercontact',
2355 $result = api_format_items($items, ['id' => 0], true, 'xml');
2356 foreach ($result as $status) {
2357 self::assertStatus($status);
2362 * Test the api_lists_list() function.
2366 public function testApiListsList()
2368 $result = api_lists_list('json');
2369 self::assertEquals(['lists_list' => []], $result);
2373 * Test the api_lists_ownerships() function.
2377 public function testApiListsOwnerships()
2379 $result = api_lists_ownerships('json');
2380 foreach ($result['lists']['lists'] as $list) {
2381 self::assertList($list);
2386 * Test the api_lists_ownerships() function without an authenticated user.
2390 public function testApiListsOwnershipsWithoutAuthenticatedUser()
2392 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2393 $_SESSION['authenticated'] = false;
2394 api_lists_ownerships('json');
2398 * Test the api_lists_statuses() function.
2402 public function testApiListsStatuses()
2404 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2405 api_lists_statuses('json');
2409 * Test the api_lists_statuses() function with a list ID.
2410 * @doesNotPerformAssertions
2412 public function testApiListsStatusesWithListId()
2414 $_REQUEST['list_id'] = 1;
2415 $_REQUEST['page'] = -1;
2416 $_REQUEST['max_id'] = 10;
2417 $result = api_lists_statuses('json');
2418 foreach ($result['status'] as $status) {
2419 self::assertStatus($status);
2424 * Test the api_lists_statuses() function with a list ID and a RSS result.
2428 public function testApiListsStatusesWithListIdAndRss()
2430 $_REQUEST['list_id'] = 1;
2431 $result = api_lists_statuses('rss');
2432 self::assertXml($result, 'statuses');
2436 * Test the api_lists_statuses() function with an unallowed user.
2440 public function testApiListsStatusesWithUnallowedUser()
2442 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2443 $_SESSION['allow_api'] = false;
2444 $_GET['screen_name'] = $this->selfUser['nick'];
2445 api_lists_statuses('json');
2449 * Test the api_statuses_f() function.
2453 public function testApiStatusesFWithFriends()
2456 $result = api_statuses_f('friends');
2457 self::assertArrayHasKey('user', $result);
2461 * Test the api_statuses_f() function.
2465 public function testApiStatusesFWithFollowers()
2467 $result = api_statuses_f('followers');
2468 self::assertArrayHasKey('user', $result);
2472 * Test the api_statuses_f() function.
2476 public function testApiStatusesFWithBlocks()
2478 $result = api_statuses_f('blocks');
2479 self::assertArrayHasKey('user', $result);
2483 * Test the api_statuses_f() function.
2487 public function testApiStatusesFWithIncoming()
2489 $result = api_statuses_f('incoming');
2490 self::assertArrayHasKey('user', $result);
2494 * Test the api_statuses_f() function an undefined cursor GET variable.
2498 public function testApiStatusesFWithUndefinedCursor()
2500 $_GET['cursor'] = 'undefined';
2501 self::assertFalse(api_statuses_f('friends'));
2505 * Test the api_statuses_friends() function.
2509 public function testApiStatusesFriends()
2511 $result = api_statuses_friends('json');
2512 self::assertArrayHasKey('user', $result);
2516 * Test the api_statuses_friends() function an undefined cursor GET variable.
2520 public function testApiStatusesFriendsWithUndefinedCursor()
2522 $_GET['cursor'] = 'undefined';
2523 self::assertFalse(api_statuses_friends('json'));
2527 * Test the api_statuses_followers() function.
2531 public function testApiStatusesFollowers()
2533 $result = api_statuses_followers('json');
2534 self::assertArrayHasKey('user', $result);
2538 * Test the api_statuses_followers() function an undefined cursor GET variable.
2542 public function testApiStatusesFollowersWithUndefinedCursor()
2544 $_GET['cursor'] = 'undefined';
2545 self::assertFalse(api_statuses_followers('json'));
2549 * Test the api_blocks_list() function.
2553 public function testApiBlocksList()
2555 $result = api_blocks_list('json');
2556 self::assertArrayHasKey('user', $result);
2560 * Test the api_blocks_list() function an undefined cursor GET variable.
2564 public function testApiBlocksListWithUndefinedCursor()
2566 $_GET['cursor'] = 'undefined';
2567 self::assertFalse(api_blocks_list('json'));
2571 * Test the api_friendships_incoming() function.
2575 public function testApiFriendshipsIncoming()
2577 $result = api_friendships_incoming('json');
2578 self::assertArrayHasKey('id', $result);
2582 * Test the api_friendships_incoming() function an undefined cursor GET variable.
2586 public function testApiFriendshipsIncomingWithUndefinedCursor()
2588 $_GET['cursor'] = 'undefined';
2589 self::assertFalse(api_friendships_incoming('json'));
2593 * Test the api_statusnet_config() function.
2597 public function testApiStatusnetConfig()
2600 $result = api_statusnet_config('json');
2601 self::assertEquals('localhost', $result['config']['site']['server']);
2602 self::assertEquals('default', $result['config']['site']['theme']);
2603 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2604 self::assertTrue($result['config']['site']['fancy']);
2605 self::assertEquals('en', $result['config']['site']['language']);
2606 self::assertEquals('UTC', $result['config']['site']['timezone']);
2607 self::assertEquals(200000, $result['config']['site']['textlimit']);
2608 self::assertEquals('false', $result['config']['site']['private']);
2609 self::assertEquals('false', $result['config']['site']['ssl']);
2610 self::assertEquals(30, $result['config']['site']['shorturllength']);
2615 * Test the api_direct_messages_new() function.
2619 public function testApiDirectMessagesNew()
2621 $result = api_direct_messages_new('json');
2622 self::assertNull($result);
2626 * Test the api_direct_messages_new() function without an authenticated user.
2630 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2632 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2633 $_SESSION['authenticated'] = false;
2634 api_direct_messages_new('json');
2638 * Test the api_direct_messages_new() function with an user ID.
2642 public function testApiDirectMessagesNewWithUserId()
2644 $_POST['text'] = 'message_text';
2645 $_POST['user_id'] = $this->otherUser['id'];
2646 $result = api_direct_messages_new('json');
2647 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2651 * Test the api_direct_messages_new() function with a screen name.
2655 public function testApiDirectMessagesNewWithScreenName()
2657 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2658 $_POST['text'] = 'message_text';
2659 $_POST['screen_name'] = $this->friendUser['nick'];
2660 $result = api_direct_messages_new('json');
2661 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2662 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2663 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2667 * Test the api_direct_messages_new() function with a title.
2671 public function testApiDirectMessagesNewWithTitle()
2673 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2674 $_POST['text'] = 'message_text';
2675 $_POST['screen_name'] = $this->friendUser['nick'];
2676 $_REQUEST['title'] = 'message_title';
2677 $result = api_direct_messages_new('json');
2678 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2679 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2680 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2681 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2685 * Test the api_direct_messages_new() function with an RSS result.
2689 public function testApiDirectMessagesNewWithRss()
2691 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2692 $_POST['text'] = 'message_text';
2693 $_POST['screen_name'] = $this->friendUser['nick'];
2694 $result = api_direct_messages_new('rss');
2695 self::assertXml($result, 'direct-messages');
2699 * Test the api_direct_messages_destroy() function.
2703 public function testApiDirectMessagesDestroy()
2705 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2706 api_direct_messages_destroy('json');
2710 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2714 public function testApiDirectMessagesDestroyWithVerbose()
2716 $_GET['friendica_verbose'] = 'true';
2717 $result = api_direct_messages_destroy('json');
2721 'result' => 'error',
2722 'message' => 'message id or parenturi not specified'
2730 * Test the api_direct_messages_destroy() function without an authenticated user.
2734 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2736 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
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\ForbiddenException::class);
2869 $_SESSION['allow_api'] = false;
2870 $_GET['screen_name'] = $this->selfUser['nick'];
2871 api_direct_messages_box('json', 'sentbox', 'false');
2875 * Test the api_direct_messages_sentbox() function.
2879 public function testApiDirectMessagesSentbox()
2881 $result = api_direct_messages_sentbox('json');
2882 self::assertArrayHasKey('direct_message', $result);
2886 * Test the api_direct_messages_inbox() function.
2890 public function testApiDirectMessagesInbox()
2892 $result = api_direct_messages_inbox('json');
2893 self::assertArrayHasKey('direct_message', $result);
2897 * Test the api_direct_messages_all() function.
2901 public function testApiDirectMessagesAll()
2903 $result = api_direct_messages_all('json');
2904 self::assertArrayHasKey('direct_message', $result);
2908 * Test the api_direct_messages_conversation() function.
2912 public function testApiDirectMessagesConversation()
2914 $result = api_direct_messages_conversation('json');
2915 self::assertArrayHasKey('direct_message', $result);
2919 * Test the api_oauth_request_token() function.
2923 public function testApiOauthRequestToken()
2925 $this->markTestIncomplete('exit() kills phpunit as well');
2929 * Test the api_oauth_access_token() function.
2933 public function testApiOauthAccessToken()
2935 $this->markTestIncomplete('exit() kills phpunit as well');
2939 * Test the api_fr_photos_list() function.
2943 public function testApiFrPhotosList()
2945 $result = api_fr_photos_list('json');
2946 self::assertArrayHasKey('photo', $result);
2950 * Test the api_fr_photos_list() function without an authenticated user.
2954 public function testApiFrPhotosListWithoutAuthenticatedUser()
2956 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
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\ForbiddenException::class);
2978 $_SESSION['authenticated'] = false;
2979 api_fr_photo_create_update('json');
2983 * Test the api_fr_photo_create_update() function with an album name.
2987 public function testApiFrPhotoCreateUpdateWithAlbum()
2989 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2990 $_REQUEST['album'] = 'album_name';
2991 api_fr_photo_create_update('json');
2995 * Test the api_fr_photo_create_update() function with the update mode.
2999 public function testApiFrPhotoCreateUpdateWithUpdate()
3001 $this->markTestIncomplete('We need to create a dataset for this');
3005 * Test the api_fr_photo_create_update() function with an uploaded file.
3009 public function testApiFrPhotoCreateUpdateWithFile()
3011 $this->markTestIncomplete();
3015 * Test the api_fr_photo_detail() function.
3019 public function testApiFrPhotoDetail()
3021 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3022 api_fr_photo_detail('json');
3026 * Test the api_fr_photo_detail() function without an authenticated user.
3030 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
3032 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3033 $_SESSION['authenticated'] = false;
3034 api_fr_photo_detail('json');
3038 * Test the api_fr_photo_detail() function with a photo ID.
3042 public function testApiFrPhotoDetailWithPhotoId()
3044 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
3045 $_REQUEST['photo_id'] = 1;
3046 api_fr_photo_detail('json');
3050 * Test the api_fr_photo_detail() function with a correct photo ID.
3054 public function testApiFrPhotoDetailCorrectPhotoId()
3056 $this->markTestIncomplete('We need to create a dataset for this.');
3060 * Test the api_account_update_profile_image() function.
3064 public function testApiAccountUpdateProfileImage()
3066 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3067 api_account_update_profile_image('json');
3071 * Test the api_account_update_profile_image() function without an authenticated user.
3075 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
3077 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3078 $_SESSION['authenticated'] = false;
3079 api_account_update_profile_image('json');
3083 * Test the api_account_update_profile_image() function with an uploaded file.
3087 public function testApiAccountUpdateProfileImageWithUpload()
3089 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3090 $this->markTestIncomplete();
3095 * Test the api_account_update_profile() function.
3099 public function testApiAccountUpdateProfile()
3101 $_POST['name'] = 'new_name';
3102 $_POST['description'] = 'new_description';
3103 $result = api_account_update_profile('json');
3104 // We can't use assertSelfUser() here because the user object is missing some properties.
3105 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
3106 self::assertEquals('DFRN', $result['user']['location']);
3107 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
3108 self::assertEquals('dfrn', $result['user']['network']);
3109 self::assertEquals('new_name', $result['user']['name']);
3110 self::assertEquals('new_description', $result['user']['description']);
3114 * Test the check_acl_input() function.
3118 public function testCheckAclInput()
3120 $result = check_acl_input('<aclstring>');
3121 // Where does this result come from?
3122 self::assertEquals(1, $result);
3126 * Test the check_acl_input() function with an empty ACL string.
3130 public function testCheckAclInputWithEmptyAclString()
3132 $result = check_acl_input(' ');
3133 self::assertFalse($result);
3137 * Test the save_media_to_database() function.
3141 public function testSaveMediaToDatabase()
3143 $this->markTestIncomplete();
3147 * Test the post_photo_item() function.
3151 public function testPostPhotoItem()
3153 $this->markTestIncomplete();
3157 * Test the prepare_photo_data() function.
3161 public function testPreparePhotoData()
3163 $this->markTestIncomplete();
3167 * Test the api_share_as_retweet() function with a valid item.
3171 public function testApiShareAsRetweetWithValidItem()
3173 $this->markTestIncomplete();
3177 * Test the api_in_reply_to() function.
3181 public function testApiInReplyTo()
3183 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3184 self::assertArrayHasKey('status_id', $result);
3185 self::assertArrayHasKey('user_id', $result);
3186 self::assertArrayHasKey('status_id_str', $result);
3187 self::assertArrayHasKey('user_id_str', $result);
3188 self::assertArrayHasKey('screen_name', $result);
3192 * Test the api_in_reply_to() function with a valid item.
3196 public function testApiInReplyToWithValidItem()
3198 $this->markTestIncomplete();
3202 * Test the api_clean_plain_items() function.
3206 public function testApiCleanPlainItems()
3208 $_REQUEST['include_entities'] = 'true';
3209 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3210 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3214 * Test the api_best_nickname() function.
3218 public function testApiBestNickname()
3221 $result = api_best_nickname($contacts);
3222 self::assertNull($result);
3226 * Test the api_best_nickname() function with contacts.
3230 public function testApiBestNicknameWithContacts()
3232 $this->markTestIncomplete();
3236 * Test the api_friendica_group_show() function.
3240 public function testApiFriendicaGroupShow()
3242 $this->markTestIncomplete();
3246 * Test the api_friendica_group_delete() function.
3250 public function testApiFriendicaGroupDelete()
3252 $this->markTestIncomplete();
3256 * Test the api_lists_destroy() function.
3260 public function testApiListsDestroy()
3262 $this->markTestIncomplete();
3266 * Test the group_create() function.
3270 public function testGroupCreate()
3272 $this->markTestIncomplete();
3276 * Test the api_friendica_group_create() function.
3280 public function testApiFriendicaGroupCreate()
3282 $this->markTestIncomplete();
3286 * Test the api_lists_create() function.
3290 public function testApiListsCreate()
3292 $this->markTestIncomplete();
3296 * Test the api_friendica_group_update() function.
3300 public function testApiFriendicaGroupUpdate()
3302 $this->markTestIncomplete();
3306 * Test the api_lists_update() function.
3310 public function testApiListsUpdate()
3312 $this->markTestIncomplete();
3316 * Test the api_friendica_activity() function.
3320 public function testApiFriendicaActivity()
3322 $this->markTestIncomplete();
3326 * Test the api_friendica_notification_seen() function.
3330 public function testApiFriendicaNotificationSeen()
3332 $this->markTestIncomplete();
3336 * Test the api_friendica_direct_messages_setseen() function.
3340 public function testApiFriendicaDirectMessagesSetseen()
3342 $this->markTestIncomplete();
3346 * Test the api_friendica_direct_messages_search() function.
3350 public function testApiFriendicaDirectMessagesSearch()
3352 $this->markTestIncomplete();