6 namespace Friendica\Test\legacy;
9 use Friendica\Core\Config\Capability\IManageConfigValues;
10 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
11 use Friendica\Core\Protocol;
13 use Friendica\Module\Api\ApiResponse;
14 use Friendica\Module\BaseApi;
15 use Friendica\Network\HTTPException;
16 use Friendica\Security\BasicAuth;
17 use Friendica\Test\FixtureTest;
18 use Friendica\Util\Arrays;
19 use Friendica\Util\DateTimeFormat;
20 use Friendica\Util\Temporal;
21 use Monolog\Handler\TestHandler;
23 require_once __DIR__ . '/../../include/api.php';
26 * Tests for the API functions.
28 * Functions that use header() need to be tested in a separate process.
29 * @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
31 * @backupGlobals enabled
33 class ApiTest extends FixtureTest
36 * @var TestHandler Can handle log-outputs
43 protected $friendUser;
47 protected $wrongUserId;
52 /** @var IManageConfigValues */
56 * Create variables used by tests.
58 protected function setUp() : void
60 global $API, $called_api;
66 /** @var IManageConfigValues $config */
67 $this->config = $this->dice->create(IManageConfigValues::class);
69 $this->config->set('system', 'url', 'http://localhost');
70 $this->config->set('system', 'hostname', 'localhost');
71 $this->config->set('system', 'worker_dont_fork', true);
74 $this->config->set('config', 'hostname', 'localhost');
75 $this->config->set('system', 'throttle_limit_day', 100);
76 $this->config->set('system', 'throttle_limit_week', 100);
77 $this->config->set('system', 'throttle_limit_month', 100);
78 $this->config->set('system', 'theme', 'system_theme');
82 $this->app = DI::app();
84 DI::args()->setArgc(1);
86 // User data that the test database is populated with
89 'name' => 'Self contact',
90 'nick' => 'selfcontact',
91 'nurl' => 'http://localhost/profile/selfcontact'
95 'name' => 'Friend contact',
96 'nick' => 'friendcontact',
97 'nurl' => 'http://localhost/profile/friendcontact'
101 'name' => 'othercontact',
102 'nick' => 'othercontact',
103 'nurl' => 'http://localhost/profile/othercontact'
106 // User ID that we know is not in the database
107 $this->wrongUserId = 666;
109 DI::session()->start();
111 // Most API require login so we force the session
113 'authenticated' => true,
114 'uid' => $this->selfUser['id']
116 BasicAuth::setCurrentUserID($this->selfUser['id']);
120 * Assert that an user array contains expected keys.
122 * @param array $user User array
126 private function assertSelfUser(array $user)
128 self::assertEquals($this->selfUser['id'], $user['uid']);
129 self::assertEquals($this->selfUser['id'], $user['cid']);
130 self::assertEquals(1, $user['self']);
131 self::assertEquals('DFRN', $user['location']);
132 self::assertEquals($this->selfUser['name'], $user['name']);
133 self::assertEquals($this->selfUser['nick'], $user['screen_name']);
134 self::assertEquals('dfrn', $user['network']);
135 self::assertTrue($user['verified']);
139 * Assert that an user array contains expected keys.
141 * @param array $user User array
145 private function assertOtherUser(array $user = [])
147 self::assertEquals($this->otherUser['id'], $user['id']);
148 self::assertEquals($this->otherUser['id'], $user['id_str']);
149 self::assertEquals(0, $user['self']);
150 self::assertEquals($this->otherUser['name'], $user['name']);
151 self::assertEquals($this->otherUser['nick'], $user['screen_name']);
152 self::assertFalse($user['verified']);
156 * Assert that a status array contains expected keys.
158 * @param array $status Status array
162 private function assertStatus(array $status = [])
164 self::assertIsString($status['text'] ?? '');
165 self::assertIsInt($status['id'] ?? '');
166 // We could probably do more checks here.
170 * Assert that a list array contains expected keys.
172 * @param array $list List array
176 private function assertList(array $list = [])
178 self::assertIsString($list['name']);
179 self::assertIsInt($list['id']);
180 self::assertIsString('string', $list['id_str']);
181 self::assertContains($list['mode'], ['public', 'private']);
182 // We could probably do more checks here.
186 * Assert that the string is XML and contain the root element.
188 * @param string $result XML string
189 * @param string $root_element Root element name
193 private function assertXml($result = '', $root_element = '')
195 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
196 self::assertStringContainsString('<' . $root_element, $result);
197 // We could probably do more checks here.
201 * Get the path to a temporary empty PNG image.
203 * @return string Path
205 private function getTempImage()
207 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
211 // Empty 1x1 px PNG image
212 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
220 * Test the api_user() function.
224 public function testApiUser()
226 self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
230 * Test the api_user() function with an unallowed user.
234 public function testApiUserWithUnallowedUser()
236 // self::assertEquals(false, api_user());
240 * Test the api_source() function.
244 public function testApiSource()
246 self::assertEquals('api', api_source());
250 * Test the api_source() function with a Twidere user agent.
254 public function testApiSourceWithTwidere()
256 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
257 self::assertEquals('Twidere', api_source());
261 * Test the api_source() function with a GET parameter.
265 public function testApiSourceWithGet()
267 $_GET['source'] = 'source_name';
268 self::assertEquals('source_name', api_source());
272 * Test the api_date() function.
276 public function testApiDate()
278 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', 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()
558 $user_info = ['url' => 'user_url', 'lang' => 'en'];
559 $result = api_rss_extra([], $user_info);
560 self::assertEquals($user_info, $result['$user']);
561 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
562 self::assertArrayHasKey('self', $result['$rss']);
563 self::assertArrayHasKey('base', $result['$rss']);
564 self::assertArrayHasKey('updated', $result['$rss']);
565 self::assertArrayHasKey('atom_updated', $result['$rss']);
566 self::assertArrayHasKey('language', $result['$rss']);
567 self::assertArrayHasKey('logo', $result['$rss']);
571 * Test the api_rss_extra() function without any user info.
575 public function testApiRssExtraWithoutUserInfo()
577 $result = api_rss_extra([], null);
578 self::assertIsArray($result['$user']);
579 self::assertArrayHasKey('alternate', $result['$rss']);
580 self::assertArrayHasKey('self', $result['$rss']);
581 self::assertArrayHasKey('base', $result['$rss']);
582 self::assertArrayHasKey('updated', $result['$rss']);
583 self::assertArrayHasKey('atom_updated', $result['$rss']);
584 self::assertArrayHasKey('language', $result['$rss']);
585 self::assertArrayHasKey('logo', $result['$rss']);
589 * Test the api_unique_id_to_nurl() function.
593 public function testApiUniqueIdToNurl()
595 self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
599 * Test the api_unique_id_to_nurl() function with a correct ID.
603 public function testApiUniqueIdToNurlWithCorrectId()
605 self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
609 * Test the api_get_user() function.
613 public function testApiGetUser()
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 a Frio schema.
627 public function testApiGetUserWithFrioSchema()
629 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
630 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
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 an empty Frio schema.
643 public function testApiGetUserWithEmptyFrioSchema()
645 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
646 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
647 // $user = api_get_user();
648 // self::assertSelfUser($user);
649 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
650 // self::assertEquals('6fdbe8', $user['profile_link_color']);
651 // self::assertEquals('ededed', $user['profile_background_color']);
655 * Test the api_get_user() function with a custom Frio schema.
659 public function testApiGetUserWithCustomFrioSchema()
661 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
662 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
663 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
664 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
665 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
666 // $user = api_get_user();
667 // self::assertSelfUser($user);
668 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
669 // self::assertEquals('123456', $user['profile_link_color']);
670 // self::assertEquals('123456', $user['profile_background_color']);
674 * Test the api_get_user() function with an user that is not allowed to use the API.
676 * @runInSeparateProcess
677 * @preserveGlobalState disabled
679 public function testApiGetUserWithoutApiUser()
681 // api_get_user() with empty parameters is not used anymore
683 $_SERVER['PHP_AUTH_USER'] = 'Test user';
684 $_SERVER['PHP_AUTH_PW'] = 'password';
685 BasicAuth::setCurrentUserID();
686 self::assertFalse(api_get_user());
691 * Test the api_get_user() function with an user ID in a GET parameter.
695 public function testApiGetUserWithGetId()
697 // self::assertOtherUser(api_get_user());
701 * Test the api_get_user() function with a wrong user ID in a GET parameter.
705 public function testApiGetUserWithWrongGetId()
707 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
708 // self::assertOtherUser(api_get_user());
712 * Test the api_get_user() function with an user name in a GET parameter.
716 public function testApiGetUserWithGetName()
718 // self::assertSelfUser(api_get_user());
722 * Test the api_get_user() function with a profile URL in a GET parameter.
726 public function testApiGetUserWithGetUrl()
728 // self::assertSelfUser(api_get_user());
732 * Test the api_get_user() function with an user ID in the API path.
736 public function testApiGetUserWithNumericCalledApi()
738 // global $called_api;
739 // $called_api = ['api_path'];
740 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
741 // self::assertOtherUser(api_get_user());
745 * Test the api_get_user() function with the $called_api global variable.
749 public function testApiGetUserWithCalledApi()
751 // global $called_api;
752 // $called_api = ['api', 'api_path'];
753 // self::assertSelfUser(api_get_user());
757 * Test the api_get_user() function with a 0 user ID.
761 public function testApiGetUserWithZeroUser()
763 self::assertSelfUser(DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray());
767 * Test the api_item_get_user() function.
771 public function testApiItemGetUser()
773 $users = api_item_get_user($this->app, []);
774 self::assertSelfUser($users[0]);
778 * Test the api_item_get_user() function with a different item parent.
782 public function testApiItemGetUserWithDifferentParent()
784 $users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
785 self::assertSelfUser($users[0]);
786 self::assertEquals($users[0], $users[1]);
790 * Test the Arrays::walkRecursive() function.
794 public function testApiWalkRecursive()
799 Arrays::walkRecursive(
802 // Should we test this with a callback that actually does something?
810 * Test the Arrays::walkRecursive() function with an array.
814 public function testApiWalkRecursiveWithArray()
816 $array = [['item1'], ['item2']];
819 Arrays::walkRecursive(
822 // Should we test this with a callback that actually does something?
830 * Test the BaseApi::reformatXML() function.
834 public function testApiReformatXml()
838 self::assertTrue(ApiResponse::reformatXML($item, $key));
839 self::assertEquals('true', $item);
843 * Test the BaseApi::reformatXML() function with a statusnet_api key.
847 public function testApiReformatXmlWithStatusnetKey()
850 $key = 'statusnet_api';
851 self::assertTrue(ApiResponse::reformatXML($item, $key));
852 self::assertEquals('statusnet:api', $key);
856 * Test the BaseApi::reformatXML() function with a friendica_api key.
860 public function testApiReformatXmlWithFriendicaKey()
863 $key = 'friendica_api';
864 self::assertTrue(ApiResponse::reformatXML($item, $key));
865 self::assertEquals('friendica:api', $key);
869 * Test the BaseApi::createXML() function.
873 public function testApiCreateXml()
876 '<?xml version="1.0"?>' . "\n" .
877 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
878 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
879 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
880 ' <data>some_data</data>' . "\n" .
881 '</root_element>' . "\n",
882 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
887 * Test the BaseApi::createXML() function without any XML namespace.
891 public function testApiCreateXmlWithoutNamespaces()
894 '<?xml version="1.0"?>' . "\n" .
896 ' <data>some_data</data>' . "\n" .
898 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
903 * Test the BaseApi::formatData() function.
907 public function testApiFormatData()
909 $data = ['some_data'];
910 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
914 * Test the BaseApi::formatData() function with an XML result.
918 public function testApiFormatDataWithXml()
921 '<?xml version="1.0"?>' . "\n" .
922 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
923 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
924 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
925 ' <data>some_data</data>' . "\n" .
926 '</root_element>' . "\n",
927 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
932 * Test the api_account_verify_credentials() function.
936 public function testApiAccountVerifyCredentials()
938 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
942 * Test the api_account_verify_credentials() function without an authenticated user.
946 public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
948 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
949 BasicAuth::setCurrentUserID();
950 $_SESSION['authenticated'] = false;
951 api_account_verify_credentials('json');
955 * Test the requestdata() function.
959 public function testRequestdata()
961 self::assertNull(requestdata('variable_name'));
965 * Test the requestdata() function with a POST parameter.
969 public function testRequestdataWithPost()
971 $_POST['variable_name'] = 'variable_value';
972 self::assertEquals('variable_value', requestdata('variable_name'));
976 * Test the requestdata() function with a GET parameter.
980 public function testRequestdataWithGet()
982 $_GET['variable_name'] = 'variable_value';
983 self::assertEquals('variable_value', requestdata('variable_name'));
987 * Test the api_statuses_mediap() function.
991 public function testApiStatusesMediap()
993 DI::args()->setArgc(2);
1001 'tmp_name' => $this->getTempImage(),
1002 'name' => 'spacer.png',
1003 'type' => 'image/png'
1006 $_GET['status'] = '<b>Status content</b>';
1008 $result = api_statuses_mediap('json');
1009 self::assertStatus($result['status']);
1013 * Test the api_statuses_mediap() function without an authenticated user.
1017 public function testApiStatusesMediapWithoutAuthenticatedUser()
1019 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1020 BasicAuth::setCurrentUserID();
1021 $_SESSION['authenticated'] = false;
1022 api_statuses_mediap('json');
1026 * Test the api_statuses_update() function.
1030 public function testApiStatusesUpdate()
1032 $_GET['status'] = 'Status content #friendica';
1033 $_GET['in_reply_to_status_id'] = -1;
1042 'tmp_name' => $this->getTempImage(),
1043 'name' => 'spacer.png',
1044 'type' => 'image/png'
1048 $result = api_statuses_update('json');
1049 self::assertStatus($result['status']);
1053 * Test the api_statuses_update() function with an HTML status.
1057 public function testApiStatusesUpdateWithHtml()
1059 $_GET['htmlstatus'] = '<b>Status content</b>';
1061 $result = api_statuses_update('json');
1062 self::assertStatus($result['status']);
1066 * Test the api_statuses_update() function without an authenticated user.
1070 public function testApiStatusesUpdateWithoutAuthenticatedUser()
1072 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1073 BasicAuth::setCurrentUserID();
1074 $_SESSION['authenticated'] = false;
1075 api_statuses_update('json');
1079 * Test the api_statuses_update() function with a parent status.
1083 public function testApiStatusesUpdateWithParent()
1085 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1089 * Test the api_statuses_update() function with a media_ids parameter.
1093 public function testApiStatusesUpdateWithMediaIds()
1095 $this->markTestIncomplete();
1099 * Test the api_statuses_update() function with the throttle limit reached.
1103 public function testApiStatusesUpdateWithDayThrottleReached()
1105 $this->markTestIncomplete();
1109 * Test the api_media_upload() function.
1110 * @runInSeparateProcess
1111 * @preserveGlobalState disabled
1113 public function testApiMediaUpload()
1115 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1120 * Test the api_media_upload() function without an authenticated user.
1124 public function testApiMediaUploadWithoutAuthenticatedUser()
1126 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1127 BasicAuth::setCurrentUserID();
1128 $_SESSION['authenticated'] = false;
1133 * Test the api_media_upload() function with an invalid uploaded media.
1137 public function testApiMediaUploadWithMedia()
1139 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1143 'tmp_name' => 'tmp_name'
1150 * Test the api_media_upload() function with an valid uploaded media.
1154 public function testApiMediaUploadWithValidMedia()
1162 'tmp_name' => $this->getTempImage(),
1163 'name' => 'spacer.png',
1164 'type' => 'image/png'
1168 DI::args()->setArgc(2);
1170 $result = api_media_upload();
1171 self::assertEquals('image/png', $result['media']['image']['image_type']);
1172 self::assertEquals(1, $result['media']['image']['w']);
1173 self::assertEquals(1, $result['media']['image']['h']);
1174 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1178 * Test the api_status_show() function.
1180 public function testApiStatusShowWithJson()
1182 $result = api_status_show('json', 1);
1183 self::assertStatus($result['status']);
1187 * Test the api_status_show() function with an XML result.
1189 public function testApiStatusShowWithXml()
1191 $result = api_status_show('xml', 1);
1192 self::assertXml($result, 'statuses');
1196 * Test the api_get_last_status() function
1198 public function testApiGetLastStatus()
1200 $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1202 self::assertNotNull($item);
1206 * Test the api_users_show() function.
1210 public function testApiUsersShow()
1212 $result = api_users_show('json');
1213 // We can't use assertSelfUser() here because the user object is missing some properties.
1214 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1215 self::assertEquals('DFRN', $result['user']['location']);
1216 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1217 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1218 self::assertEquals('dfrn', $result['user']['network']);
1219 self::assertTrue($result['user']['verified']);
1223 * Test the api_users_show() function with an XML result.
1227 public function testApiUsersShowWithXml()
1229 $result = api_users_show('xml');
1230 self::assertXml($result, 'statuses');
1234 * Test the api_users_search() function.
1238 public function testApiUsersSearch()
1240 $_GET['q'] = 'othercontact';
1241 $result = api_users_search('json');
1242 self::assertOtherUser($result['users'][0]);
1246 * Test the api_users_search() function with an XML result.
1250 public function testApiUsersSearchWithXml()
1252 $_GET['q'] = 'othercontact';
1253 $result = api_users_search('xml');
1254 self::assertXml($result, 'users');
1258 * Test the api_users_search() function without a GET q parameter.
1262 public function testApiUsersSearchWithoutQuery()
1264 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1265 api_users_search('json');
1269 * Test the api_users_lookup() function.
1273 public function testApiUsersLookup()
1275 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1276 api_users_lookup('json');
1280 * Test the api_users_lookup() function with an user ID.
1284 public function testApiUsersLookupWithUserId()
1286 $_REQUEST['user_id'] = $this->otherUser['id'];
1287 $result = api_users_lookup('json');
1288 self::assertOtherUser($result['users'][0]);
1292 * Test the api_search() function.
1296 public function testApiSearch()
1298 $_REQUEST['q'] = 'reply';
1299 $_REQUEST['max_id'] = 10;
1300 $result = api_search('json');
1301 foreach ($result['status'] as $status) {
1302 self::assertStatus($status);
1303 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1308 * Test the api_search() function a count parameter.
1312 public function testApiSearchWithCount()
1314 $_REQUEST['q'] = 'reply';
1315 $_REQUEST['count'] = 20;
1316 $result = api_search('json');
1317 foreach ($result['status'] as $status) {
1318 self::assertStatus($status);
1319 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1324 * Test the api_search() function with an rpp parameter.
1328 public function testApiSearchWithRpp()
1330 $_REQUEST['q'] = 'reply';
1331 $_REQUEST['rpp'] = 20;
1332 $result = api_search('json');
1333 foreach ($result['status'] as $status) {
1334 self::assertStatus($status);
1335 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1340 * Test the api_search() function with an q parameter contains hashtag.
1341 * @doesNotPerformAssertions
1343 public function testApiSearchWithHashtag()
1345 $_REQUEST['q'] = '%23friendica';
1346 $result = api_search('json');
1347 foreach ($result['status'] as $status) {
1348 self::assertStatus($status);
1349 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1354 * Test the api_search() function with an exclude_replies parameter.
1355 * @doesNotPerformAssertions
1357 public function testApiSearchWithExcludeReplies()
1359 $_REQUEST['max_id'] = 10;
1360 $_REQUEST['exclude_replies'] = true;
1361 $_REQUEST['q'] = 'friendica';
1362 $result = api_search('json');
1363 foreach ($result['status'] as $status) {
1364 self::assertStatus($status);
1369 * Test the api_search() function without an authenticated user.
1373 public function testApiSearchWithUnallowedUser()
1375 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1376 BasicAuth::setCurrentUserID();
1381 * Test the api_search() function without any GET query parameter.
1385 public function testApiSearchWithoutQuery()
1387 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1392 * Test the api_statuses_home_timeline() function.
1396 public function testApiStatusesHomeTimeline()
1398 $_REQUEST['max_id'] = 10;
1399 $_REQUEST['exclude_replies'] = true;
1400 $_REQUEST['conversation_id'] = 1;
1401 $result = api_statuses_home_timeline('json');
1402 self::assertNotEmpty($result['status']);
1403 foreach ($result['status'] as $status) {
1404 self::assertStatus($status);
1409 * Test the api_statuses_home_timeline() function with a negative page parameter.
1413 public function testApiStatusesHomeTimelineWithNegativePage()
1415 $_REQUEST['page'] = -2;
1416 $result = api_statuses_home_timeline('json');
1417 self::assertNotEmpty($result['status']);
1418 foreach ($result['status'] as $status) {
1419 self::assertStatus($status);
1424 * Test the api_statuses_home_timeline() with an unallowed user.
1428 public function testApiStatusesHomeTimelineWithUnallowedUser()
1430 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1431 BasicAuth::setCurrentUserID();
1432 api_statuses_home_timeline('json');
1436 * Test the api_statuses_home_timeline() function with an RSS result.
1440 public function testApiStatusesHomeTimelineWithRss()
1442 $result = api_statuses_home_timeline('rss');
1443 self::assertXml($result, 'statuses');
1447 * Test the api_statuses_public_timeline() function.
1451 public function testApiStatusesPublicTimeline()
1453 $_REQUEST['max_id'] = 10;
1454 $_REQUEST['conversation_id'] = 1;
1455 $result = api_statuses_public_timeline('json');
1456 self::assertNotEmpty($result['status']);
1457 foreach ($result['status'] as $status) {
1458 self::assertStatus($status);
1463 * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1467 public function testApiStatusesPublicTimelineWithExcludeReplies()
1469 $_REQUEST['max_id'] = 10;
1470 $_REQUEST['exclude_replies'] = true;
1471 $result = api_statuses_public_timeline('json');
1472 self::assertNotEmpty($result['status']);
1473 foreach ($result['status'] as $status) {
1474 self::assertStatus($status);
1479 * Test the api_statuses_public_timeline() function with a negative page parameter.
1483 public function testApiStatusesPublicTimelineWithNegativePage()
1485 $_REQUEST['page'] = -2;
1486 $result = api_statuses_public_timeline('json');
1487 self::assertNotEmpty($result['status']);
1488 foreach ($result['status'] as $status) {
1489 self::assertStatus($status);
1494 * Test the api_statuses_public_timeline() function with an unallowed user.
1498 public function testApiStatusesPublicTimelineWithUnallowedUser()
1500 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1501 BasicAuth::setCurrentUserID();
1502 api_statuses_public_timeline('json');
1506 * Test the api_statuses_public_timeline() function with an RSS result.
1510 public function testApiStatusesPublicTimelineWithRss()
1512 $result = api_statuses_public_timeline('rss');
1513 self::assertXml($result, 'statuses');
1517 * Test the api_statuses_networkpublic_timeline() function.
1521 public function testApiStatusesNetworkpublicTimeline()
1523 $_REQUEST['max_id'] = 10;
1524 $result = api_statuses_networkpublic_timeline('json');
1525 self::assertNotEmpty($result['status']);
1526 foreach ($result['status'] as $status) {
1527 self::assertStatus($status);
1532 * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1536 public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1538 $_REQUEST['page'] = -2;
1539 $result = api_statuses_networkpublic_timeline('json');
1540 self::assertNotEmpty($result['status']);
1541 foreach ($result['status'] as $status) {
1542 self::assertStatus($status);
1547 * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1551 public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1553 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1554 BasicAuth::setCurrentUserID();
1555 api_statuses_networkpublic_timeline('json');
1559 * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1563 public function testApiStatusesNetworkpublicTimelineWithRss()
1565 $result = api_statuses_networkpublic_timeline('rss');
1566 self::assertXml($result, 'statuses');
1570 * Test the api_statuses_show() function.
1574 public function testApiStatusesShow()
1576 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1577 api_statuses_show('json');
1581 * Test the api_statuses_show() function with an ID.
1585 public function testApiStatusesShowWithId()
1587 DI::args()->setArgv(['', '', '', 1]);
1588 $result = api_statuses_show('json');
1589 self::assertStatus($result['status']);
1593 * Test the api_statuses_show() function with the conversation parameter.
1597 public function testApiStatusesShowWithConversation()
1599 DI::args()->setArgv(['', '', '', 1]);
1600 $_REQUEST['conversation'] = 1;
1601 $result = api_statuses_show('json');
1602 self::assertNotEmpty($result['status']);
1603 foreach ($result['status'] as $status) {
1604 self::assertStatus($status);
1609 * Test the api_statuses_show() function with an unallowed user.
1613 public function testApiStatusesShowWithUnallowedUser()
1615 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1616 BasicAuth::setCurrentUserID();
1617 api_statuses_show('json');
1621 * Test the api_conversation_show() function.
1625 public function testApiConversationShow()
1627 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1628 api_conversation_show('json');
1632 * Test the api_conversation_show() function with an ID.
1636 public function testApiConversationShowWithId()
1638 DI::args()->setArgv(['', '', '', 1]);
1639 $_REQUEST['max_id'] = 10;
1640 $_REQUEST['page'] = -2;
1641 $result = api_conversation_show('json');
1642 self::assertNotEmpty($result['status']);
1643 foreach ($result['status'] as $status) {
1644 self::assertStatus($status);
1649 * Test the api_conversation_show() function with an unallowed user.
1653 public function testApiConversationShowWithUnallowedUser()
1655 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1656 BasicAuth::setCurrentUserID();
1657 api_conversation_show('json');
1661 * Test the api_statuses_repeat() function.
1665 public function testApiStatusesRepeat()
1667 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1668 api_statuses_repeat('json');
1672 * Test the api_statuses_repeat() function without an authenticated user.
1676 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1678 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1679 BasicAuth::setCurrentUserID();
1680 $_SESSION['authenticated'] = false;
1681 api_statuses_repeat('json');
1685 * Test the api_statuses_repeat() function with an ID.
1689 public function testApiStatusesRepeatWithId()
1691 DI::args()->setArgv(['', '', '', 1]);
1692 $result = api_statuses_repeat('json');
1693 self::assertStatus($result['status']);
1695 // Also test with a shared status
1696 DI::args()->setArgv(['', '', '', 5]);
1697 $result = api_statuses_repeat('json');
1698 self::assertStatus($result['status']);
1702 * Test the api_statuses_destroy() function.
1706 public function testApiStatusesDestroy()
1708 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1709 api_statuses_destroy('json');
1713 * Test the api_statuses_destroy() function without an authenticated user.
1717 public function testApiStatusesDestroyWithoutAuthenticatedUser()
1719 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1720 BasicAuth::setCurrentUserID();
1721 $_SESSION['authenticated'] = false;
1722 api_statuses_destroy('json');
1726 * Test the api_statuses_destroy() function with an ID.
1730 public function testApiStatusesDestroyWithId()
1732 DI::args()->setArgv(['', '', '', 1]);
1733 $result = api_statuses_destroy('json');
1734 self::assertStatus($result['status']);
1738 * Test the api_statuses_mentions() function.
1742 public function testApiStatusesMentions()
1744 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1745 $_REQUEST['max_id'] = 10;
1746 $result = api_statuses_mentions('json');
1747 self::assertEmpty($result['status']);
1748 // We should test with mentions in the database.
1752 * Test the api_statuses_mentions() function with a negative page parameter.
1756 public function testApiStatusesMentionsWithNegativePage()
1758 $_REQUEST['page'] = -2;
1759 $result = api_statuses_mentions('json');
1760 self::assertEmpty($result['status']);
1764 * Test the api_statuses_mentions() function with an unallowed user.
1768 public function testApiStatusesMentionsWithUnallowedUser()
1770 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1771 BasicAuth::setCurrentUserID();
1772 api_statuses_mentions('json');
1776 * Test the api_statuses_mentions() function with an RSS result.
1780 public function testApiStatusesMentionsWithRss()
1782 $result = api_statuses_mentions('rss');
1783 self::assertXml($result, 'statuses');
1787 * Test the api_statuses_user_timeline() function.
1791 public function testApiStatusesUserTimeline()
1793 $_REQUEST['max_id'] = 10;
1794 $_REQUEST['exclude_replies'] = true;
1795 $_REQUEST['conversation_id'] = 1;
1796 $result = api_statuses_user_timeline('json');
1797 self::assertNotEmpty($result['status']);
1798 foreach ($result['status'] as $status) {
1799 self::assertStatus($status);
1804 * Test the api_statuses_user_timeline() function with a negative page parameter.
1808 public function testApiStatusesUserTimelineWithNegativePage()
1810 $_REQUEST['page'] = -2;
1811 $result = api_statuses_user_timeline('json');
1812 self::assertNotEmpty($result['status']);
1813 foreach ($result['status'] as $status) {
1814 self::assertStatus($status);
1819 * Test the api_statuses_user_timeline() function with an RSS result.
1823 public function testApiStatusesUserTimelineWithRss()
1825 $result = api_statuses_user_timeline('rss');
1826 self::assertXml($result, 'statuses');
1830 * Test the api_statuses_user_timeline() function with an unallowed user.
1834 public function testApiStatusesUserTimelineWithUnallowedUser()
1836 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1837 BasicAuth::setCurrentUserID();
1838 api_statuses_user_timeline('json');
1842 * Test the api_favorites_create_destroy() function.
1846 public function testApiFavoritesCreateDestroy()
1848 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1849 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1850 api_favorites_create_destroy('json');
1854 * Test the api_favorites_create_destroy() function with an invalid ID.
1858 public function testApiFavoritesCreateDestroyWithInvalidId()
1860 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1861 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1862 api_favorites_create_destroy('json');
1866 * Test the api_favorites_create_destroy() function with an invalid action.
1870 public function testApiFavoritesCreateDestroyWithInvalidAction()
1872 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1873 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1874 $_REQUEST['id'] = 1;
1875 api_favorites_create_destroy('json');
1879 * Test the api_favorites_create_destroy() function with the create action.
1883 public function testApiFavoritesCreateDestroyWithCreateAction()
1885 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1886 $_REQUEST['id'] = 3;
1887 $result = api_favorites_create_destroy('json');
1888 self::assertStatus($result['status']);
1892 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1896 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1898 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1899 $_REQUEST['id'] = 3;
1900 $result = api_favorites_create_destroy('rss');
1901 self::assertXml($result, 'status');
1905 * Test the api_favorites_create_destroy() function with the destroy action.
1909 public function testApiFavoritesCreateDestroyWithDestroyAction()
1911 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1912 $_REQUEST['id'] = 3;
1913 $result = api_favorites_create_destroy('json');
1914 self::assertStatus($result['status']);
1918 * Test the api_favorites_create_destroy() function without an authenticated user.
1922 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1924 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1925 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1926 BasicAuth::setCurrentUserID();
1927 $_SESSION['authenticated'] = false;
1928 api_favorites_create_destroy('json');
1932 * Test the api_favorites() function.
1936 public function testApiFavorites()
1938 $_REQUEST['page'] = -1;
1939 $_REQUEST['max_id'] = 10;
1940 $result = api_favorites('json');
1941 foreach ($result['status'] as $status) {
1942 self::assertStatus($status);
1947 * Test the api_favorites() function with an RSS result.
1951 public function testApiFavoritesWithRss()
1953 $result = api_favorites('rss');
1954 self::assertXml($result, 'statuses');
1958 * Test the api_favorites() function with an unallowed user.
1962 public function testApiFavoritesWithUnallowedUser()
1964 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1965 BasicAuth::setCurrentUserID();
1966 api_favorites('json');
1970 * Test the api_format_messages() function.
1974 public function testApiFormatMessages()
1976 $result = api_format_messages(
1977 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1978 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1979 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1981 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1982 self::assertEquals(1, $result['id']);
1983 self::assertEquals(2, $result['recipient_id']);
1984 self::assertEquals(3, $result['sender_id']);
1985 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1986 self::assertEquals('sender_name', $result['sender_screen_name']);
1990 * Test the api_format_messages() function with HTML.
1994 public function testApiFormatMessagesWithHtmlText()
1996 $_GET['getText'] = 'html';
1997 $result = api_format_messages(
1998 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1999 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2000 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2002 self::assertEquals('item_title', $result['title']);
2003 self::assertEquals('<strong>item_body</strong>', $result['text']);
2007 * Test the api_format_messages() function with plain text.
2011 public function testApiFormatMessagesWithPlainText()
2013 $_GET['getText'] = 'plain';
2014 $result = api_format_messages(
2015 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2016 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2017 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2019 self::assertEquals('item_title', $result['title']);
2020 self::assertEquals('item_body', $result['text']);
2024 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
2028 public function testApiFormatMessagesWithoutUserObjects()
2030 $_GET['getUserObjects'] = 'false';
2031 $result = api_format_messages(
2032 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
2033 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
2034 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
2036 self::assertTrue(!isset($result['sender']));
2037 self::assertTrue(!isset($result['recipient']));
2041 * Test the api_convert_item() function.
2045 public function testApiConvertItem()
2047 $result = api_convert_item(
2049 'network' => 'feed',
2050 'title' => 'item_title',
2052 // We need a long string to test that it is correctly cut
2053 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2054 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2055 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2056 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2057 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2058 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2059 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2060 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2061 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2062 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2063 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2064 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2065 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2066 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2067 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2068 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2069 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2070 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2071 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2072 'repellat officia illum quos impedit quam iste esse unde qui ' .
2073 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2074 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2075 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2076 'plink' => 'item_plink'
2079 self::assertStringStartsWith('item_title', $result['text']);
2080 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2084 * Test the api_convert_item() function with an empty item body.
2088 public function testApiConvertItemWithoutBody()
2090 $result = api_convert_item(
2092 'network' => 'feed',
2093 'title' => 'item_title',
2096 'plink' => 'item_plink'
2099 self::assertEquals("item_title", $result['text']);
2100 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2104 * Test the api_convert_item() function with the title in the body.
2108 public function testApiConvertItemWithTitleInBody()
2110 $result = api_convert_item(
2112 'title' => 'item_title',
2113 'body' => 'item_title item_body',
2117 self::assertEquals('item_title item_body', $result['text']);
2118 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2122 * Test the api_get_attachments() function.
2126 public function testApiGetAttachments()
2129 self::assertEmpty(api_get_attachments($body, 0));
2133 * Test the api_get_attachments() function with an img tag.
2137 public function testApiGetAttachmentsWithImage()
2139 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2140 self::assertIsArray(api_get_attachments($body, 0));
2144 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2148 public function testApiGetAttachmentsWithImageAndAndStatus()
2150 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2151 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2152 self::assertIsArray(api_get_attachments($body, 0));
2156 * Test the api_get_entitities() function.
2160 public function testApiGetEntitities()
2163 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2167 * Test the api_get_entitities() function with the include_entities parameter.
2171 public function testApiGetEntititiesWithIncludeEntities()
2173 $_REQUEST['include_entities'] = 'true';
2175 $result = api_get_entitities($text, 'bbcode', 0);
2176 self::assertIsArray($result['hashtags']);
2177 self::assertIsArray($result['symbols']);
2178 self::assertIsArray($result['urls']);
2179 self::assertIsArray($result['user_mentions']);
2183 * Test the api_format_items_embeded_images() function.
2187 public function testApiFormatItemsEmbededImages()
2190 'text ' . DI::baseUrl() . '/display/item_guid',
2191 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2196 * Test the api_contactlink_to_array() function.
2200 public function testApiContactlinkToArray()
2207 api_contactlink_to_array('text')
2212 * Test the api_contactlink_to_array() function with an URL.
2216 public function testApiContactlinkToArrayWithUrl()
2220 'name' => ['link_text'],
2223 api_contactlink_to_array('text <a href="url">link_text</a>')
2228 * Test the api_format_items_activities() function.
2232 public function testApiFormatItemsActivities()
2234 $item = ['uid' => 0, 'uri' => ''];
2235 $result = api_format_items_activities($item);
2236 self::assertArrayHasKey('like', $result);
2237 self::assertArrayHasKey('dislike', $result);
2238 self::assertArrayHasKey('attendyes', $result);
2239 self::assertArrayHasKey('attendno', $result);
2240 self::assertArrayHasKey('attendmaybe', $result);
2244 * Test the api_format_items_activities() function with an XML result.
2248 public function testApiFormatItemsActivitiesWithXml()
2250 $item = ['uid' => 0, 'uri' => ''];
2251 $result = api_format_items_activities($item, 'xml');
2252 self::assertArrayHasKey('friendica:like', $result);
2253 self::assertArrayHasKey('friendica:dislike', $result);
2254 self::assertArrayHasKey('friendica:attendyes', $result);
2255 self::assertArrayHasKey('friendica:attendno', $result);
2256 self::assertArrayHasKey('friendica:attendmaybe', $result);
2260 * Test the api_format_items() function.
2261 * @doesNotPerformAssertions
2263 public function testApiFormatItems()
2267 'item_network' => 'item_network',
2273 'author-network' => Protocol::DFRN,
2274 'author-link' => 'http://localhost/profile/othercontact',
2278 $result = api_format_items($items, ['id' => 0], true);
2279 foreach ($result as $status) {
2280 self::assertStatus($status);
2285 * Test the api_format_items() function with an XML result.
2286 * @doesNotPerformAssertions
2288 public function testApiFormatItemsWithXml()
2296 'author-network' => Protocol::DFRN,
2297 'author-link' => 'http://localhost/profile/othercontact',
2301 $result = api_format_items($items, ['id' => 0], true, 'xml');
2302 foreach ($result as $status) {
2303 self::assertStatus($status);
2308 * Test the api_lists_list() function.
2312 public function testApiListsList()
2314 $result = api_lists_list('json');
2315 self::assertEquals(['lists_list' => []], $result);
2319 * Test the api_lists_ownerships() function.
2323 public function testApiListsOwnerships()
2325 $result = api_lists_ownerships('json');
2326 foreach ($result['lists']['lists'] as $list) {
2327 self::assertList($list);
2332 * Test the api_lists_ownerships() function without an authenticated user.
2336 public function testApiListsOwnershipsWithoutAuthenticatedUser()
2338 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2339 BasicAuth::setCurrentUserID();
2340 $_SESSION['authenticated'] = false;
2341 api_lists_ownerships('json');
2345 * Test the api_lists_statuses() function.
2349 public function testApiListsStatuses()
2351 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2352 api_lists_statuses('json');
2356 * Test the api_lists_statuses() function with a list ID.
2357 * @doesNotPerformAssertions
2359 public function testApiListsStatusesWithListId()
2361 $_REQUEST['list_id'] = 1;
2362 $_REQUEST['page'] = -1;
2363 $_REQUEST['max_id'] = 10;
2364 $result = api_lists_statuses('json');
2365 foreach ($result['status'] as $status) {
2366 self::assertStatus($status);
2371 * Test the api_lists_statuses() function with a list ID and a RSS result.
2375 public function testApiListsStatusesWithListIdAndRss()
2377 $_REQUEST['list_id'] = 1;
2378 $result = api_lists_statuses('rss');
2379 self::assertXml($result, 'statuses');
2383 * Test the api_lists_statuses() function with an unallowed user.
2387 public function testApiListsStatusesWithUnallowedUser()
2389 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2390 BasicAuth::setCurrentUserID();
2391 api_lists_statuses('json');
2395 * Test the api_statuses_f() function.
2399 public function testApiStatusesFWithFriends()
2402 $result = api_statuses_f('friends');
2403 self::assertArrayHasKey('user', $result);
2407 * Test the api_statuses_f() function.
2411 public function testApiStatusesFWithFollowers()
2413 $result = api_statuses_f('followers');
2414 self::assertArrayHasKey('user', $result);
2418 * Test the api_statuses_f() function.
2422 public function testApiStatusesFWithBlocks()
2424 $result = api_statuses_f('blocks');
2425 self::assertArrayHasKey('user', $result);
2429 * Test the api_statuses_f() function.
2433 public function testApiStatusesFWithIncoming()
2435 $result = api_statuses_f('incoming');
2436 self::assertArrayHasKey('user', $result);
2440 * Test the api_statuses_f() function an undefined cursor GET variable.
2444 public function testApiStatusesFWithUndefinedCursor()
2446 $_GET['cursor'] = 'undefined';
2447 self::assertFalse(api_statuses_f('friends'));
2451 * Test the api_statuses_friends() function.
2455 public function testApiStatusesFriends()
2457 $result = api_statuses_friends('json');
2458 self::assertArrayHasKey('user', $result);
2462 * Test the api_statuses_friends() function an undefined cursor GET variable.
2466 public function testApiStatusesFriendsWithUndefinedCursor()
2468 $_GET['cursor'] = 'undefined';
2469 self::assertFalse(api_statuses_friends('json'));
2473 * Test the api_statuses_followers() function.
2477 public function testApiStatusesFollowers()
2479 $result = api_statuses_followers('json');
2480 self::assertArrayHasKey('user', $result);
2484 * Test the api_statuses_followers() function an undefined cursor GET variable.
2488 public function testApiStatusesFollowersWithUndefinedCursor()
2490 $_GET['cursor'] = 'undefined';
2491 self::assertFalse(api_statuses_followers('json'));
2495 * Test the api_blocks_list() function.
2499 public function testApiBlocksList()
2501 $result = api_blocks_list('json');
2502 self::assertArrayHasKey('user', $result);
2506 * Test the api_blocks_list() function an undefined cursor GET variable.
2510 public function testApiBlocksListWithUndefinedCursor()
2512 $_GET['cursor'] = 'undefined';
2513 self::assertFalse(api_blocks_list('json'));
2517 * Test the api_friendships_incoming() function.
2521 public function testApiFriendshipsIncoming()
2523 $result = api_friendships_incoming('json');
2524 self::assertArrayHasKey('id', $result);
2528 * Test the api_friendships_incoming() function an undefined cursor GET variable.
2532 public function testApiFriendshipsIncomingWithUndefinedCursor()
2534 $_GET['cursor'] = 'undefined';
2535 self::assertFalse(api_friendships_incoming('json'));
2539 * Test the api_statusnet_config() function.
2543 public function testApiStatusnetConfig()
2546 $result = api_statusnet_config('json');
2547 self::assertEquals('localhost', $result['config']['site']['server']);
2548 self::assertEquals('default', $result['config']['site']['theme']);
2549 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2550 self::assertTrue($result['config']['site']['fancy']);
2551 self::assertEquals('en', $result['config']['site']['language']);
2552 self::assertEquals('UTC', $result['config']['site']['timezone']);
2553 self::assertEquals(200000, $result['config']['site']['textlimit']);
2554 self::assertEquals('false', $result['config']['site']['private']);
2555 self::assertEquals('false', $result['config']['site']['ssl']);
2556 self::assertEquals(30, $result['config']['site']['shorturllength']);
2561 * Test the api_direct_messages_new() function.
2565 public function testApiDirectMessagesNew()
2567 $result = api_direct_messages_new('json');
2568 self::assertNull($result);
2572 * Test the api_direct_messages_new() function without an authenticated user.
2576 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2578 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2579 BasicAuth::setCurrentUserID();
2580 $_SESSION['authenticated'] = false;
2581 api_direct_messages_new('json');
2585 * Test the api_direct_messages_new() function with an user ID.
2589 public function testApiDirectMessagesNewWithUserId()
2591 $_POST['text'] = 'message_text';
2592 $_POST['user_id'] = $this->otherUser['id'];
2593 $result = api_direct_messages_new('json');
2594 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2598 * Test the api_direct_messages_new() function with a screen name.
2602 public function testApiDirectMessagesNewWithScreenName()
2604 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2605 $_POST['text'] = 'message_text';
2606 $_POST['screen_name'] = $this->friendUser['nick'];
2607 $result = api_direct_messages_new('json');
2608 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2609 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2610 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2614 * Test the api_direct_messages_new() function with a title.
2618 public function testApiDirectMessagesNewWithTitle()
2620 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2621 $_POST['text'] = 'message_text';
2622 $_POST['screen_name'] = $this->friendUser['nick'];
2623 $_REQUEST['title'] = 'message_title';
2624 $result = api_direct_messages_new('json');
2625 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2626 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2627 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2628 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2632 * Test the api_direct_messages_new() function with an RSS result.
2636 public function testApiDirectMessagesNewWithRss()
2638 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2639 $_POST['text'] = 'message_text';
2640 $_POST['screen_name'] = $this->friendUser['nick'];
2641 $result = api_direct_messages_new('rss');
2642 self::assertXml($result, 'direct-messages');
2646 * Test the api_direct_messages_destroy() function.
2650 public function testApiDirectMessagesDestroy()
2652 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2653 api_direct_messages_destroy('json');
2657 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2661 public function testApiDirectMessagesDestroyWithVerbose()
2663 $_GET['friendica_verbose'] = 'true';
2664 $result = api_direct_messages_destroy('json');
2668 'result' => 'error',
2669 'message' => 'message id or parenturi not specified'
2677 * Test the api_direct_messages_destroy() function without an authenticated user.
2681 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2683 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2684 BasicAuth::setCurrentUserID();
2685 $_SESSION['authenticated'] = false;
2686 api_direct_messages_destroy('json');
2690 * Test the api_direct_messages_destroy() function with a non-zero ID.
2694 public function testApiDirectMessagesDestroyWithId()
2696 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2697 $_REQUEST['id'] = 1;
2698 api_direct_messages_destroy('json');
2702 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2706 public function testApiDirectMessagesDestroyWithIdAndVerbose()
2708 $_REQUEST['id'] = 1;
2709 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2710 $_GET['friendica_verbose'] = 'true';
2711 $result = api_direct_messages_destroy('json');
2715 'result' => 'error',
2716 'message' => 'message id not in database'
2724 * Test the api_direct_messages_destroy() function with a non-zero ID.
2728 public function testApiDirectMessagesDestroyWithCorrectId()
2730 $this->markTestIncomplete('We need to add a dataset for this.');
2734 * Test the api_direct_messages_box() function.
2738 public function testApiDirectMessagesBoxWithSentbox()
2740 $_REQUEST['page'] = -1;
2741 $_REQUEST['max_id'] = 10;
2742 $result = api_direct_messages_box('json', 'sentbox', 'false');
2743 self::assertArrayHasKey('direct_message', $result);
2747 * Test the api_direct_messages_box() function.
2751 public function testApiDirectMessagesBoxWithConversation()
2753 $result = api_direct_messages_box('json', 'conversation', 'false');
2754 self::assertArrayHasKey('direct_message', $result);
2758 * Test the api_direct_messages_box() function.
2762 public function testApiDirectMessagesBoxWithAll()
2764 $result = api_direct_messages_box('json', 'all', 'false');
2765 self::assertArrayHasKey('direct_message', $result);
2769 * Test the api_direct_messages_box() function.
2773 public function testApiDirectMessagesBoxWithInbox()
2775 $result = api_direct_messages_box('json', 'inbox', 'false');
2776 self::assertArrayHasKey('direct_message', $result);
2780 * Test the api_direct_messages_box() function.
2784 public function testApiDirectMessagesBoxWithVerbose()
2786 $result = api_direct_messages_box('json', 'sentbox', 'true');
2790 'result' => 'error',
2791 'message' => 'no mails available'
2799 * Test the api_direct_messages_box() function with a RSS result.
2803 public function testApiDirectMessagesBoxWithRss()
2805 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2806 self::assertXml($result, 'direct-messages');
2810 * Test the api_direct_messages_box() function without an authenticated user.
2814 public function testApiDirectMessagesBoxWithUnallowedUser()
2816 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2817 BasicAuth::setCurrentUserID();
2818 api_direct_messages_box('json', 'sentbox', 'false');
2822 * Test the api_direct_messages_sentbox() function.
2826 public function testApiDirectMessagesSentbox()
2828 $result = api_direct_messages_sentbox('json');
2829 self::assertArrayHasKey('direct_message', $result);
2833 * Test the api_direct_messages_inbox() function.
2837 public function testApiDirectMessagesInbox()
2839 $result = api_direct_messages_inbox('json');
2840 self::assertArrayHasKey('direct_message', $result);
2844 * Test the api_direct_messages_all() function.
2848 public function testApiDirectMessagesAll()
2850 $result = api_direct_messages_all('json');
2851 self::assertArrayHasKey('direct_message', $result);
2855 * Test the api_direct_messages_conversation() function.
2859 public function testApiDirectMessagesConversation()
2861 $result = api_direct_messages_conversation('json');
2862 self::assertArrayHasKey('direct_message', $result);
2866 * Test the api_oauth_request_token() function.
2870 public function testApiOauthRequestToken()
2872 $this->markTestIncomplete('exit() kills phpunit as well');
2876 * Test the api_oauth_access_token() function.
2880 public function testApiOauthAccessToken()
2882 $this->markTestIncomplete('exit() kills phpunit as well');
2886 * Test the api_fr_photos_list() function.
2890 public function testApiFrPhotosList()
2892 $result = api_fr_photos_list('json');
2893 self::assertArrayHasKey('photo', $result);
2897 * Test the api_fr_photos_list() function without an authenticated user.
2901 public function testApiFrPhotosListWithoutAuthenticatedUser()
2903 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2904 BasicAuth::setCurrentUserID();
2905 $_SESSION['authenticated'] = false;
2906 api_fr_photos_list('json');
2910 * Test the api_fr_photo_create_update() function.
2912 public function testApiFrPhotoCreateUpdate()
2914 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2915 api_fr_photo_create_update('json');
2919 * Test the api_fr_photo_create_update() function without an authenticated user.
2923 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2925 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2926 BasicAuth::setCurrentUserID();
2927 $_SESSION['authenticated'] = false;
2928 api_fr_photo_create_update('json');
2932 * Test the api_fr_photo_create_update() function with an album name.
2936 public function testApiFrPhotoCreateUpdateWithAlbum()
2938 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2939 $_REQUEST['album'] = 'album_name';
2940 api_fr_photo_create_update('json');
2944 * Test the api_fr_photo_create_update() function with the update mode.
2948 public function testApiFrPhotoCreateUpdateWithUpdate()
2950 $this->markTestIncomplete('We need to create a dataset for this');
2954 * Test the api_fr_photo_create_update() function with an uploaded file.
2958 public function testApiFrPhotoCreateUpdateWithFile()
2960 $this->markTestIncomplete();
2964 * Test the api_fr_photo_detail() function.
2968 public function testApiFrPhotoDetail()
2970 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2971 api_fr_photo_detail('json');
2975 * Test the api_fr_photo_detail() function without an authenticated user.
2979 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
2981 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2982 BasicAuth::setCurrentUserID();
2983 $_SESSION['authenticated'] = false;
2984 api_fr_photo_detail('json');
2988 * Test the api_fr_photo_detail() function with a photo ID.
2992 public function testApiFrPhotoDetailWithPhotoId()
2994 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
2995 $_REQUEST['photo_id'] = 1;
2996 api_fr_photo_detail('json');
3000 * Test the api_fr_photo_detail() function with a correct photo ID.
3004 public function testApiFrPhotoDetailCorrectPhotoId()
3006 $this->markTestIncomplete('We need to create a dataset for this.');
3010 * Test the api_account_update_profile_image() function.
3014 public function testApiAccountUpdateProfileImage()
3016 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3017 api_account_update_profile_image('json');
3021 * Test the api_account_update_profile_image() function without an authenticated user.
3025 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
3027 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
3028 BasicAuth::setCurrentUserID();
3029 $_SESSION['authenticated'] = false;
3030 api_account_update_profile_image('json');
3034 * Test the api_account_update_profile_image() function with an uploaded file.
3038 public function testApiAccountUpdateProfileImageWithUpload()
3040 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
3041 $this->markTestIncomplete();
3046 * Test the api_account_update_profile() function.
3050 public function testApiAccountUpdateProfile()
3052 $_POST['name'] = 'new_name';
3053 $_POST['description'] = 'new_description';
3054 $result = api_account_update_profile('json');
3055 // We can't use assertSelfUser() here because the user object is missing some properties.
3056 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
3057 self::assertEquals('DFRN', $result['user']['location']);
3058 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
3059 self::assertEquals('dfrn', $result['user']['network']);
3060 self::assertEquals('new_name', $result['user']['name']);
3061 self::assertEquals('new_description', $result['user']['description']);
3065 * Test the check_acl_input() function.
3069 public function testCheckAclInput()
3071 $result = check_acl_input('<aclstring>');
3072 // Where does this result come from?
3073 self::assertEquals(1, $result);
3077 * Test the check_acl_input() function with an empty ACL string.
3081 public function testCheckAclInputWithEmptyAclString()
3083 $result = check_acl_input(' ');
3084 self::assertFalse($result);
3088 * Test the save_media_to_database() function.
3092 public function testSaveMediaToDatabase()
3094 $this->markTestIncomplete();
3098 * Test the post_photo_item() function.
3102 public function testPostPhotoItem()
3104 $this->markTestIncomplete();
3108 * Test the prepare_photo_data() function.
3112 public function testPreparePhotoData()
3114 $this->markTestIncomplete();
3118 * Test the api_share_as_retweet() function with a valid item.
3122 public function testApiShareAsRetweetWithValidItem()
3124 $this->markTestIncomplete();
3128 * Test the api_in_reply_to() function.
3132 public function testApiInReplyTo()
3134 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3135 self::assertArrayHasKey('status_id', $result);
3136 self::assertArrayHasKey('user_id', $result);
3137 self::assertArrayHasKey('status_id_str', $result);
3138 self::assertArrayHasKey('user_id_str', $result);
3139 self::assertArrayHasKey('screen_name', $result);
3143 * Test the api_in_reply_to() function with a valid item.
3147 public function testApiInReplyToWithValidItem()
3149 $this->markTestIncomplete();
3153 * Test the api_clean_plain_items() function.
3157 public function testApiCleanPlainItems()
3159 $_REQUEST['include_entities'] = 'true';
3160 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3161 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3165 * Test the api_best_nickname() function.
3169 public function testApiBestNickname()
3172 $result = api_best_nickname($contacts);
3173 self::assertNull($result);
3177 * Test the api_best_nickname() function with contacts.
3181 public function testApiBestNicknameWithContacts()
3183 $this->markTestIncomplete();
3187 * Test the api_friendica_group_show() function.
3191 public function testApiFriendicaGroupShow()
3193 $this->markTestIncomplete();
3197 * Test the api_friendica_group_delete() function.
3201 public function testApiFriendicaGroupDelete()
3203 $this->markTestIncomplete();
3207 * Test the api_lists_destroy() function.
3211 public function testApiListsDestroy()
3213 $this->markTestIncomplete();
3217 * Test the group_create() function.
3221 public function testGroupCreate()
3223 $this->markTestIncomplete();
3227 * Test the api_friendica_group_create() function.
3231 public function testApiFriendicaGroupCreate()
3233 $this->markTestIncomplete();
3237 * Test the api_lists_create() function.
3241 public function testApiListsCreate()
3243 $this->markTestIncomplete();
3247 * Test the api_friendica_group_update() function.
3251 public function testApiFriendicaGroupUpdate()
3253 $this->markTestIncomplete();
3257 * Test the api_lists_update() function.
3261 public function testApiListsUpdate()
3263 $this->markTestIncomplete();
3267 * Test the api_friendica_activity() function.
3271 public function testApiFriendicaActivity()
3273 $this->markTestIncomplete();
3277 * Test the api_friendica_notification_seen() function.
3281 public function testApiFriendicaNotificationSeen()
3283 $this->markTestIncomplete();
3287 * Test the api_friendica_direct_messages_setseen() function.
3291 public function testApiFriendicaDirectMessagesSetseen()
3293 $this->markTestIncomplete();
3297 * Test the api_friendica_direct_messages_search() function.
3301 public function testApiFriendicaDirectMessagesSearch()
3303 $this->markTestIncomplete();