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']
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'], api_user());
230 * Test the api_user() function with an unallowed user.
234 public function testApiUserWithUnallowedUser()
236 $_SESSION = ['allow_api' => false];
237 self::assertEquals(false, api_user());
241 * Test the api_source() function.
245 public function testApiSource()
247 self::assertEquals('api', api_source());
251 * Test the api_source() function with a Twidere user agent.
255 public function testApiSourceWithTwidere()
257 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
258 self::assertEquals('Twidere', api_source());
262 * Test the api_source() function with a GET parameter.
266 public function testApiSourceWithGet()
268 $_GET['source'] = 'source_name';
269 self::assertEquals('source_name', api_source());
273 * Test the api_date() function.
277 public function testApiDate()
279 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
283 * Test the api_register_func() function.
287 public function testApiRegisterFunc()
299 self::assertTrue($API['api_path']['auth']);
300 self::assertEquals('method', $API['api_path']['method']);
301 self::assertTrue(is_callable($API['api_path']['func']));
305 * Test the BasicAuth::getCurrentUserID() function without any login.
307 * @runInSeparateProcess
308 * @preserveGlobalState disabled
309 * @preserveGlobalState disabled
311 public function testApiLoginWithoutLogin()
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 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
327 $_SERVER['PHP_AUTH_USER'] = 'user@server';
328 BasicAuth::getCurrentUserID(true);
332 * Test the BasicAuth::getCurrentUserID() function with oAuth.
336 public function testApiLoginWithOauth()
338 $this->markTestIncomplete('Can we test this easily?');
342 * Test the BasicAuth::getCurrentUserID() function with authentication provided by an addon.
346 public function testApiLoginWithAddonAuth()
348 $this->markTestIncomplete('Can we test this easily?');
352 * Test the BasicAuth::getCurrentUserID() function with a correct login.
354 * @runInSeparateProcess
355 * @preserveGlobalState disabled
356 * @doesNotPerformAssertions
358 public function testApiLoginWithCorrectLogin()
360 $_SERVER['PHP_AUTH_USER'] = 'Test user';
361 $_SERVER['PHP_AUTH_PW'] = 'password';
362 BasicAuth::getCurrentUserID(true);
366 * Test the BasicAuth::getCurrentUserID() function with a remote user.
368 * @runInSeparateProcess
369 * @preserveGlobalState disabled
371 public function testApiLoginWithRemoteUser()
373 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
374 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
375 BasicAuth::getCurrentUserID(true);
379 * Test the api_check_method() function.
383 public function testApiCheckMethod()
385 self::assertFalse(api_check_method('method'));
389 * Test the api_check_method() function with a correct method.
393 public function testApiCheckMethodWithCorrectMethod()
395 $_SERVER['REQUEST_METHOD'] = 'method';
396 self::assertTrue(api_check_method('method'));
400 * Test the api_check_method() function with a wildcard.
404 public function testApiCheckMethodWithWildcard()
406 self::assertTrue(api_check_method('*'));
410 * Test the api_call() function.
412 * @runInSeparateProcess
413 * @preserveGlobalState disabled
415 public function testApiCall()
419 'method' => 'method',
420 'func' => function () {
421 return ['data' => ['some_data']];
424 $_SERVER['REQUEST_METHOD'] = 'method';
425 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
426 $_GET['callback'] = 'callback_name';
428 $args = DI::args()->determine($_SERVER, $_GET);
431 'callback_name(["some_data"])',
432 api_call($this->app, $args)
437 * Test the api_call() function with the profiled enabled.
439 * @runInSeparateProcess
440 * @preserveGlobalState disabled
442 public function testApiCallWithProfiler()
446 'method' => 'method',
447 'func' => function () {
448 return ['data' => ['some_data']];
452 $_SERVER['REQUEST_METHOD'] = 'method';
453 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
455 $args = DI::args()->determine($_SERVER, $_GET);
457 $this->config->set('system', 'profiler', true);
458 $this->config->set('rendertime', 'callstack', true);
459 $this->app->callstack = [
460 'database' => ['some_function' => 200],
461 'database_write' => ['some_function' => 200],
462 'cache' => ['some_function' => 200],
463 'cache_write' => ['some_function' => 200],
464 'network' => ['some_function' => 200]
469 api_call($this->app, $args)
474 * Test the api_call() function with a JSON result.
476 * @runInSeparateProcess
477 * @preserveGlobalState disabled
479 public function testApiCallWithJson()
483 'method' => 'method',
484 'func' => function () {
485 return ['data' => ['some_data']];
488 $_SERVER['REQUEST_METHOD'] = 'method';
489 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
491 $args = DI::args()->determine($_SERVER, $_GET);
495 api_call($this->app, $args)
500 * Test the api_call() function with an XML result.
502 * @runInSeparateProcess
503 * @preserveGlobalState disabled
505 public function testApiCallWithXml()
509 'method' => 'method',
510 'func' => function () {
514 $_SERVER['REQUEST_METHOD'] = 'method';
515 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
517 $args = DI::args()->determine($_SERVER, $_GET);
521 api_call($this->app, $args)
526 * Test the api_call() function with an RSS result.
528 * @runInSeparateProcess
529 * @preserveGlobalState disabled
531 public function testApiCallWithRss()
535 'method' => 'method',
536 'func' => function () {
540 $_SERVER['REQUEST_METHOD'] = 'method';
541 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
543 $args = DI::args()->determine($_SERVER, $_GET);
546 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
548 api_call($this->app, $args)
553 * Test the api_call() function with an Atom result.
555 * @runInSeparateProcess
556 * @preserveGlobalState disabled
558 public function testApiCallWithAtom()
562 'method' => 'method',
563 'func' => function () {
567 $_SERVER['REQUEST_METHOD'] = 'method';
568 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
570 $args = DI::args()->determine($_SERVER, $_GET);
573 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
575 api_call($this->app, $args)
580 * Test the api_rss_extra() function.
584 public function testApiRssExtra()
586 $user_info = ['url' => 'user_url', 'lang' => 'en'];
587 $result = api_rss_extra([], $user_info);
588 self::assertEquals($user_info, $result['$user']);
589 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
590 self::assertArrayHasKey('self', $result['$rss']);
591 self::assertArrayHasKey('base', $result['$rss']);
592 self::assertArrayHasKey('updated', $result['$rss']);
593 self::assertArrayHasKey('atom_updated', $result['$rss']);
594 self::assertArrayHasKey('language', $result['$rss']);
595 self::assertArrayHasKey('logo', $result['$rss']);
599 * Test the api_rss_extra() function without any user info.
603 public function testApiRssExtraWithoutUserInfo()
605 $result = api_rss_extra([], null);
606 self::assertIsArray($result['$user']);
607 self::assertArrayHasKey('alternate', $result['$rss']);
608 self::assertArrayHasKey('self', $result['$rss']);
609 self::assertArrayHasKey('base', $result['$rss']);
610 self::assertArrayHasKey('updated', $result['$rss']);
611 self::assertArrayHasKey('atom_updated', $result['$rss']);
612 self::assertArrayHasKey('language', $result['$rss']);
613 self::assertArrayHasKey('logo', $result['$rss']);
617 * Test the api_unique_id_to_nurl() function.
621 public function testApiUniqueIdToNurl()
623 self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
627 * Test the api_unique_id_to_nurl() function with a correct ID.
631 public function testApiUniqueIdToNurlWithCorrectId()
633 self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
637 * Test the api_get_user() function.
641 public function testApiGetUser()
643 $user = api_get_user();
644 self::assertSelfUser($user);
645 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
646 // self::assertEquals('6fdbe8', $user['profile_link_color']);
647 // self::assertEquals('ededed', $user['profile_background_color']);
651 * Test the api_get_user() function with a Frio schema.
655 public function testApiGetUserWithFrioSchema()
657 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
658 $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
659 $user = api_get_user();
660 self::assertSelfUser($user);
661 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
662 // self::assertEquals('6fdbe8', $user['profile_link_color']);
663 // self::assertEquals('ededed', $user['profile_background_color']);
667 * Test the api_get_user() function with an empty Frio schema.
671 public function testApiGetUserWithEmptyFrioSchema()
673 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
674 $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
675 $user = api_get_user();
676 self::assertSelfUser($user);
677 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
678 // self::assertEquals('6fdbe8', $user['profile_link_color']);
679 // self::assertEquals('ededed', $user['profile_background_color']);
683 * Test the api_get_user() function with a custom Frio schema.
687 public function testApiGetUserWithCustomFrioSchema()
689 $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
690 $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
691 $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
692 $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
693 $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
694 $user = api_get_user();
695 self::assertSelfUser($user);
696 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
697 // self::assertEquals('123456', $user['profile_link_color']);
698 // self::assertEquals('123456', $user['profile_background_color']);
702 * Test the api_get_user() function with an user that is not allowed to use the API.
704 * @runInSeparateProcess
705 * @preserveGlobalState disabled
707 public function testApiGetUserWithoutApiUser()
709 $_SERVER['PHP_AUTH_USER'] = 'Test user';
710 $_SERVER['PHP_AUTH_PW'] = 'password';
711 $_SESSION['allow_api'] = false;
712 self::assertFalse(api_get_user());
716 * Test the api_get_user() function with an user ID in a GET parameter.
720 public function testApiGetUserWithGetId()
722 $_GET['user_id'] = $this->otherUser['id'];
723 self::assertOtherUser(api_get_user());
727 * Test the api_get_user() function with a wrong user ID in a GET parameter.
731 public function testApiGetUserWithWrongGetId()
733 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
734 $_GET['user_id'] = $this->wrongUserId;
735 self::assertOtherUser(api_get_user());
739 * Test the api_get_user() function with an user name in a GET parameter.
743 public function testApiGetUserWithGetName()
745 $_GET['screen_name'] = $this->selfUser['nick'];
746 self::assertSelfUser(api_get_user());
750 * Test the api_get_user() function with a profile URL in a GET parameter.
754 public function testApiGetUserWithGetUrl()
756 $_GET['profileurl'] = $this->selfUser['nurl'];
757 self::assertSelfUser(api_get_user());
761 * Test the api_get_user() function with an user ID in the API path.
765 public function testApiGetUserWithNumericCalledApi()
768 $called_api = ['api_path'];
769 DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
770 self::assertOtherUser(api_get_user());
774 * Test the api_get_user() function with the $called_api global variable.
778 public function testApiGetUserWithCalledApi()
781 $called_api = ['api', 'api_path'];
782 self::assertSelfUser(api_get_user());
786 * Test the api_get_user() function with a valid user.
790 public function testApiGetUserWithCorrectUser()
792 self::assertOtherUser(api_get_user($this->otherUser['id']));
796 * Test the api_get_user() function with a wrong user ID.
800 public function testApiGetUserWithWrongUser()
802 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
803 self::assertOtherUser(api_get_user($this->wrongUserId));
807 * Test the api_get_user() function with a 0 user ID.
811 public function testApiGetUserWithZeroUser()
813 self::assertSelfUser(api_get_user(0));
817 * Test the api_item_get_user() function.
821 public function testApiItemGetUser()
823 $users = api_item_get_user($this->app, []);
824 self::assertSelfUser($users[0]);
828 * Test the api_item_get_user() function with a different item parent.
832 public function testApiItemGetUserWithDifferentParent()
834 $users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
835 self::assertSelfUser($users[0]);
836 self::assertEquals($users[0], $users[1]);
840 * Test the Arrays::walkRecursive() function.
844 public function testApiWalkRecursive()
849 Arrays::walkRecursive(
852 // Should we test this with a callback that actually does something?
860 * Test the Arrays::walkRecursive() function with an array.
864 public function testApiWalkRecursiveWithArray()
866 $array = [['item1'], ['item2']];
869 Arrays::walkRecursive(
872 // Should we test this with a callback that actually does something?
880 * Test the BaseApi::reformatXML() function.
884 public function testApiReformatXml()
888 self::assertTrue(ApiResponse::reformatXML($item, $key));
889 self::assertEquals('true', $item);
893 * Test the BaseApi::reformatXML() function with a statusnet_api key.
897 public function testApiReformatXmlWithStatusnetKey()
900 $key = 'statusnet_api';
901 self::assertTrue(ApiResponse::reformatXML($item, $key));
902 self::assertEquals('statusnet:api', $key);
906 * Test the BaseApi::reformatXML() function with a friendica_api key.
910 public function testApiReformatXmlWithFriendicaKey()
913 $key = 'friendica_api';
914 self::assertTrue(ApiResponse::reformatXML($item, $key));
915 self::assertEquals('friendica:api', $key);
919 * Test the BaseApi::createXML() function.
923 public function testApiCreateXml()
926 '<?xml version="1.0"?>' . "\n" .
927 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
928 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
929 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
930 ' <data>some_data</data>' . "\n" .
931 '</root_element>' . "\n",
932 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
937 * Test the BaseApi::createXML() function without any XML namespace.
941 public function testApiCreateXmlWithoutNamespaces()
944 '<?xml version="1.0"?>' . "\n" .
946 ' <data>some_data</data>' . "\n" .
948 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
953 * Test the BaseApi::formatData() function.
957 public function testApiFormatData()
959 $data = ['some_data'];
960 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
964 * Test the BaseApi::formatData() function with an XML result.
968 public function testApiFormatDataWithXml()
971 '<?xml version="1.0"?>' . "\n" .
972 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
973 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
974 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
975 ' <data>some_data</data>' . "\n" .
976 '</root_element>' . "\n",
977 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
982 * Test the api_account_verify_credentials() function.
986 public function testApiAccountVerifyCredentials()
988 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
992 * Test the api_account_verify_credentials() function without an authenticated user.
996 public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
998 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
999 $_SESSION['authenticated'] = false;
1000 api_account_verify_credentials('json');
1004 * Test the requestdata() function.
1008 public function testRequestdata()
1010 self::assertNull(requestdata('variable_name'));
1014 * Test the requestdata() function with a POST parameter.
1018 public function testRequestdataWithPost()
1020 $_POST['variable_name'] = 'variable_value';
1021 self::assertEquals('variable_value', requestdata('variable_name'));
1025 * Test the requestdata() function with a GET parameter.
1029 public function testRequestdataWithGet()
1031 $_GET['variable_name'] = 'variable_value';
1032 self::assertEquals('variable_value', requestdata('variable_name'));
1036 * Test the api_statuses_mediap() function.
1040 public function testApiStatusesMediap()
1042 DI::args()->setArgc(2);
1050 'tmp_name' => $this->getTempImage(),
1051 'name' => 'spacer.png',
1052 'type' => 'image/png'
1055 $_GET['status'] = '<b>Status content</b>';
1057 $result = api_statuses_mediap('json');
1058 self::assertStatus($result['status']);
1062 * Test the api_statuses_mediap() function without an authenticated user.
1066 public function testApiStatusesMediapWithoutAuthenticatedUser()
1068 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1069 $_SESSION['authenticated'] = false;
1070 api_statuses_mediap('json');
1074 * Test the api_statuses_update() function.
1078 public function testApiStatusesUpdate()
1080 $_GET['status'] = 'Status content #friendica';
1081 $_GET['in_reply_to_status_id'] = -1;
1090 'tmp_name' => $this->getTempImage(),
1091 'name' => 'spacer.png',
1092 'type' => 'image/png'
1096 $result = api_statuses_update('json');
1097 self::assertStatus($result['status']);
1101 * Test the api_statuses_update() function with an HTML status.
1105 public function testApiStatusesUpdateWithHtml()
1107 $_GET['htmlstatus'] = '<b>Status content</b>';
1109 $result = api_statuses_update('json');
1110 self::assertStatus($result['status']);
1114 * Test the api_statuses_update() function without an authenticated user.
1118 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1120 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1121 $_SESSION['authenticated'] = false;
1122 api_statuses_update('json');
1126 * Test the api_statuses_update() function with a parent status.
1130 public function testApiStatusesUpdateWithParent()
1132 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1136 * Test the api_statuses_update() function with a media_ids parameter.
1140 public function testApiStatusesUpdateWithMediaIds()
1142 $this->markTestIncomplete();
1146 * Test the api_statuses_update() function with the throttle limit reached.
1150 public function testApiStatusesUpdateWithDayThrottleReached()
1152 $this->markTestIncomplete();
1156 * Test the api_media_upload() function.
1157 * @runInSeparateProcess
1158 * @preserveGlobalState disabled
1160 public function testApiMediaUpload()
1162 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1167 * Test the api_media_upload() function without an authenticated user.
1171 public function testApiMediaUploadWithoutAuthenticatedUser()
1173 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1174 $_SESSION['authenticated'] = false;
1179 * Test the api_media_upload() function with an invalid uploaded media.
1183 public function testApiMediaUploadWithMedia()
1185 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1189 'tmp_name' => 'tmp_name'
1196 * Test the api_media_upload() function with an valid uploaded media.
1200 public function testApiMediaUploadWithValidMedia()
1208 'tmp_name' => $this->getTempImage(),
1209 'name' => 'spacer.png',
1210 'type' => 'image/png'
1214 DI::args()->setArgc(2);
1216 $result = api_media_upload();
1217 self::assertEquals('image/png', $result['media']['image']['image_type']);
1218 self::assertEquals(1, $result['media']['image']['w']);
1219 self::assertEquals(1, $result['media']['image']['h']);
1220 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1224 * Test the api_status_show() function.
1226 public function testApiStatusShowWithJson()
1228 $result = api_status_show('json', 1);
1229 self::assertStatus($result['status']);
1233 * Test the api_status_show() function with an XML result.
1235 public function testApiStatusShowWithXml()
1237 $result = api_status_show('xml', 1);
1238 self::assertXml($result, 'statuses');
1242 * Test the api_get_last_status() function
1244 public function testApiGetLastStatus()
1246 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1248 self::assertNotNull($item);
1252 * Test the api_users_show() function.
1256 public function testApiUsersShow()
1258 $result = api_users_show('json');
1259 // We can't use assertSelfUser() here because the user object is missing some properties.
1260 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1261 self::assertEquals('DFRN', $result['user']['location']);
1262 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1263 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1264 self::assertEquals('dfrn', $result['user']['network']);
1265 self::assertTrue($result['user']['verified']);
1269 * Test the api_users_show() function with an XML result.
1273 public function testApiUsersShowWithXml()
1275 $result = api_users_show('xml');
1276 self::assertXml($result, 'statuses');
1280 * Test the api_users_search() function.
1284 public function testApiUsersSearch()
1286 $_GET['q'] = 'othercontact';
1287 $result = api_users_search('json');
1288 self::assertOtherUser($result['users'][0]);
1292 * Test the api_users_search() function with an XML result.
1296 public function testApiUsersSearchWithXml()
1298 $_GET['q'] = 'othercontact';
1299 $result = api_users_search('xml');
1300 self::assertXml($result, 'users');
1304 * Test the api_users_search() function without a GET q parameter.
1308 public function testApiUsersSearchWithoutQuery()
1310 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1311 api_users_search('json');
1315 * Test the api_users_lookup() function.
1319 public function testApiUsersLookup()
1321 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1322 api_users_lookup('json');
1326 * Test the api_users_lookup() function with an user ID.
1330 public function testApiUsersLookupWithUserId()
1332 $_REQUEST['user_id'] = $this->otherUser['id'];
1333 $result = api_users_lookup('json');
1334 self::assertOtherUser($result['users'][0]);
1338 * Test the api_search() function.
1342 public function testApiSearch()
1344 $_REQUEST['q'] = 'reply';
1345 $_REQUEST['max_id'] = 10;
1346 $result = api_search('json');
1347 foreach ($result['status'] as $status) {
1348 self::assertStatus($status);
1349 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1354 * Test the api_search() function a count parameter.
1358 public function testApiSearchWithCount()
1360 $_REQUEST['q'] = 'reply';
1361 $_REQUEST['count'] = 20;
1362 $result = api_search('json');
1363 foreach ($result['status'] as $status) {
1364 self::assertStatus($status);
1365 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1370 * Test the api_search() function with an rpp parameter.
1374 public function testApiSearchWithRpp()
1376 $_REQUEST['q'] = 'reply';
1377 $_REQUEST['rpp'] = 20;
1378 $result = api_search('json');
1379 foreach ($result['status'] as $status) {
1380 self::assertStatus($status);
1381 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1386 * Test the api_search() function with an q parameter contains hashtag.
1387 * @doesNotPerformAssertions
1389 public function testApiSearchWithHashtag()
1391 $_REQUEST['q'] = '%23friendica';
1392 $result = api_search('json');
1393 foreach ($result['status'] as $status) {
1394 self::assertStatus($status);
1395 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1400 * Test the api_search() function with an exclude_replies parameter.
1401 * @doesNotPerformAssertions
1403 public function testApiSearchWithExcludeReplies()
1405 $_REQUEST['max_id'] = 10;
1406 $_REQUEST['exclude_replies'] = true;
1407 $_REQUEST['q'] = 'friendica';
1408 $result = api_search('json');
1409 foreach ($result['status'] as $status) {
1410 self::assertStatus($status);
1415 * Test the api_search() function without an authenticated user.
1419 public function testApiSearchWithUnallowedUser()
1421 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1422 $_SESSION['allow_api'] = false;
1423 $_GET['screen_name'] = $this->selfUser['nick'];
1428 * Test the api_search() function without any GET query parameter.
1432 public function testApiSearchWithoutQuery()
1434 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1439 * Test the api_statuses_home_timeline() function.
1443 public function testApiStatusesHomeTimeline()
1445 $_REQUEST['max_id'] = 10;
1446 $_REQUEST['exclude_replies'] = true;
1447 $_REQUEST['conversation_id'] = 1;
1448 $result = api_statuses_home_timeline('json');
1449 self::assertNotEmpty($result['status']);
1450 foreach ($result['status'] as $status) {
1451 self::assertStatus($status);
1456 * Test the api_statuses_home_timeline() function with a negative page parameter.
1460 public function testApiStatusesHomeTimelineWithNegativePage()
1462 $_REQUEST['page'] = -2;
1463 $result = api_statuses_home_timeline('json');
1464 self::assertNotEmpty($result['status']);
1465 foreach ($result['status'] as $status) {
1466 self::assertStatus($status);
1471 * Test the api_statuses_home_timeline() with an unallowed user.
1475 public function testApiStatusesHomeTimelineWithUnallowedUser()
1477 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1478 $_SESSION['allow_api'] = false;
1479 $_GET['screen_name'] = $this->selfUser['nick'];
1480 api_statuses_home_timeline('json');
1484 * Test the api_statuses_home_timeline() function with an RSS result.
1488 public function testApiStatusesHomeTimelineWithRss()
1490 $result = api_statuses_home_timeline('rss');
1491 self::assertXml($result, 'statuses');
1495 * Test the api_statuses_public_timeline() function.
1499 public function testApiStatusesPublicTimeline()
1501 $_REQUEST['max_id'] = 10;
1502 $_REQUEST['conversation_id'] = 1;
1503 $result = api_statuses_public_timeline('json');
1504 self::assertNotEmpty($result['status']);
1505 foreach ($result['status'] as $status) {
1506 self::assertStatus($status);
1511 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1515 public function testApiStatusesPublicTimelineWithExcludeReplies()
1517 $_REQUEST['max_id'] = 10;
1518 $_REQUEST['exclude_replies'] = true;
1519 $result = api_statuses_public_timeline('json');
1520 self::assertNotEmpty($result['status']);
1521 foreach ($result['status'] as $status) {
1522 self::assertStatus($status);
1527 * Test the api_statuses_public_timeline() function with a negative page parameter.
1531 public function testApiStatusesPublicTimelineWithNegativePage()
1533 $_REQUEST['page'] = -2;
1534 $result = api_statuses_public_timeline('json');
1535 self::assertNotEmpty($result['status']);
1536 foreach ($result['status'] as $status) {
1537 self::assertStatus($status);
1542 * Test the api_statuses_public_timeline() function with an unallowed user.
1546 public function testApiStatusesPublicTimelineWithUnallowedUser()
1548 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1549 $_SESSION['allow_api'] = false;
1550 $_GET['screen_name'] = $this->selfUser['nick'];
1551 api_statuses_public_timeline('json');
1555 * Test the api_statuses_public_timeline() function with an RSS result.
1559 public function testApiStatusesPublicTimelineWithRss()
1561 $result = api_statuses_public_timeline('rss');
1562 self::assertXml($result, 'statuses');
1566 * Test the api_statuses_networkpublic_timeline() function.
1570 public function testApiStatusesNetworkpublicTimeline()
1572 $_REQUEST['max_id'] = 10;
1573 $result = api_statuses_networkpublic_timeline('json');
1574 self::assertNotEmpty($result['status']);
1575 foreach ($result['status'] as $status) {
1576 self::assertStatus($status);
1581 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1585 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1587 $_REQUEST['page'] = -2;
1588 $result = api_statuses_networkpublic_timeline('json');
1589 self::assertNotEmpty($result['status']);
1590 foreach ($result['status'] as $status) {
1591 self::assertStatus($status);
1596 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1600 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1602 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1603 $_SESSION['allow_api'] = false;
1604 $_GET['screen_name'] = $this->selfUser['nick'];
1605 api_statuses_networkpublic_timeline('json');
1609 * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1613 public function testApiStatusesNetworkpublicTimelineWithRss()
1615 $result = api_statuses_networkpublic_timeline('rss');
1616 self::assertXml($result, 'statuses');
1620 * Test the api_statuses_show() function.
1624 public function testApiStatusesShow()
1626 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1627 api_statuses_show('json');
1631 * Test the api_statuses_show() function with an ID.
1635 public function testApiStatusesShowWithId()
1637 DI::args()->setArgv(['', '', '', 1]);
1638 $result = api_statuses_show('json');
1639 self::assertStatus($result['status']);
1643 * Test the api_statuses_show() function with the conversation parameter.
1647 public function testApiStatusesShowWithConversation()
1649 DI::args()->setArgv(['', '', '', 1]);
1650 $_REQUEST['conversation'] = 1;
1651 $result = api_statuses_show('json');
1652 self::assertNotEmpty($result['status']);
1653 foreach ($result['status'] as $status) {
1654 self::assertStatus($status);
1659 * Test the api_statuses_show() function with an unallowed user.
1663 public function testApiStatusesShowWithUnallowedUser()
1665 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1666 $_SESSION['allow_api'] = false;
1667 $_GET['screen_name'] = $this->selfUser['nick'];
1668 api_statuses_show('json');
1672 * Test the api_conversation_show() function.
1676 public function testApiConversationShow()
1678 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1679 api_conversation_show('json');
1683 * Test the api_conversation_show() function with an ID.
1687 public function testApiConversationShowWithId()
1689 DI::args()->setArgv(['', '', '', 1]);
1690 $_REQUEST['max_id'] = 10;
1691 $_REQUEST['page'] = -2;
1692 $result = api_conversation_show('json');
1693 self::assertNotEmpty($result['status']);
1694 foreach ($result['status'] as $status) {
1695 self::assertStatus($status);
1700 * Test the api_conversation_show() function with an unallowed user.
1704 public function testApiConversationShowWithUnallowedUser()
1706 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1707 $_SESSION['allow_api'] = false;
1708 $_GET['screen_name'] = $this->selfUser['nick'];
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\ForbiddenException::class);
1731 $_SESSION['authenticated'] = false;
1732 api_statuses_repeat('json');
1736 * Test the api_statuses_repeat() function with an ID.
1740 public function testApiStatusesRepeatWithId()
1742 DI::args()->setArgv(['', '', '', 1]);
1743 $result = api_statuses_repeat('json');
1744 self::assertStatus($result['status']);
1746 // Also test with a shared status
1747 DI::args()->setArgv(['', '', '', 5]);
1748 $result = api_statuses_repeat('json');
1749 self::assertStatus($result['status']);
1753 * Test the api_statuses_destroy() function.
1757 public function testApiStatusesDestroy()
1759 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1760 api_statuses_destroy('json');
1764 * Test the api_statuses_destroy() function without an authenticated user.
1768 public function testApiStatusesDestroyWithoutAuthenticatedUser()
1770 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1771 $_SESSION['authenticated'] = false;
1772 api_statuses_destroy('json');
1776 * Test the api_statuses_destroy() function with an ID.
1780 public function testApiStatusesDestroyWithId()
1782 DI::args()->setArgv(['', '', '', 1]);
1783 $result = api_statuses_destroy('json');
1784 self::assertStatus($result['status']);
1788 * Test the api_statuses_mentions() function.
1792 public function testApiStatusesMentions()
1794 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1795 $_REQUEST['max_id'] = 10;
1796 $result = api_statuses_mentions('json');
1797 self::assertEmpty($result['status']);
1798 // We should test with mentions in the database.
1802 * Test the api_statuses_mentions() function with a negative page parameter.
1806 public function testApiStatusesMentionsWithNegativePage()
1808 $_REQUEST['page'] = -2;
1809 $result = api_statuses_mentions('json');
1810 self::assertEmpty($result['status']);
1814 * Test the api_statuses_mentions() function with an unallowed user.
1818 public function testApiStatusesMentionsWithUnallowedUser()
1820 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1821 $_SESSION['allow_api'] = false;
1822 $_GET['screen_name'] = $this->selfUser['nick'];
1823 api_statuses_mentions('json');
1827 * Test the api_statuses_mentions() function with an RSS result.
1831 public function testApiStatusesMentionsWithRss()
1833 $result = api_statuses_mentions('rss');
1834 self::assertXml($result, 'statuses');
1838 * Test the api_statuses_user_timeline() function.
1842 public function testApiStatusesUserTimeline()
1844 $_REQUEST['max_id'] = 10;
1845 $_REQUEST['exclude_replies'] = true;
1846 $_REQUEST['conversation_id'] = 1;
1847 $result = api_statuses_user_timeline('json');
1848 self::assertNotEmpty($result['status']);
1849 foreach ($result['status'] as $status) {
1850 self::assertStatus($status);
1855 * Test the api_statuses_user_timeline() function with a negative page parameter.
1859 public function testApiStatusesUserTimelineWithNegativePage()
1861 $_REQUEST['page'] = -2;
1862 $result = api_statuses_user_timeline('json');
1863 self::assertNotEmpty($result['status']);
1864 foreach ($result['status'] as $status) {
1865 self::assertStatus($status);
1870 * Test the api_statuses_user_timeline() function with an RSS result.
1874 public function testApiStatusesUserTimelineWithRss()
1876 $result = api_statuses_user_timeline('rss');
1877 self::assertXml($result, 'statuses');
1881 * Test the api_statuses_user_timeline() function with an unallowed user.
1885 public function testApiStatusesUserTimelineWithUnallowedUser()
1887 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1888 $_SESSION['allow_api'] = false;
1889 $_GET['screen_name'] = $this->selfUser['nick'];
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\ForbiddenException::class);
1977 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1978 $_SESSION['authenticated'] = false;
1979 api_favorites_create_destroy('json');
1983 * Test the api_favorites() function.
1987 public function testApiFavorites()
1989 $_REQUEST['page'] = -1;
1990 $_REQUEST['max_id'] = 10;
1991 $result = api_favorites('json');
1992 foreach ($result['status'] as $status) {
1993 self::assertStatus($status);
1998 * Test the api_favorites() function with an RSS result.
2002 public function testApiFavoritesWithRss()
2004 $result = api_favorites('rss');
2005 self::assertXml($result, 'statuses');
2009 * Test the api_favorites() function with an unallowed user.
2013 public function testApiFavoritesWithUnallowedUser()
2015 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2016 $_SESSION['allow_api'] = false;
2017 $_GET['screen_name'] = $this->selfUser['nick'];
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\ForbiddenException::class);
2391 $_SESSION['authenticated'] = false;
2392 api_lists_ownerships('json');
2396 * Test the api_lists_statuses() function.
2400 public function testApiListsStatuses()
2402 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2403 api_lists_statuses('json');
2407 * Test the api_lists_statuses() function with a list ID.
2408 * @doesNotPerformAssertions
2410 public function testApiListsStatusesWithListId()
2412 $_REQUEST['list_id'] = 1;
2413 $_REQUEST['page'] = -1;
2414 $_REQUEST['max_id'] = 10;
2415 $result = api_lists_statuses('json');
2416 foreach ($result['status'] as $status) {
2417 self::assertStatus($status);
2422 * Test the api_lists_statuses() function with a list ID and a RSS result.
2426 public function testApiListsStatusesWithListIdAndRss()
2428 $_REQUEST['list_id'] = 1;
2429 $result = api_lists_statuses('rss');
2430 self::assertXml($result, 'statuses');
2434 * Test the api_lists_statuses() function with an unallowed user.
2438 public function testApiListsStatusesWithUnallowedUser()
2440 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2441 $_SESSION['allow_api'] = false;
2442 $_GET['screen_name'] = $this->selfUser['nick'];
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\ForbiddenException::class);
2631 $_SESSION['authenticated'] = false;
2632 api_direct_messages_new('json');
2636 * Test the api_direct_messages_new() function with an user ID.
2640 public function testApiDirectMessagesNewWithUserId()
2642 $_POST['text'] = 'message_text';
2643 $_POST['user_id'] = $this->otherUser['id'];
2644 $result = api_direct_messages_new('json');
2645 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2649 * Test the api_direct_messages_new() function with a screen name.
2653 public function testApiDirectMessagesNewWithScreenName()
2655 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2656 $_POST['text'] = 'message_text';
2657 $_POST['screen_name'] = $this->friendUser['nick'];
2658 $result = api_direct_messages_new('json');
2659 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2660 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2661 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2665 * Test the api_direct_messages_new() function with a title.
2669 public function testApiDirectMessagesNewWithTitle()
2671 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2672 $_POST['text'] = 'message_text';
2673 $_POST['screen_name'] = $this->friendUser['nick'];
2674 $_REQUEST['title'] = 'message_title';
2675 $result = api_direct_messages_new('json');
2676 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2677 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2678 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2679 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2683 * Test the api_direct_messages_new() function with an RSS result.
2687 public function testApiDirectMessagesNewWithRss()
2689 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2690 $_POST['text'] = 'message_text';
2691 $_POST['screen_name'] = $this->friendUser['nick'];
2692 $result = api_direct_messages_new('rss');
2693 self::assertXml($result, 'direct-messages');
2697 * Test the api_direct_messages_destroy() function.
2701 public function testApiDirectMessagesDestroy()
2703 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2704 api_direct_messages_destroy('json');
2708 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2712 public function testApiDirectMessagesDestroyWithVerbose()
2714 $_GET['friendica_verbose'] = 'true';
2715 $result = api_direct_messages_destroy('json');
2719 'result' => 'error',
2720 'message' => 'message id or parenturi not specified'
2728 * Test the api_direct_messages_destroy() function without an authenticated user.
2732 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2734 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2735 $_SESSION['authenticated'] = false;
2736 api_direct_messages_destroy('json');
2740 * Test the api_direct_messages_destroy() function with a non-zero ID.
2744 public function testApiDirectMessagesDestroyWithId()
2746 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2747 $_REQUEST['id'] = 1;
2748 api_direct_messages_destroy('json');
2752 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2756 public function testApiDirectMessagesDestroyWithIdAndVerbose()
2758 $_REQUEST['id'] = 1;
2759 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2760 $_GET['friendica_verbose'] = 'true';
2761 $result = api_direct_messages_destroy('json');
2765 'result' => 'error',
2766 'message' => 'message id not in database'
2774 * Test the api_direct_messages_destroy() function with a non-zero ID.
2778 public function testApiDirectMessagesDestroyWithCorrectId()
2780 $this->markTestIncomplete('We need to add a dataset for this.');
2784 * Test the api_direct_messages_box() function.
2788 public function testApiDirectMessagesBoxWithSentbox()
2790 $_REQUEST['page'] = -1;
2791 $_REQUEST['max_id'] = 10;
2792 $result = api_direct_messages_box('json', 'sentbox', 'false');
2793 self::assertArrayHasKey('direct_message', $result);
2797 * Test the api_direct_messages_box() function.
2801 public function testApiDirectMessagesBoxWithConversation()
2803 $result = api_direct_messages_box('json', 'conversation', 'false');
2804 self::assertArrayHasKey('direct_message', $result);
2808 * Test the api_direct_messages_box() function.
2812 public function testApiDirectMessagesBoxWithAll()
2814 $result = api_direct_messages_box('json', 'all', 'false');
2815 self::assertArrayHasKey('direct_message', $result);
2819 * Test the api_direct_messages_box() function.
2823 public function testApiDirectMessagesBoxWithInbox()
2825 $result = api_direct_messages_box('json', 'inbox', 'false');
2826 self::assertArrayHasKey('direct_message', $result);
2830 * Test the api_direct_messages_box() function.
2834 public function testApiDirectMessagesBoxWithVerbose()
2836 $result = api_direct_messages_box('json', 'sentbox', 'true');
2840 'result' => 'error',
2841 'message' => 'no mails available'
2849 * Test the api_direct_messages_box() function with a RSS result.
2853 public function testApiDirectMessagesBoxWithRss()
2855 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2856 self::assertXml($result, 'direct-messages');
2860 * Test the api_direct_messages_box() function without an authenticated user.
2864 public function testApiDirectMessagesBoxWithUnallowedUser()
2866 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2867 $_SESSION['allow_api'] = false;
2868 $_GET['screen_name'] = $this->selfUser['nick'];
2869 api_direct_messages_box('json', 'sentbox', 'false');
2873 * Test the api_direct_messages_sentbox() function.
2877 public function testApiDirectMessagesSentbox()
2879 $result = api_direct_messages_sentbox('json');
2880 self::assertArrayHasKey('direct_message', $result);
2884 * Test the api_direct_messages_inbox() function.
2888 public function testApiDirectMessagesInbox()
2890 $result = api_direct_messages_inbox('json');
2891 self::assertArrayHasKey('direct_message', $result);
2895 * Test the api_direct_messages_all() function.
2899 public function testApiDirectMessagesAll()
2901 $result = api_direct_messages_all('json');
2902 self::assertArrayHasKey('direct_message', $result);
2906 * Test the api_direct_messages_conversation() function.
2910 public function testApiDirectMessagesConversation()
2912 $result = api_direct_messages_conversation('json');
2913 self::assertArrayHasKey('direct_message', $result);
2917 * Test the api_oauth_request_token() function.
2921 public function testApiOauthRequestToken()
2923 $this->markTestIncomplete('exit() kills phpunit as well');
2927 * Test the api_oauth_access_token() function.
2931 public function testApiOauthAccessToken()
2933 $this->markTestIncomplete('exit() kills phpunit as well');
2937 * Test the api_fr_photos_list() function.
2941 public function testApiFrPhotosList()
2943 $result = api_fr_photos_list('json');
2944 self::assertArrayHasKey('photo', $result);
2948 * Test the api_fr_photos_list() function without an authenticated user.
2952 public function testApiFrPhotosListWithoutAuthenticatedUser()
2954 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2955 $_SESSION['authenticated'] = false;
2956 api_fr_photos_list('json');
2960 * Test the api_fr_photo_create_update() function.
2962 public function testApiFrPhotoCreateUpdate()
2964 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2965 api_fr_photo_create_update('json');
2969 * Test the api_fr_photo_create_update() function without an authenticated user.
2973 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2975 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
2976 $_SESSION['authenticated'] = false;
2977 api_fr_photo_create_update('json');
2981 * Test the api_fr_photo_create_update() function with an album name.
2985 public function testApiFrPhotoCreateUpdateWithAlbum()
2987 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2988 $_REQUEST['album'] = 'album_name';
2989 api_fr_photo_create_update('json');
2993 * Test the api_fr_photo_create_update() function with the update mode.
2997 public function testApiFrPhotoCreateUpdateWithUpdate()
2999 $this->markTestIncomplete('We need to create a dataset for this');
3003 * Test the api_fr_photo_create_update() function with an uploaded file.
3007 public function testApiFrPhotoCreateUpdateWithFile()
3009 $this->markTestIncomplete();
3013 * Test the api_fr_photo_detail() function.
3017 public function testApiFrPhotoDetail()
3019 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3020 api_fr_photo_detail('json');
3024 * Test the api_fr_photo_detail() function without an authenticated user.
3028 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
3030 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3031 $_SESSION['authenticated'] = false;
3032 api_fr_photo_detail('json');
3036 * Test the api_fr_photo_detail() function with a photo ID.
3040 public function testApiFrPhotoDetailWithPhotoId()
3042 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
3043 $_REQUEST['photo_id'] = 1;
3044 api_fr_photo_detail('json');
3048 * Test the api_fr_photo_detail() function with a correct photo ID.
3052 public function testApiFrPhotoDetailCorrectPhotoId()
3054 $this->markTestIncomplete('We need to create a dataset for this.');
3058 * Test the api_account_update_profile_image() function.
3062 public function testApiAccountUpdateProfileImage()
3064 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3065 api_account_update_profile_image('json');
3069 * Test the api_account_update_profile_image() function without an authenticated user.
3073 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
3075 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
3076 $_SESSION['authenticated'] = false;
3077 api_account_update_profile_image('json');
3081 * Test the api_account_update_profile_image() function with an uploaded file.
3085 public function testApiAccountUpdateProfileImageWithUpload()
3087 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3088 $this->markTestIncomplete();
3093 * Test the api_account_update_profile() function.
3097 public function testApiAccountUpdateProfile()
3099 $_POST['name'] = 'new_name';
3100 $_POST['description'] = 'new_description';
3101 $result = api_account_update_profile('json');
3102 // We can't use assertSelfUser() here because the user object is missing some properties.
3103 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
3104 self::assertEquals('DFRN', $result['user']['location']);
3105 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
3106 self::assertEquals('dfrn', $result['user']['network']);
3107 self::assertEquals('new_name', $result['user']['name']);
3108 self::assertEquals('new_description', $result['user']['description']);
3112 * Test the check_acl_input() function.
3116 public function testCheckAclInput()
3118 $result = check_acl_input('<aclstring>');
3119 // Where does this result come from?
3120 self::assertEquals(1, $result);
3124 * Test the check_acl_input() function with an empty ACL string.
3128 public function testCheckAclInputWithEmptyAclString()
3130 $result = check_acl_input(' ');
3131 self::assertFalse($result);
3135 * Test the save_media_to_database() function.
3139 public function testSaveMediaToDatabase()
3141 $this->markTestIncomplete();
3145 * Test the post_photo_item() function.
3149 public function testPostPhotoItem()
3151 $this->markTestIncomplete();
3155 * Test the prepare_photo_data() function.
3159 public function testPreparePhotoData()
3161 $this->markTestIncomplete();
3165 * Test the api_share_as_retweet() function with a valid item.
3169 public function testApiShareAsRetweetWithValidItem()
3171 $this->markTestIncomplete();
3175 * Test the api_in_reply_to() function.
3179 public function testApiInReplyTo()
3181 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3182 self::assertArrayHasKey('status_id', $result);
3183 self::assertArrayHasKey('user_id', $result);
3184 self::assertArrayHasKey('status_id_str', $result);
3185 self::assertArrayHasKey('user_id_str', $result);
3186 self::assertArrayHasKey('screen_name', $result);
3190 * Test the api_in_reply_to() function with a valid item.
3194 public function testApiInReplyToWithValidItem()
3196 $this->markTestIncomplete();
3200 * Test the api_clean_plain_items() function.
3204 public function testApiCleanPlainItems()
3206 $_REQUEST['include_entities'] = 'true';
3207 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3208 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3212 * Test the api_best_nickname() function.
3216 public function testApiBestNickname()
3219 $result = api_best_nickname($contacts);
3220 self::assertNull($result);
3224 * Test the api_best_nickname() function with contacts.
3228 public function testApiBestNicknameWithContacts()
3230 $this->markTestIncomplete();
3234 * Test the api_friendica_group_show() function.
3238 public function testApiFriendicaGroupShow()
3240 $this->markTestIncomplete();
3244 * Test the api_friendica_group_delete() function.
3248 public function testApiFriendicaGroupDelete()
3250 $this->markTestIncomplete();
3254 * Test the api_lists_destroy() function.
3258 public function testApiListsDestroy()
3260 $this->markTestIncomplete();
3264 * Test the group_create() function.
3268 public function testGroupCreate()
3270 $this->markTestIncomplete();
3274 * Test the api_friendica_group_create() function.
3278 public function testApiFriendicaGroupCreate()
3280 $this->markTestIncomplete();
3284 * Test the api_lists_create() function.
3288 public function testApiListsCreate()
3290 $this->markTestIncomplete();
3294 * Test the api_friendica_group_update() function.
3298 public function testApiFriendicaGroupUpdate()
3300 $this->markTestIncomplete();
3304 * Test the api_lists_update() function.
3308 public function testApiListsUpdate()
3310 $this->markTestIncomplete();
3314 * Test the api_friendica_activity() function.
3318 public function testApiFriendicaActivity()
3320 $this->markTestIncomplete();
3324 * Test the api_friendica_notification_seen() function.
3328 public function testApiFriendicaNotificationSeen()
3330 $this->markTestIncomplete();
3334 * Test the api_friendica_direct_messages_setseen() function.
3338 public function testApiFriendicaDirectMessagesSetseen()
3340 $this->markTestIncomplete();
3344 * Test the api_friendica_direct_messages_search() function.
3348 public function testApiFriendicaDirectMessagesSearch()
3350 $this->markTestIncomplete();