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\Model\Post;
14 use Friendica\Module\Api\ApiResponse;
15 use Friendica\Module\BaseApi;
16 use Friendica\Network\HTTPException;
17 use Friendica\Security\BasicAuth;
18 use Friendica\Test\FixtureTest;
19 use Friendica\Util\Arrays;
20 use Friendica\Util\DateTimeFormat;
21 use Friendica\Util\Temporal;
22 use Monolog\Handler\TestHandler;
24 require_once __DIR__ . '/../../include/api.php';
27 * Tests for the API functions.
29 * Functions that use header() need to be tested in a separate process.
30 * @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
32 * @backupGlobals enabled
34 class ApiTest extends FixtureTest
37 * @var TestHandler Can handle log-outputs
44 protected $friendUser;
48 protected $wrongUserId;
53 /** @var IManageConfigValues */
57 * Create variables used by tests.
59 protected function setUp() : void
61 global $API, $called_api;
67 /** @var IManageConfigValues $config */
68 $this->config = $this->dice->create(IManageConfigValues::class);
70 $this->config->set('system', 'url', 'http://localhost');
71 $this->config->set('system', 'hostname', 'localhost');
72 $this->config->set('system', 'worker_dont_fork', true);
75 $this->config->set('config', 'hostname', 'localhost');
76 $this->config->set('system', 'throttle_limit_day', 100);
77 $this->config->set('system', 'throttle_limit_week', 100);
78 $this->config->set('system', 'throttle_limit_month', 100);
79 $this->config->set('system', 'theme', 'system_theme');
83 $this->app = DI::app();
85 DI::args()->setArgc(1);
87 // User data that the test database is populated with
90 'name' => 'Self contact',
91 'nick' => 'selfcontact',
92 'nurl' => 'http://localhost/profile/selfcontact'
96 'name' => 'Friend contact',
97 'nick' => 'friendcontact',
98 'nurl' => 'http://localhost/profile/friendcontact'
102 'name' => 'othercontact',
103 'nick' => 'othercontact',
104 'nurl' => 'http://localhost/profile/othercontact'
107 // User ID that we know is not in the database
108 $this->wrongUserId = 666;
110 DI::session()->start();
112 // 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($this->otherUser['name'], $user['name']);
151 self::assertEquals($this->otherUser['nick'], $user['screen_name']);
152 self::assertFalse($user['verified']);
156 * Assert that a status array contains expected keys.
158 * @param array $status Status array
162 private function assertStatus(array $status = [])
164 self::assertIsString($status['text'] ?? '');
165 self::assertIsInt($status['id'] ?? '');
166 // We could probably do more checks here.
170 * Assert that a list array contains expected keys.
172 * @param array $list List array
176 private function assertList(array $list = [])
178 self::assertIsString($list['name']);
179 self::assertIsInt($list['id']);
180 self::assertIsString('string', $list['id_str']);
181 self::assertContains($list['mode'], ['public', 'private']);
182 // We could probably do more checks here.
186 * Assert that the string is XML and contain the root element.
188 * @param string $result XML string
189 * @param string $root_element Root element name
193 private function assertXml($result = '', $root_element = '')
195 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
196 self::assertStringContainsString('<' . $root_element, $result);
197 // We could probably do more checks here.
201 * Get the path to a temporary empty PNG image.
203 * @return string Path
205 private function getTempImage()
207 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
211 // Empty 1x1 px PNG image
212 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
220 * Test the api_user() function.
224 public function testApiUser()
226 self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
230 * Test the api_user() function with an unallowed user.
234 public function testApiUserWithUnallowedUser()
236 // self::assertEquals(false, api_user());
240 * Test the api_source() function.
244 public function testApiSource()
246 self::assertEquals('api', api_source());
250 * Test the api_source() function with a Twidere user agent.
254 public function testApiSourceWithTwidere()
256 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
257 self::assertEquals('Twidere', api_source());
261 * Test the api_source() function with a GET parameter.
265 public function testApiSourceWithGet()
267 $_GET['source'] = 'source_name';
268 self::assertEquals('source_name', api_source());
272 * Test the api_date() function.
276 public function testApiDate()
278 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', DateTimeFormat::utc('1990-10-10', DateTimeFormat::API));
282 * Test the api_register_func() function.
286 public function testApiRegisterFunc()
298 self::assertTrue($API['api_path']['auth']);
299 self::assertEquals('method', $API['api_path']['method']);
300 self::assertTrue(is_callable($API['api_path']['func']));
304 * Test the BasicAuth::getCurrentUserID() function without any login.
306 * @runInSeparateProcess
307 * @preserveGlobalState disabled
308 * @preserveGlobalState disabled
310 public function testApiLoginWithoutLogin()
312 BasicAuth::setCurrentUserID();
313 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
314 BasicAuth::getCurrentUserID(true);
318 * Test the BasicAuth::getCurrentUserID() function with a bad login.
320 * @runInSeparateProcess
321 * @preserveGlobalState disabled
322 * @preserveGlobalState disabled
324 public function testApiLoginWithBadLogin()
326 BasicAuth::setCurrentUserID();
327 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
328 $_SERVER['PHP_AUTH_USER'] = 'user@server';
329 BasicAuth::getCurrentUserID(true);
333 * Test the BasicAuth::getCurrentUserID() function with oAuth.
337 public function testApiLoginWithOauth()
339 $this->markTestIncomplete('Can we test this easily?');
343 * Test the BasicAuth::getCurrentUserID() function with authentication provided by an addon.
347 public function testApiLoginWithAddonAuth()
349 $this->markTestIncomplete('Can we test this easily?');
353 * Test the BasicAuth::getCurrentUserID() function with a correct login.
355 * @runInSeparateProcess
356 * @preserveGlobalState disabled
357 * @doesNotPerformAssertions
359 public function testApiLoginWithCorrectLogin()
361 BasicAuth::setCurrentUserID();
362 $_SERVER['PHP_AUTH_USER'] = 'Test user';
363 $_SERVER['PHP_AUTH_PW'] = 'password';
364 BasicAuth::getCurrentUserID(true);
368 * Test the BasicAuth::getCurrentUserID() function with a remote user.
370 * @runInSeparateProcess
371 * @preserveGlobalState disabled
373 public function testApiLoginWithRemoteUser()
375 BasicAuth::setCurrentUserID();
376 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
377 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
378 BasicAuth::getCurrentUserID(true);
382 * Test the api_call() function.
384 * @runInSeparateProcess
385 * @preserveGlobalState disabled
387 public function testApiCall()
391 'method' => 'method',
392 'func' => function () {
393 return ['data' => ['some_data']];
396 $_SERVER['REQUEST_METHOD'] = 'method';
397 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
398 $_GET['callback'] = 'callback_name';
400 $args = DI::args()->determine($_SERVER, $_GET);
403 'callback_name(["some_data"])',
404 api_call($this->app, $args)
409 * Test the api_call() function with the profiled enabled.
411 * @runInSeparateProcess
412 * @preserveGlobalState disabled
414 public function testApiCallWithProfiler()
418 'method' => 'method',
419 'func' => function () {
420 return ['data' => ['some_data']];
424 $_SERVER['REQUEST_METHOD'] = 'method';
425 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
427 $args = DI::args()->determine($_SERVER, $_GET);
429 $this->config->set('system', 'profiler', true);
430 $this->config->set('rendertime', 'callstack', true);
431 $this->app->callstack = [
432 'database' => ['some_function' => 200],
433 'database_write' => ['some_function' => 200],
434 'cache' => ['some_function' => 200],
435 'cache_write' => ['some_function' => 200],
436 'network' => ['some_function' => 200]
441 api_call($this->app, $args)
446 * Test the api_call() function with a JSON result.
448 * @runInSeparateProcess
449 * @preserveGlobalState disabled
451 public function testApiCallWithJson()
455 'method' => 'method',
456 'func' => function () {
457 return ['data' => ['some_data']];
460 $_SERVER['REQUEST_METHOD'] = 'method';
461 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
463 $args = DI::args()->determine($_SERVER, $_GET);
467 api_call($this->app, $args)
472 * Test the api_call() function with an XML result.
474 * @runInSeparateProcess
475 * @preserveGlobalState disabled
477 public function testApiCallWithXml()
481 'method' => 'method',
482 'func' => function () {
486 $_SERVER['REQUEST_METHOD'] = 'method';
487 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
489 $args = DI::args()->determine($_SERVER, $_GET);
493 api_call($this->app, $args)
498 * Test the api_call() function with an RSS result.
500 * @runInSeparateProcess
501 * @preserveGlobalState disabled
503 public function testApiCallWithRss()
507 'method' => 'method',
508 'func' => function () {
512 $_SERVER['REQUEST_METHOD'] = 'method';
513 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
515 $args = DI::args()->determine($_SERVER, $_GET);
518 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
520 api_call($this->app, $args)
525 * Test the api_call() function with an Atom result.
527 * @runInSeparateProcess
528 * @preserveGlobalState disabled
530 public function testApiCallWithAtom()
534 'method' => 'method',
535 'func' => function () {
539 $_SERVER['REQUEST_METHOD'] = 'method';
540 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
542 $args = DI::args()->determine($_SERVER, $_GET);
545 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
547 api_call($this->app, $args)
552 * Test the api_rss_extra() function.
556 public function testApiRssExtra()
559 $user_info = ['url' => 'user_url', 'lang' => 'en'];
560 $result = api_rss_extra([], $user_info);
561 self::assertEquals($user_info, $result['$user']);
562 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
563 self::assertArrayHasKey('self', $result['$rss']);
564 self::assertArrayHasKey('base', $result['$rss']);
565 self::assertArrayHasKey('updated', $result['$rss']);
566 self::assertArrayHasKey('atom_updated', $result['$rss']);
567 self::assertArrayHasKey('language', $result['$rss']);
568 self::assertArrayHasKey('logo', $result['$rss']);
573 * Test the api_rss_extra() function without any user info.
577 public function testApiRssExtraWithoutUserInfo()
580 $result = api_rss_extra([], null);
581 self::assertIsArray($result['$user']);
582 self::assertArrayHasKey('alternate', $result['$rss']);
583 self::assertArrayHasKey('self', $result['$rss']);
584 self::assertArrayHasKey('base', $result['$rss']);
585 self::assertArrayHasKey('updated', $result['$rss']);
586 self::assertArrayHasKey('atom_updated', $result['$rss']);
587 self::assertArrayHasKey('language', $result['$rss']);
588 self::assertArrayHasKey('logo', $result['$rss']);
593 * Test the api_get_user() function.
597 public function testApiGetUser()
599 // $user = api_get_user();
600 // self::assertSelfUser($user);
601 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
602 // self::assertEquals('6fdbe8', $user['profile_link_color']);
603 // self::assertEquals('ededed', $user['profile_background_color']);
607 * Test the api_get_user() function with a Frio schema.
611 public function testApiGetUserWithFrioSchema()
613 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
614 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
615 // $user = api_get_user();
616 // self::assertSelfUser($user);
617 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
618 // self::assertEquals('6fdbe8', $user['profile_link_color']);
619 // self::assertEquals('ededed', $user['profile_background_color']);
623 * Test the api_get_user() function with an empty Frio schema.
627 public function testApiGetUserWithEmptyFrioSchema()
629 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
630 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
631 // $user = api_get_user();
632 // self::assertSelfUser($user);
633 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
634 // self::assertEquals('6fdbe8', $user['profile_link_color']);
635 // self::assertEquals('ededed', $user['profile_background_color']);
639 * Test the api_get_user() function with a custom Frio schema.
643 public function testApiGetUserWithCustomFrioSchema()
645 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
646 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
647 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
648 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
649 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
650 // $user = api_get_user();
651 // self::assertSelfUser($user);
652 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
653 // self::assertEquals('123456', $user['profile_link_color']);
654 // self::assertEquals('123456', $user['profile_background_color']);
658 * Test the api_get_user() function with an user that is not allowed to use the API.
660 * @runInSeparateProcess
661 * @preserveGlobalState disabled
663 public function testApiGetUserWithoutApiUser()
665 // api_get_user() with empty parameters is not used anymore
667 $_SERVER['PHP_AUTH_USER'] = 'Test user';
668 $_SERVER['PHP_AUTH_PW'] = 'password';
669 BasicAuth::setCurrentUserID();
670 self::assertFalse(api_get_user());
675 * Test the api_get_user() function with an user ID in a GET parameter.
679 public function testApiGetUserWithGetId()
681 // self::assertOtherUser(api_get_user());
685 * Test the api_get_user() function with a wrong user ID in a GET parameter.
689 public function testApiGetUserWithWrongGetId()
691 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
692 // self::assertOtherUser(api_get_user());
696 * Test the api_get_user() function with an user name in a GET parameter.
700 public function testApiGetUserWithGetName()
702 // self::assertSelfUser(api_get_user());
706 * Test the api_get_user() function with a profile URL in a GET parameter.
710 public function testApiGetUserWithGetUrl()
712 // self::assertSelfUser(api_get_user());
716 * Test the api_get_user() function with an user ID in the API path.
720 public function testApiGetUserWithNumericCalledApi()
722 // global $called_api;
723 // $called_api = ['api_path'];
724 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
725 // self::assertOtherUser(api_get_user());
729 * Test the api_get_user() function with the $called_api global variable.
733 public function testApiGetUserWithCalledApi()
735 // global $called_api;
736 // $called_api = ['api', 'api_path'];
737 // self::assertSelfUser(api_get_user());
741 * Test the Arrays::walkRecursive() function.
745 public function testApiWalkRecursive()
750 Arrays::walkRecursive(
753 // Should we test this with a callback that actually does something?
761 * Test the Arrays::walkRecursive() function with an array.
765 public function testApiWalkRecursiveWithArray()
767 $array = [['item1'], ['item2']];
770 Arrays::walkRecursive(
773 // Should we test this with a callback that actually does something?
781 * Test the BaseApi::reformatXML() function.
785 public function testApiReformatXml()
789 self::assertTrue(ApiResponse::reformatXML($item, $key));
790 self::assertEquals('true', $item);
794 * Test the BaseApi::reformatXML() function with a statusnet_api key.
798 public function testApiReformatXmlWithStatusnetKey()
801 $key = 'statusnet_api';
802 self::assertTrue(ApiResponse::reformatXML($item, $key));
803 self::assertEquals('statusnet:api', $key);
807 * Test the BaseApi::reformatXML() function with a friendica_api key.
811 public function testApiReformatXmlWithFriendicaKey()
814 $key = 'friendica_api';
815 self::assertTrue(ApiResponse::reformatXML($item, $key));
816 self::assertEquals('friendica:api', $key);
820 * Test the BaseApi::createXML() function.
824 public function testApiCreateXml()
827 '<?xml version="1.0"?>' . "\n" .
828 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
829 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
830 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
831 ' <data>some_data</data>' . "\n" .
832 '</root_element>' . "\n",
833 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
838 * Test the BaseApi::createXML() function without any XML namespace.
842 public function testApiCreateXmlWithoutNamespaces()
845 '<?xml version="1.0"?>' . "\n" .
847 ' <data>some_data</data>' . "\n" .
849 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
854 * Test the BaseApi::formatData() function.
858 public function testApiFormatData()
860 $data = ['some_data'];
861 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
865 * Test the BaseApi::formatData() function with an XML result.
869 public function testApiFormatDataWithXml()
872 '<?xml version="1.0"?>' . "\n" .
873 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
874 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
875 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
876 ' <data>some_data</data>' . "\n" .
877 '</root_element>' . "\n",
878 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
883 * Test the api_account_verify_credentials() function.
887 public function testApiAccountVerifyCredentials()
889 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
893 * Test the api_account_verify_credentials() function without an authenticated user.
897 public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
899 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
900 BasicAuth::setCurrentUserID();
901 $_SESSION['authenticated'] = false;
902 api_account_verify_credentials('json');
906 * Test the requestdata() function.
910 public function testRequestdata()
912 self::assertNull(requestdata('variable_name'));
916 * Test the requestdata() function with a POST parameter.
920 public function testRequestdataWithPost()
922 $_POST['variable_name'] = 'variable_value';
923 self::assertEquals('variable_value', requestdata('variable_name'));
927 * Test the requestdata() function with a GET parameter.
931 public function testRequestdataWithGet()
933 $_GET['variable_name'] = 'variable_value';
934 self::assertEquals('variable_value', requestdata('variable_name'));
938 * Test the api_statuses_mediap() function.
942 public function testApiStatusesMediap()
944 DI::args()->setArgc(2);
952 'tmp_name' => $this->getTempImage(),
953 'name' => 'spacer.png',
954 'type' => 'image/png'
957 $_GET['status'] = '<b>Status content</b>';
959 $result = api_statuses_mediap('json');
960 self::assertStatus($result['status']);
964 * Test the api_statuses_mediap() function without an authenticated user.
968 public function testApiStatusesMediapWithoutAuthenticatedUser()
970 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
971 BasicAuth::setCurrentUserID();
972 $_SESSION['authenticated'] = false;
973 api_statuses_mediap('json');
977 * Test the api_statuses_update() function.
981 public function testApiStatusesUpdate()
983 $_GET['status'] = 'Status content #friendica';
984 $_GET['in_reply_to_status_id'] = -1;
993 'tmp_name' => $this->getTempImage(),
994 'name' => 'spacer.png',
995 'type' => 'image/png'
999 $result = api_statuses_update('json');
1000 self::assertStatus($result['status']);
1004 * Test the api_statuses_update() function with an HTML status.
1008 public function testApiStatusesUpdateWithHtml()
1010 $_GET['htmlstatus'] = '<b>Status content</b>';
1012 $result = api_statuses_update('json');
1013 self::assertStatus($result['status']);
1017 * Test the api_statuses_update() function without an authenticated user.
1021 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1023 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1024 BasicAuth::setCurrentUserID();
1025 $_SESSION['authenticated'] = false;
1026 api_statuses_update('json');
1030 * Test the api_statuses_update() function with a parent status.
1034 public function testApiStatusesUpdateWithParent()
1036 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1040 * Test the api_statuses_update() function with a media_ids parameter.
1044 public function testApiStatusesUpdateWithMediaIds()
1046 $this->markTestIncomplete();
1050 * Test the api_statuses_update() function with the throttle limit reached.
1054 public function testApiStatusesUpdateWithDayThrottleReached()
1056 $this->markTestIncomplete();
1060 * Test the api_media_upload() function.
1061 * @runInSeparateProcess
1062 * @preserveGlobalState disabled
1064 public function testApiMediaUpload()
1066 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1071 * Test the api_media_upload() function without an authenticated user.
1075 public function testApiMediaUploadWithoutAuthenticatedUser()
1077 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1078 BasicAuth::setCurrentUserID();
1079 $_SESSION['authenticated'] = false;
1084 * Test the api_media_upload() function with an invalid uploaded media.
1088 public function testApiMediaUploadWithMedia()
1090 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1094 'tmp_name' => 'tmp_name'
1101 * Test the api_media_upload() function with an valid uploaded media.
1105 public function testApiMediaUploadWithValidMedia()
1113 'tmp_name' => $this->getTempImage(),
1114 'name' => 'spacer.png',
1115 'type' => 'image/png'
1119 DI::args()->setArgc(2);
1121 $result = api_media_upload();
1122 self::assertEquals('image/png', $result['media']['image']['image_type']);
1123 self::assertEquals(1, $result['media']['image']['w']);
1124 self::assertEquals(1, $result['media']['image']['h']);
1125 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1129 * Test the api_status_show() function.
1131 public function testApiStatusShowWithJson()
1133 $result = api_status_show('json', 1);
1134 self::assertStatus($result['status']);
1138 * Test the api_status_show() function with an XML result.
1140 public function testApiStatusShowWithXml()
1142 $result = api_status_show('xml', 1);
1143 self::assertXml($result, 'statuses');
1147 * Test the api_get_last_status() function
1149 public function testApiGetLastStatus()
1151 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1153 self::assertNotNull($item);
1157 * Test the api_users_show() function.
1161 public function testApiUsersShow()
1163 $result = api_users_show('json');
1164 // We can't use assertSelfUser() here because the user object is missing some properties.
1165 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1166 self::assertEquals('DFRN', $result['user']['location']);
1167 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1168 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1169 self::assertTrue($result['user']['verified']);
1173 * Test the api_users_show() function with an XML result.
1177 public function testApiUsersShowWithXml()
1179 $result = api_users_show('xml');
1180 self::assertXml($result, 'statuses');
1184 * Test the api_users_search() function.
1188 public function testApiUsersSearch()
1190 $_GET['q'] = 'othercontact';
1191 $result = api_users_search('json');
1192 self::assertOtherUser($result['users'][0]);
1196 * Test the api_users_search() function with an XML result.
1200 public function testApiUsersSearchWithXml()
1202 $_GET['q'] = 'othercontact';
1203 $result = api_users_search('xml');
1204 self::assertXml($result, 'users');
1208 * Test the api_users_search() function without a GET q parameter.
1212 public function testApiUsersSearchWithoutQuery()
1214 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1215 api_users_search('json');
1219 * Test the api_users_lookup() function.
1223 public function testApiUsersLookup()
1225 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1226 api_users_lookup('json');
1230 * Test the api_users_lookup() function with an user ID.
1234 public function testApiUsersLookupWithUserId()
1236 $_REQUEST['user_id'] = $this->otherUser['id'];
1237 $result = api_users_lookup('json');
1238 self::assertOtherUser($result['users'][0]);
1242 * Test the api_search() function.
1246 public function testApiSearch()
1248 $_REQUEST['q'] = 'reply';
1249 $_REQUEST['max_id'] = 10;
1250 $result = api_search('json');
1251 foreach ($result['status'] as $status) {
1252 self::assertStatus($status);
1253 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1258 * Test the api_search() function a count parameter.
1262 public function testApiSearchWithCount()
1264 $_REQUEST['q'] = 'reply';
1265 $_REQUEST['count'] = 20;
1266 $result = api_search('json');
1267 foreach ($result['status'] as $status) {
1268 self::assertStatus($status);
1269 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1274 * Test the api_search() function with an rpp parameter.
1278 public function testApiSearchWithRpp()
1280 $_REQUEST['q'] = 'reply';
1281 $_REQUEST['rpp'] = 20;
1282 $result = api_search('json');
1283 foreach ($result['status'] as $status) {
1284 self::assertStatus($status);
1285 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1290 * Test the api_search() function with an q parameter contains hashtag.
1291 * @doesNotPerformAssertions
1293 public function testApiSearchWithHashtag()
1295 $_REQUEST['q'] = '%23friendica';
1296 $result = api_search('json');
1297 foreach ($result['status'] as $status) {
1298 self::assertStatus($status);
1299 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1304 * Test the api_search() function with an exclude_replies parameter.
1305 * @doesNotPerformAssertions
1307 public function testApiSearchWithExcludeReplies()
1309 $_REQUEST['max_id'] = 10;
1310 $_REQUEST['exclude_replies'] = true;
1311 $_REQUEST['q'] = 'friendica';
1312 $result = api_search('json');
1313 foreach ($result['status'] as $status) {
1314 self::assertStatus($status);
1319 * Test the api_search() function without an authenticated user.
1323 public function testApiSearchWithUnallowedUser()
1325 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1326 BasicAuth::setCurrentUserID();
1331 * Test the api_search() function without any GET query parameter.
1335 public function testApiSearchWithoutQuery()
1337 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1342 * Test the api_statuses_home_timeline() function.
1346 public function testApiStatusesHomeTimeline()
1348 $_REQUEST['max_id'] = 10;
1349 $_REQUEST['exclude_replies'] = true;
1350 $_REQUEST['conversation_id'] = 1;
1351 $result = api_statuses_home_timeline('json');
1352 self::assertNotEmpty($result['status']);
1353 foreach ($result['status'] as $status) {
1354 self::assertStatus($status);
1359 * Test the api_statuses_home_timeline() function with a negative page parameter.
1363 public function testApiStatusesHomeTimelineWithNegativePage()
1365 $_REQUEST['page'] = -2;
1366 $result = api_statuses_home_timeline('json');
1367 self::assertNotEmpty($result['status']);
1368 foreach ($result['status'] as $status) {
1369 self::assertStatus($status);
1374 * Test the api_statuses_home_timeline() with an unallowed user.
1378 public function testApiStatusesHomeTimelineWithUnallowedUser()
1380 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1381 BasicAuth::setCurrentUserID();
1382 api_statuses_home_timeline('json');
1386 * Test the api_statuses_home_timeline() function with an RSS result.
1390 public function testApiStatusesHomeTimelineWithRss()
1392 $result = api_statuses_home_timeline('rss');
1393 self::assertXml($result, 'statuses');
1397 * Test the api_statuses_public_timeline() function.
1401 public function testApiStatusesPublicTimeline()
1403 $_REQUEST['max_id'] = 10;
1404 $_REQUEST['conversation_id'] = 1;
1405 $result = api_statuses_public_timeline('json');
1406 self::assertNotEmpty($result['status']);
1407 foreach ($result['status'] as $status) {
1408 self::assertStatus($status);
1413 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1417 public function testApiStatusesPublicTimelineWithExcludeReplies()
1419 $_REQUEST['max_id'] = 10;
1420 $_REQUEST['exclude_replies'] = true;
1421 $result = api_statuses_public_timeline('json');
1422 self::assertNotEmpty($result['status']);
1423 foreach ($result['status'] as $status) {
1424 self::assertStatus($status);
1429 * Test the api_statuses_public_timeline() function with a negative page parameter.
1433 public function testApiStatusesPublicTimelineWithNegativePage()
1435 $_REQUEST['page'] = -2;
1436 $result = api_statuses_public_timeline('json');
1437 self::assertNotEmpty($result['status']);
1438 foreach ($result['status'] as $status) {
1439 self::assertStatus($status);
1444 * Test the api_statuses_public_timeline() function with an unallowed user.
1448 public function testApiStatusesPublicTimelineWithUnallowedUser()
1450 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1451 BasicAuth::setCurrentUserID();
1452 api_statuses_public_timeline('json');
1456 * Test the api_statuses_public_timeline() function with an RSS result.
1460 public function testApiStatusesPublicTimelineWithRss()
1462 $result = api_statuses_public_timeline('rss');
1463 self::assertXml($result, 'statuses');
1467 * Test the api_statuses_networkpublic_timeline() function.
1471 public function testApiStatusesNetworkpublicTimeline()
1473 $_REQUEST['max_id'] = 10;
1474 $result = api_statuses_networkpublic_timeline('json');
1475 self::assertNotEmpty($result['status']);
1476 foreach ($result['status'] as $status) {
1477 self::assertStatus($status);
1482 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1486 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1488 $_REQUEST['page'] = -2;
1489 $result = api_statuses_networkpublic_timeline('json');
1490 self::assertNotEmpty($result['status']);
1491 foreach ($result['status'] as $status) {
1492 self::assertStatus($status);
1497 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1501 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1503 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1504 BasicAuth::setCurrentUserID();
1505 api_statuses_networkpublic_timeline('json');
1509 * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1513 public function testApiStatusesNetworkpublicTimelineWithRss()
1515 $result = api_statuses_networkpublic_timeline('rss');
1516 self::assertXml($result, 'statuses');
1520 * Test the api_statuses_show() function.
1524 public function testApiStatusesShow()
1526 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1527 api_statuses_show('json');
1531 * Test the api_statuses_show() function with an ID.
1535 public function testApiStatusesShowWithId()
1537 DI::args()->setArgv(['', '', '', 1]);
1538 $result = api_statuses_show('json');
1539 self::assertStatus($result['status']);
1543 * Test the api_statuses_show() function with the conversation parameter.
1547 public function testApiStatusesShowWithConversation()
1549 DI::args()->setArgv(['', '', '', 1]);
1550 $_REQUEST['conversation'] = 1;
1551 $result = api_statuses_show('json');
1552 self::assertNotEmpty($result['status']);
1553 foreach ($result['status'] as $status) {
1554 self::assertStatus($status);
1559 * Test the api_statuses_show() function with an unallowed user.
1563 public function testApiStatusesShowWithUnallowedUser()
1565 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1566 BasicAuth::setCurrentUserID();
1567 api_statuses_show('json');
1571 * Test the api_conversation_show() function.
1575 public function testApiConversationShow()
1577 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1578 api_conversation_show('json');
1582 * Test the api_conversation_show() function with an ID.
1586 public function testApiConversationShowWithId()
1588 DI::args()->setArgv(['', '', '', 1]);
1589 $_REQUEST['max_id'] = 10;
1590 $_REQUEST['page'] = -2;
1591 $result = api_conversation_show('json');
1592 self::assertNotEmpty($result['status']);
1593 foreach ($result['status'] as $status) {
1594 self::assertStatus($status);
1599 * Test the api_conversation_show() function with an unallowed user.
1603 public function testApiConversationShowWithUnallowedUser()
1605 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1606 BasicAuth::setCurrentUserID();
1607 api_conversation_show('json');
1611 * Test the api_statuses_repeat() function.
1615 public function testApiStatusesRepeat()
1617 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1618 api_statuses_repeat('json');
1622 * Test the api_statuses_repeat() function without an authenticated user.
1626 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1628 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1629 BasicAuth::setCurrentUserID();
1630 $_SESSION['authenticated'] = false;
1631 api_statuses_repeat('json');
1635 * Test the api_statuses_repeat() function with an ID.
1639 public function testApiStatusesRepeatWithId()
1641 DI::args()->setArgv(['', '', '', 1]);
1642 $result = api_statuses_repeat('json');
1643 self::assertStatus($result['status']);
1645 // Also test with a shared status
1646 DI::args()->setArgv(['', '', '', 5]);
1647 $result = api_statuses_repeat('json');
1648 self::assertStatus($result['status']);
1652 * Test the api_statuses_destroy() function.
1656 public function testApiStatusesDestroy()
1658 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1659 api_statuses_destroy('json');
1663 * Test the api_statuses_destroy() function without an authenticated user.
1667 public function testApiStatusesDestroyWithoutAuthenticatedUser()
1669 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1670 BasicAuth::setCurrentUserID();
1671 $_SESSION['authenticated'] = false;
1672 api_statuses_destroy('json');
1676 * Test the api_statuses_destroy() function with an ID.
1680 public function testApiStatusesDestroyWithId()
1682 DI::args()->setArgv(['', '', '', 1]);
1683 $result = api_statuses_destroy('json');
1684 self::assertStatus($result['status']);
1688 * Test the api_statuses_mentions() function.
1692 public function testApiStatusesMentions()
1694 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1695 $_REQUEST['max_id'] = 10;
1696 $result = api_statuses_mentions('json');
1697 self::assertEmpty($result['status']);
1698 // We should test with mentions in the database.
1702 * Test the api_statuses_mentions() function with a negative page parameter.
1706 public function testApiStatusesMentionsWithNegativePage()
1708 $_REQUEST['page'] = -2;
1709 $result = api_statuses_mentions('json');
1710 self::assertEmpty($result['status']);
1714 * Test the api_statuses_mentions() function with an unallowed user.
1718 public function testApiStatusesMentionsWithUnallowedUser()
1720 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1721 BasicAuth::setCurrentUserID();
1722 api_statuses_mentions('json');
1726 * Test the api_statuses_mentions() function with an RSS result.
1730 public function testApiStatusesMentionsWithRss()
1732 $result = api_statuses_mentions('rss');
1733 self::assertXml($result, 'statuses');
1737 * Test the api_statuses_user_timeline() function.
1741 public function testApiStatusesUserTimeline()
1743 $_REQUEST['user_id'] = 42;
1744 $_REQUEST['max_id'] = 10;
1745 $_REQUEST['exclude_replies'] = true;
1746 $_REQUEST['conversation_id'] = 7;
1748 $result = api_statuses_user_timeline('json');
1749 self::assertNotEmpty($result['status']);
1750 foreach ($result['status'] as $status) {
1751 self::assertStatus($status);
1756 * Test the api_statuses_user_timeline() function with a negative page parameter.
1760 public function testApiStatusesUserTimelineWithNegativePage()
1762 $_REQUEST['user_id'] = 42;
1763 $_REQUEST['page'] = -2;
1765 $result = api_statuses_user_timeline('json');
1766 self::assertNotEmpty($result['status']);
1767 foreach ($result['status'] as $status) {
1768 self::assertStatus($status);
1773 * Test the api_statuses_user_timeline() function with an RSS result.
1777 public function testApiStatusesUserTimelineWithRss()
1779 $result = api_statuses_user_timeline('rss');
1780 self::assertXml($result, 'statuses');
1784 * Test the api_statuses_user_timeline() function with an unallowed user.
1788 public function testApiStatusesUserTimelineWithUnallowedUser()
1790 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1791 BasicAuth::setCurrentUserID();
1792 api_statuses_user_timeline('json');
1796 * Test the api_favorites_create_destroy() function.
1800 public function testApiFavoritesCreateDestroy()
1802 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1803 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1804 api_favorites_create_destroy('json');
1808 * Test the api_favorites_create_destroy() function with an invalid ID.
1812 public function testApiFavoritesCreateDestroyWithInvalidId()
1814 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1815 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1816 api_favorites_create_destroy('json');
1820 * Test the api_favorites_create_destroy() function with an invalid action.
1824 public function testApiFavoritesCreateDestroyWithInvalidAction()
1826 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1827 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1828 $_REQUEST['id'] = 1;
1829 api_favorites_create_destroy('json');
1833 * Test the api_favorites_create_destroy() function with the create action.
1837 public function testApiFavoritesCreateDestroyWithCreateAction()
1839 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1840 $_REQUEST['id'] = 3;
1841 $result = api_favorites_create_destroy('json');
1842 self::assertStatus($result['status']);
1846 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1850 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1852 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1853 $_REQUEST['id'] = 3;
1854 $result = api_favorites_create_destroy('rss');
1855 self::assertXml($result, 'status');
1859 * Test the api_favorites_create_destroy() function with the destroy action.
1863 public function testApiFavoritesCreateDestroyWithDestroyAction()
1865 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1866 $_REQUEST['id'] = 3;
1867 $result = api_favorites_create_destroy('json');
1868 self::assertStatus($result['status']);
1872 * Test the api_favorites_create_destroy() function without an authenticated user.
1876 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1878 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1879 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1880 BasicAuth::setCurrentUserID();
1881 $_SESSION['authenticated'] = false;
1882 api_favorites_create_destroy('json');
1886 * Test the api_favorites() function.
1890 public function testApiFavorites()
1892 $_REQUEST['page'] = -1;
1893 $_REQUEST['max_id'] = 10;
1894 $result = api_favorites('json');
1895 foreach ($result['status'] as $status) {
1896 self::assertStatus($status);
1901 * Test the api_favorites() function with an RSS result.
1905 public function testApiFavoritesWithRss()
1907 $result = api_favorites('rss');
1908 self::assertXml($result, 'statuses');
1912 * Test the api_favorites() function with an unallowed user.
1916 public function testApiFavoritesWithUnallowedUser()
1918 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1919 BasicAuth::setCurrentUserID();
1920 api_favorites('json');
1924 * Test the api_format_messages() function.
1928 public function testApiFormatMessages()
1930 $result = api_format_messages(
1931 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1932 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1933 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1935 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1936 self::assertEquals(1, $result['id']);
1937 self::assertEquals(2, $result['recipient_id']);
1938 self::assertEquals(3, $result['sender_id']);
1939 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1940 self::assertEquals('sender_name', $result['sender_screen_name']);
1944 * Test the api_format_messages() function with HTML.
1948 public function testApiFormatMessagesWithHtmlText()
1950 $_GET['getText'] = 'html';
1951 $result = api_format_messages(
1952 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1953 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1954 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1956 self::assertEquals('item_title', $result['title']);
1957 self::assertEquals('<strong>item_body</strong>', $result['text']);
1961 * Test the api_format_messages() function with plain text.
1965 public function testApiFormatMessagesWithPlainText()
1967 $_GET['getText'] = 'plain';
1968 $result = api_format_messages(
1969 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1970 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1971 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1973 self::assertEquals('item_title', $result['title']);
1974 self::assertEquals('item_body', $result['text']);
1978 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1982 public function testApiFormatMessagesWithoutUserObjects()
1984 $_GET['getUserObjects'] = 'false';
1985 $result = api_format_messages(
1986 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1987 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1988 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1990 self::assertTrue(!isset($result['sender']));
1991 self::assertTrue(!isset($result['recipient']));
1995 * Test the api_convert_item() function.
1999 public function testApiConvertItem()
2001 $result = api_convert_item(
2003 'network' => 'feed',
2004 'title' => 'item_title',
2006 // We need a long string to test that it is correctly cut
2007 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2008 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2009 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2010 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2011 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2012 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2013 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2014 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2015 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2016 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2017 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2018 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2019 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2020 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2021 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2022 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2023 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2024 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2025 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2026 'repellat officia illum quos impedit quam iste esse unde qui ' .
2027 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2028 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2029 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2030 'plink' => 'item_plink'
2033 self::assertStringStartsWith('item_title', $result['text']);
2034 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2038 * Test the api_convert_item() function with an empty item body.
2042 public function testApiConvertItemWithoutBody()
2044 $result = api_convert_item(
2046 'network' => 'feed',
2047 'title' => 'item_title',
2050 'plink' => 'item_plink'
2053 self::assertEquals("item_title", $result['text']);
2054 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2058 * Test the api_convert_item() function with the title in the body.
2062 public function testApiConvertItemWithTitleInBody()
2064 $result = api_convert_item(
2066 'title' => 'item_title',
2067 'body' => 'item_title item_body',
2071 self::assertEquals('item_title item_body', $result['text']);
2072 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2076 * Test the api_get_attachments() function.
2080 public function testApiGetAttachments()
2083 self::assertEmpty(api_get_attachments($body, 0));
2087 * Test the api_get_attachments() function with an img tag.
2091 public function testApiGetAttachmentsWithImage()
2093 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2094 self::assertIsArray(api_get_attachments($body, 0));
2098 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2102 public function testApiGetAttachmentsWithImageAndAndStatus()
2104 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2105 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2106 self::assertIsArray(api_get_attachments($body, 0));
2110 * Test the api_get_entitities() function.
2114 public function testApiGetEntitities()
2117 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2121 * Test the api_get_entitities() function with the include_entities parameter.
2125 public function testApiGetEntititiesWithIncludeEntities()
2127 $_REQUEST['include_entities'] = 'true';
2129 $result = api_get_entitities($text, 'bbcode', 0);
2130 self::assertIsArray($result['hashtags']);
2131 self::assertIsArray($result['symbols']);
2132 self::assertIsArray($result['urls']);
2133 self::assertIsArray($result['user_mentions']);
2137 * Test the api_format_items_embeded_images() function.
2141 public function testApiFormatItemsEmbededImages()
2144 'text ' . DI::baseUrl() . '/display/item_guid',
2145 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2150 * Test the api_contactlink_to_array() function.
2154 public function testApiContactlinkToArray()
2161 api_contactlink_to_array('text')
2166 * Test the api_contactlink_to_array() function with an URL.
2170 public function testApiContactlinkToArrayWithUrl()
2174 'name' => ['link_text'],
2177 api_contactlink_to_array('text <a href="url">link_text</a>')
2182 * Test the api_format_items_activities() function.
2186 public function testApiFormatItemsActivities()
2188 $item = ['uid' => 0, 'uri' => ''];
2189 $result = api_format_items_activities($item);
2190 self::assertArrayHasKey('like', $result);
2191 self::assertArrayHasKey('dislike', $result);
2192 self::assertArrayHasKey('attendyes', $result);
2193 self::assertArrayHasKey('attendno', $result);
2194 self::assertArrayHasKey('attendmaybe', $result);
2198 * Test the api_format_items_activities() function with an XML result.
2202 public function testApiFormatItemsActivitiesWithXml()
2204 $item = ['uid' => 0, 'uri' => ''];
2205 $result = api_format_items_activities($item, 'xml');
2206 self::assertArrayHasKey('friendica:like', $result);
2207 self::assertArrayHasKey('friendica:dislike', $result);
2208 self::assertArrayHasKey('friendica:attendyes', $result);
2209 self::assertArrayHasKey('friendica:attendno', $result);
2210 self::assertArrayHasKey('friendica:attendmaybe', $result);
2214 * Test the api_format_items() function.
2215 * @doesNotPerformAssertions
2217 public function testApiFormatItems()
2219 $items = Post::selectToArray([], ['uid' => 42]);
2220 foreach ($items as $item) {
2221 $status = api_format_item($item);
2222 self::assertStatus($status);
2227 * Test the api_format_items() function with an XML result.
2228 * @doesNotPerformAssertions
2230 public function testApiFormatItemsWithXml()
2232 $items = Post::selectToArray([], ['uid' => 42]);
2233 foreach ($items as $item) {
2234 $status = api_format_item($item, 'xml');
2235 self::assertStatus($status);
2240 * Test the api_lists_list() function.
2244 public function testApiListsList()
2246 $result = api_lists_list('json');
2247 self::assertEquals(['lists_list' => []], $result);
2251 * Test the api_lists_ownerships() function.
2255 public function testApiListsOwnerships()
2257 $result = api_lists_ownerships('json');
2258 foreach ($result['lists']['lists'] as $list) {
2259 self::assertList($list);
2264 * Test the api_lists_ownerships() function without an authenticated user.
2268 public function testApiListsOwnershipsWithoutAuthenticatedUser()
2270 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2271 BasicAuth::setCurrentUserID();
2272 $_SESSION['authenticated'] = false;
2273 api_lists_ownerships('json');
2277 * Test the api_lists_statuses() function.
2281 public function testApiListsStatuses()
2283 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2284 api_lists_statuses('json');
2288 * Test the api_lists_statuses() function with a list ID.
2289 * @doesNotPerformAssertions
2291 public function testApiListsStatusesWithListId()
2293 $_REQUEST['list_id'] = 1;
2294 $_REQUEST['page'] = -1;
2295 $_REQUEST['max_id'] = 10;
2296 $result = api_lists_statuses('json');
2297 foreach ($result['status'] as $status) {
2298 self::assertStatus($status);
2303 * Test the api_lists_statuses() function with a list ID and a RSS result.
2307 public function testApiListsStatusesWithListIdAndRss()
2309 $_REQUEST['list_id'] = 1;
2310 $result = api_lists_statuses('rss');
2311 self::assertXml($result, 'statuses');
2315 * Test the api_lists_statuses() function with an unallowed user.
2319 public function testApiListsStatusesWithUnallowedUser()
2321 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2322 BasicAuth::setCurrentUserID();
2323 api_lists_statuses('json');
2327 * Test the api_statuses_f() function.
2331 public function testApiStatusesFWithFriends()
2334 $result = api_statuses_f('friends');
2335 self::assertArrayHasKey('user', $result);
2339 * Test the api_statuses_f() function.
2343 public function testApiStatusesFWithFollowers()
2345 $result = api_statuses_f('followers');
2346 self::assertArrayHasKey('user', $result);
2350 * Test the api_statuses_f() function.
2354 public function testApiStatusesFWithBlocks()
2356 $result = api_statuses_f('blocks');
2357 self::assertArrayHasKey('user', $result);
2361 * Test the api_statuses_f() function.
2365 public function testApiStatusesFWithIncoming()
2367 $result = api_statuses_f('incoming');
2368 self::assertArrayHasKey('user', $result);
2372 * Test the api_statuses_f() function an undefined cursor GET variable.
2376 public function testApiStatusesFWithUndefinedCursor()
2378 $_GET['cursor'] = 'undefined';
2379 self::assertFalse(api_statuses_f('friends'));
2383 * Test the api_statuses_friends() function.
2387 public function testApiStatusesFriends()
2389 $result = api_statuses_friends('json');
2390 self::assertArrayHasKey('user', $result);
2394 * Test the api_statuses_friends() function an undefined cursor GET variable.
2398 public function testApiStatusesFriendsWithUndefinedCursor()
2400 $_GET['cursor'] = 'undefined';
2401 self::assertFalse(api_statuses_friends('json'));
2405 * Test the api_statuses_followers() function.
2409 public function testApiStatusesFollowers()
2411 $result = api_statuses_followers('json');
2412 self::assertArrayHasKey('user', $result);
2416 * Test the api_statuses_followers() function an undefined cursor GET variable.
2420 public function testApiStatusesFollowersWithUndefinedCursor()
2422 $_GET['cursor'] = 'undefined';
2423 self::assertFalse(api_statuses_followers('json'));
2427 * Test the api_blocks_list() function.
2431 public function testApiBlocksList()
2433 $result = api_blocks_list('json');
2434 self::assertArrayHasKey('user', $result);
2438 * Test the api_blocks_list() function an undefined cursor GET variable.
2442 public function testApiBlocksListWithUndefinedCursor()
2444 $_GET['cursor'] = 'undefined';
2445 self::assertFalse(api_blocks_list('json'));
2449 * Test the api_friendships_incoming() function.
2453 public function testApiFriendshipsIncoming()
2455 $result = api_friendships_incoming('json');
2456 self::assertArrayHasKey('id', $result);
2460 * Test the api_friendships_incoming() function an undefined cursor GET variable.
2464 public function testApiFriendshipsIncomingWithUndefinedCursor()
2466 $_GET['cursor'] = 'undefined';
2467 self::assertFalse(api_friendships_incoming('json'));
2471 * Test the api_statusnet_config() function.
2475 public function testApiStatusnetConfig()
2478 $result = api_statusnet_config('json');
2479 self::assertEquals('localhost', $result['config']['site']['server']);
2480 self::assertEquals('default', $result['config']['site']['theme']);
2481 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2482 self::assertTrue($result['config']['site']['fancy']);
2483 self::assertEquals('en', $result['config']['site']['language']);
2484 self::assertEquals('UTC', $result['config']['site']['timezone']);
2485 self::assertEquals(200000, $result['config']['site']['textlimit']);
2486 self::assertEquals('false', $result['config']['site']['private']);
2487 self::assertEquals('false', $result['config']['site']['ssl']);
2488 self::assertEquals(30, $result['config']['site']['shorturllength']);
2493 * Test the api_direct_messages_new() function.
2497 public function testApiDirectMessagesNew()
2499 $result = api_direct_messages_new('json');
2500 self::assertNull($result);
2504 * Test the api_direct_messages_new() function without an authenticated user.
2508 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2510 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2511 BasicAuth::setCurrentUserID();
2512 $_SESSION['authenticated'] = false;
2513 api_direct_messages_new('json');
2517 * Test the api_direct_messages_new() function with an user ID.
2521 public function testApiDirectMessagesNewWithUserId()
2523 $_POST['text'] = 'message_text';
2524 $_POST['user_id'] = $this->otherUser['id'];
2525 $result = api_direct_messages_new('json');
2526 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2530 * Test the api_direct_messages_new() function with a screen name.
2534 public function testApiDirectMessagesNewWithScreenName()
2536 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2537 $_POST['text'] = 'message_text';
2538 $_POST['user_id'] = $this->friendUser['id'];
2539 $result = api_direct_messages_new('json');
2540 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2541 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2542 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2546 * Test the api_direct_messages_new() function with a title.
2550 public function testApiDirectMessagesNewWithTitle()
2552 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2553 $_POST['text'] = 'message_text';
2554 $_POST['user_id'] = $this->friendUser['id'];
2555 $_REQUEST['title'] = 'message_title';
2556 $result = api_direct_messages_new('json');
2557 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2558 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2559 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2560 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2564 * Test the api_direct_messages_new() function with an RSS result.
2568 public function testApiDirectMessagesNewWithRss()
2570 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2571 $_POST['text'] = 'message_text';
2572 $_POST['user_id'] = $this->friendUser['id'];
2573 $result = api_direct_messages_new('rss');
2574 self::assertXml($result, 'direct-messages');
2578 * Test the api_direct_messages_destroy() function.
2582 public function testApiDirectMessagesDestroy()
2584 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2585 api_direct_messages_destroy('json');
2589 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2593 public function testApiDirectMessagesDestroyWithVerbose()
2595 $_GET['friendica_verbose'] = 'true';
2596 $result = api_direct_messages_destroy('json');
2600 'result' => 'error',
2601 'message' => 'message id or parenturi not specified'
2609 * Test the api_direct_messages_destroy() function without an authenticated user.
2613 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2615 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2616 BasicAuth::setCurrentUserID();
2617 $_SESSION['authenticated'] = false;
2618 api_direct_messages_destroy('json');
2622 * Test the api_direct_messages_destroy() function with a non-zero ID.
2626 public function testApiDirectMessagesDestroyWithId()
2628 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2629 $_REQUEST['id'] = 1;
2630 api_direct_messages_destroy('json');
2634 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2638 public function testApiDirectMessagesDestroyWithIdAndVerbose()
2640 $_REQUEST['id'] = 1;
2641 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2642 $_GET['friendica_verbose'] = 'true';
2643 $result = api_direct_messages_destroy('json');
2647 'result' => 'error',
2648 'message' => 'message id not in database'
2656 * Test the api_direct_messages_destroy() function with a non-zero ID.
2660 public function testApiDirectMessagesDestroyWithCorrectId()
2662 $this->markTestIncomplete('We need to add a dataset for this.');
2666 * Test the api_direct_messages_box() function.
2670 public function testApiDirectMessagesBoxWithSentbox()
2672 $_REQUEST['page'] = -1;
2673 $_REQUEST['max_id'] = 10;
2674 $result = api_direct_messages_box('json', 'sentbox', 'false');
2675 self::assertArrayHasKey('direct_message', $result);
2679 * Test the api_direct_messages_box() function.
2683 public function testApiDirectMessagesBoxWithConversation()
2685 $result = api_direct_messages_box('json', 'conversation', 'false');
2686 self::assertArrayHasKey('direct_message', $result);
2690 * Test the api_direct_messages_box() function.
2694 public function testApiDirectMessagesBoxWithAll()
2696 $result = api_direct_messages_box('json', 'all', 'false');
2697 self::assertArrayHasKey('direct_message', $result);
2701 * Test the api_direct_messages_box() function.
2705 public function testApiDirectMessagesBoxWithInbox()
2707 $result = api_direct_messages_box('json', 'inbox', 'false');
2708 self::assertArrayHasKey('direct_message', $result);
2712 * Test the api_direct_messages_box() function.
2716 public function testApiDirectMessagesBoxWithVerbose()
2718 $result = api_direct_messages_box('json', 'sentbox', 'true');
2722 'result' => 'error',
2723 'message' => 'no mails available'
2731 * Test the api_direct_messages_box() function with a RSS result.
2735 public function testApiDirectMessagesBoxWithRss()
2737 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2738 self::assertXml($result, 'direct-messages');
2742 * Test the api_direct_messages_box() function without an authenticated user.
2746 public function testApiDirectMessagesBoxWithUnallowedUser()
2748 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2749 BasicAuth::setCurrentUserID();
2750 api_direct_messages_box('json', 'sentbox', 'false');
2754 * Test the api_direct_messages_sentbox() function.
2758 public function testApiDirectMessagesSentbox()
2760 $result = api_direct_messages_sentbox('json');
2761 self::assertArrayHasKey('direct_message', $result);
2765 * Test the api_direct_messages_inbox() function.
2769 public function testApiDirectMessagesInbox()
2771 $result = api_direct_messages_inbox('json');
2772 self::assertArrayHasKey('direct_message', $result);
2776 * Test the api_direct_messages_all() function.
2780 public function testApiDirectMessagesAll()
2782 $result = api_direct_messages_all('json');
2783 self::assertArrayHasKey('direct_message', $result);
2787 * Test the api_direct_messages_conversation() function.
2791 public function testApiDirectMessagesConversation()
2793 $result = api_direct_messages_conversation('json');
2794 self::assertArrayHasKey('direct_message', $result);
2798 * Test the api_oauth_request_token() function.
2802 public function testApiOauthRequestToken()
2804 $this->markTestIncomplete('exit() kills phpunit as well');
2808 * Test the api_oauth_access_token() function.
2812 public function testApiOauthAccessToken()
2814 $this->markTestIncomplete('exit() kills phpunit as well');
2818 * Test the api_fr_photos_list() function.
2822 public function testApiFrPhotosList()
2824 $result = api_fr_photos_list('json');
2825 self::assertArrayHasKey('photo', $result);
2829 * Test the api_fr_photos_list() function without an authenticated user.
2833 public function testApiFrPhotosListWithoutAuthenticatedUser()
2835 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2836 BasicAuth::setCurrentUserID();
2837 $_SESSION['authenticated'] = false;
2838 api_fr_photos_list('json');
2842 * Test the api_fr_photo_create_update() function.
2844 public function testApiFrPhotoCreateUpdate()
2846 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2847 api_fr_photo_create_update('json');
2851 * Test the api_fr_photo_create_update() function without an authenticated user.
2855 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2857 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2858 BasicAuth::setCurrentUserID();
2859 $_SESSION['authenticated'] = false;
2860 api_fr_photo_create_update('json');
2864 * Test the api_fr_photo_create_update() function with an album name.
2868 public function testApiFrPhotoCreateUpdateWithAlbum()
2870 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2871 $_REQUEST['album'] = 'album_name';
2872 api_fr_photo_create_update('json');
2876 * Test the api_fr_photo_create_update() function with the update mode.
2880 public function testApiFrPhotoCreateUpdateWithUpdate()
2882 $this->markTestIncomplete('We need to create a dataset for this');
2886 * Test the api_fr_photo_create_update() function with an uploaded file.
2890 public function testApiFrPhotoCreateUpdateWithFile()
2892 $this->markTestIncomplete();
2896 * Test the api_fr_photo_detail() function.
2900 public function testApiFrPhotoDetail()
2902 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2903 api_fr_photo_detail('json');
2907 * Test the api_fr_photo_detail() function without an authenticated user.
2911 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
2913 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2914 BasicAuth::setCurrentUserID();
2915 $_SESSION['authenticated'] = false;
2916 api_fr_photo_detail('json');
2920 * Test the api_fr_photo_detail() function with a photo ID.
2924 public function testApiFrPhotoDetailWithPhotoId()
2926 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
2927 $_REQUEST['photo_id'] = 1;
2928 api_fr_photo_detail('json');
2932 * Test the api_fr_photo_detail() function with a correct photo ID.
2936 public function testApiFrPhotoDetailCorrectPhotoId()
2938 $this->markTestIncomplete('We need to create a dataset for this.');
2942 * Test the api_account_update_profile_image() function.
2946 public function testApiAccountUpdateProfileImage()
2948 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2949 api_account_update_profile_image('json');
2953 * Test the api_account_update_profile_image() function without an authenticated user.
2957 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
2959 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2960 BasicAuth::setCurrentUserID();
2961 $_SESSION['authenticated'] = false;
2962 api_account_update_profile_image('json');
2966 * Test the api_account_update_profile_image() function with an uploaded file.
2970 public function testApiAccountUpdateProfileImageWithUpload()
2972 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2973 $this->markTestIncomplete();
2978 * Test the api_account_update_profile() function.
2982 public function testApiAccountUpdateProfile()
2984 $_POST['name'] = 'new_name';
2985 $_POST['description'] = 'new_description';
2986 $result = api_account_update_profile('json');
2987 // We can't use assertSelfUser() here because the user object is missing some properties.
2988 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
2989 self::assertEquals('DFRN', $result['user']['location']);
2990 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
2991 self::assertEquals('new_name', $result['user']['name']);
2992 self::assertEquals('new_description', $result['user']['description']);
2996 * Test the check_acl_input() function.
3000 public function testCheckAclInput()
3002 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
3003 // Where does this result come from?
3004 self::assertEquals(1, $result);
3008 * Test the check_acl_input() function with an empty ACL string.
3012 public function testCheckAclInputWithEmptyAclString()
3014 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
3015 self::assertFalse($result);
3019 * Test the save_media_to_database() function.
3023 public function testSaveMediaToDatabase()
3025 $this->markTestIncomplete();
3029 * Test the post_photo_item() function.
3033 public function testPostPhotoItem()
3035 $this->markTestIncomplete();
3039 * Test the prepare_photo_data() function.
3043 public function testPreparePhotoData()
3045 $this->markTestIncomplete();
3049 * Test the api_share_as_retweet() function with a valid item.
3053 public function testApiShareAsRetweetWithValidItem()
3055 $this->markTestIncomplete();
3059 * Test the api_in_reply_to() function.
3063 public function testApiInReplyTo()
3065 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3066 self::assertArrayHasKey('status_id', $result);
3067 self::assertArrayHasKey('user_id', $result);
3068 self::assertArrayHasKey('status_id_str', $result);
3069 self::assertArrayHasKey('user_id_str', $result);
3070 self::assertArrayHasKey('screen_name', $result);
3074 * Test the api_in_reply_to() function with a valid item.
3078 public function testApiInReplyToWithValidItem()
3080 $this->markTestIncomplete();
3084 * Test the api_clean_plain_items() function.
3088 public function testApiCleanPlainItems()
3090 $_REQUEST['include_entities'] = 'true';
3091 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3092 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3096 * Test the api_best_nickname() function with contacts.
3100 public function testApiBestNicknameWithContacts()
3102 $this->markTestIncomplete();
3106 * Test the api_friendica_group_show() function.
3110 public function testApiFriendicaGroupShow()
3112 $this->markTestIncomplete();
3116 * Test the api_friendica_group_delete() function.
3120 public function testApiFriendicaGroupDelete()
3122 $this->markTestIncomplete();
3126 * Test the api_lists_destroy() function.
3130 public function testApiListsDestroy()
3132 $this->markTestIncomplete();
3136 * Test the group_create() function.
3140 public function testGroupCreate()
3142 $this->markTestIncomplete();
3146 * Test the api_friendica_group_create() function.
3150 public function testApiFriendicaGroupCreate()
3152 $this->markTestIncomplete();
3156 * Test the api_lists_create() function.
3160 public function testApiListsCreate()
3162 $this->markTestIncomplete();
3166 * Test the api_friendica_group_update() function.
3170 public function testApiFriendicaGroupUpdate()
3172 $this->markTestIncomplete();
3176 * Test the api_lists_update() function.
3180 public function testApiListsUpdate()
3182 $this->markTestIncomplete();
3186 * Test the api_friendica_activity() function.
3190 public function testApiFriendicaActivity()
3192 $this->markTestIncomplete();
3196 * Test the api_friendica_notification_seen() function.
3200 public function testApiFriendicaNotificationSeen()
3202 $this->markTestIncomplete();
3206 * Test the api_friendica_direct_messages_setseen() function.
3210 public function testApiFriendicaDirectMessagesSetseen()
3212 $this->markTestIncomplete();
3216 * Test the api_friendica_direct_messages_search() function.
3220 public function testApiFriendicaDirectMessagesSearch()
3222 $this->markTestIncomplete();