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', BasicAuth::getCurrentApplicationToken()['name']);
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', BasicAuth::getCurrentApplicationToken()['name']);
261 * Test the api_source() function with a GET parameter.
265 public function testApiSourceWithGet()
267 $_REQUEST['source'] = 'source_name';
268 self::assertEquals('source_name', BasicAuth::getCurrentApplicationToken()['name']);
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(is_callable($API['api_path']['func']));
302 * Test the BasicAuth::getCurrentUserID() function without any login.
304 * @runInSeparateProcess
305 * @preserveGlobalState disabled
306 * @preserveGlobalState disabled
308 public function testApiLoginWithoutLogin()
310 BasicAuth::setCurrentUserID();
311 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
312 BasicAuth::getCurrentUserID(true);
316 * Test the BasicAuth::getCurrentUserID() function with a bad login.
318 * @runInSeparateProcess
319 * @preserveGlobalState disabled
320 * @preserveGlobalState disabled
322 public function testApiLoginWithBadLogin()
324 BasicAuth::setCurrentUserID();
325 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
326 $_SERVER['PHP_AUTH_USER'] = 'user@server';
327 BasicAuth::getCurrentUserID(true);
331 * Test the BasicAuth::getCurrentUserID() function with oAuth.
335 public function testApiLoginWithOauth()
337 $this->markTestIncomplete('Can we test this easily?');
341 * Test the BasicAuth::getCurrentUserID() function with authentication provided by an addon.
345 public function testApiLoginWithAddonAuth()
347 $this->markTestIncomplete('Can we test this easily?');
351 * Test the BasicAuth::getCurrentUserID() function with a correct login.
353 * @runInSeparateProcess
354 * @preserveGlobalState disabled
355 * @doesNotPerformAssertions
357 public function testApiLoginWithCorrectLogin()
359 BasicAuth::setCurrentUserID();
360 $_SERVER['PHP_AUTH_USER'] = 'Test user';
361 $_SERVER['PHP_AUTH_PW'] = 'password';
362 BasicAuth::getCurrentUserID(true);
366 * Test the BasicAuth::getCurrentUserID() function with a remote user.
368 * @runInSeparateProcess
369 * @preserveGlobalState disabled
371 public function testApiLoginWithRemoteUser()
373 BasicAuth::setCurrentUserID();
374 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
375 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
376 BasicAuth::getCurrentUserID(true);
380 * Test the api_call() function.
382 * @runInSeparateProcess
383 * @preserveGlobalState disabled
385 public function testApiCall()
389 'method' => 'method',
390 'func' => function () {
391 return ['data' => ['some_data']];
394 $_SERVER['REQUEST_METHOD'] = 'method';
395 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
396 $_GET['callback'] = 'callback_name';
399 'callback_name(["some_data"])',
400 api_call('api_path', 'json')
405 * Test the api_call() function with the profiled enabled.
407 * @runInSeparateProcess
408 * @preserveGlobalState disabled
410 public function testApiCallWithProfiler()
414 'method' => 'method',
415 'func' => function () {
416 return ['data' => ['some_data']];
420 $_SERVER['REQUEST_METHOD'] = 'method';
421 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
423 $this->config->set('system', 'profiler', true);
424 $this->config->set('rendertime', 'callstack', true);
425 $this->app->callstack = [
426 'database' => ['some_function' => 200],
427 'database_write' => ['some_function' => 200],
428 'cache' => ['some_function' => 200],
429 'cache_write' => ['some_function' => 200],
430 'network' => ['some_function' => 200]
435 api_call('api_path', 'json')
440 * Test the api_call() function with a JSON result.
442 * @runInSeparateProcess
443 * @preserveGlobalState disabled
445 public function testApiCallWithJson()
449 'method' => 'method',
450 'func' => function () {
451 return ['data' => ['some_data']];
454 $_SERVER['REQUEST_METHOD'] = 'method';
455 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
459 api_call('api_path.json', 'json')
464 * Test the api_call() function with an XML result.
466 * @runInSeparateProcess
467 * @preserveGlobalState disabled
469 public function testApiCallWithXml()
473 'method' => 'method',
474 'func' => function () {
478 $_SERVER['REQUEST_METHOD'] = 'method';
479 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
481 $args = DI::args()->determine($_SERVER, $_GET);
485 api_call('api_path.xml', 'xml')
490 * Test the api_call() function with an RSS result.
492 * @runInSeparateProcess
493 * @preserveGlobalState disabled
495 public function testApiCallWithRss()
499 'method' => 'method',
500 'func' => function () {
504 $_SERVER['REQUEST_METHOD'] = 'method';
505 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
508 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
510 api_call('api_path.rss', 'rss')
515 * Test the api_call() function with an Atom result.
517 * @runInSeparateProcess
518 * @preserveGlobalState disabled
520 public function testApiCallWithAtom()
524 'method' => 'method',
525 'func' => function () {
529 $_SERVER['REQUEST_METHOD'] = 'method';
530 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
533 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
535 api_call('api_path.atom', 'atom')
540 * Test the api_rss_extra() function.
544 public function testApiRssExtra()
547 $user_info = ['url' => 'user_url', 'lang' => 'en'];
548 $result = api_rss_extra([], $user_info);
549 self::assertEquals($user_info, $result['$user']);
550 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
551 self::assertArrayHasKey('self', $result['$rss']);
552 self::assertArrayHasKey('base', $result['$rss']);
553 self::assertArrayHasKey('updated', $result['$rss']);
554 self::assertArrayHasKey('atom_updated', $result['$rss']);
555 self::assertArrayHasKey('language', $result['$rss']);
556 self::assertArrayHasKey('logo', $result['$rss']);
561 * Test the api_rss_extra() function without any user info.
565 public function testApiRssExtraWithoutUserInfo()
568 $result = api_rss_extra([], null);
569 self::assertIsArray($result['$user']);
570 self::assertArrayHasKey('alternate', $result['$rss']);
571 self::assertArrayHasKey('self', $result['$rss']);
572 self::assertArrayHasKey('base', $result['$rss']);
573 self::assertArrayHasKey('updated', $result['$rss']);
574 self::assertArrayHasKey('atom_updated', $result['$rss']);
575 self::assertArrayHasKey('language', $result['$rss']);
576 self::assertArrayHasKey('logo', $result['$rss']);
581 * Test the api_get_user() function.
585 public function testApiGetUser()
587 // $user = api_get_user();
588 // self::assertSelfUser($user);
589 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
590 // self::assertEquals('6fdbe8', $user['profile_link_color']);
591 // self::assertEquals('ededed', $user['profile_background_color']);
595 * Test the api_get_user() function with a Frio schema.
599 public function testApiGetUserWithFrioSchema()
601 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
602 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
603 // $user = api_get_user();
604 // self::assertSelfUser($user);
605 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
606 // self::assertEquals('6fdbe8', $user['profile_link_color']);
607 // self::assertEquals('ededed', $user['profile_background_color']);
611 * Test the api_get_user() function with an empty Frio schema.
615 public function testApiGetUserWithEmptyFrioSchema()
617 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
618 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
619 // $user = api_get_user();
620 // self::assertSelfUser($user);
621 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
622 // self::assertEquals('6fdbe8', $user['profile_link_color']);
623 // self::assertEquals('ededed', $user['profile_background_color']);
627 * Test the api_get_user() function with a custom Frio schema.
631 public function testApiGetUserWithCustomFrioSchema()
633 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
634 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
635 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
636 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
637 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
638 // $user = api_get_user();
639 // self::assertSelfUser($user);
640 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
641 // self::assertEquals('123456', $user['profile_link_color']);
642 // self::assertEquals('123456', $user['profile_background_color']);
646 * Test the api_get_user() function with an user that is not allowed to use the API.
648 * @runInSeparateProcess
649 * @preserveGlobalState disabled
651 public function testApiGetUserWithoutApiUser()
653 // api_get_user() with empty parameters is not used anymore
655 $_SERVER['PHP_AUTH_USER'] = 'Test user';
656 $_SERVER['PHP_AUTH_PW'] = 'password';
657 BasicAuth::setCurrentUserID();
658 self::assertFalse(api_get_user());
663 * Test the api_get_user() function with an user ID in a GET parameter.
667 public function testApiGetUserWithGetId()
669 // self::assertOtherUser(api_get_user());
673 * Test the api_get_user() function with a wrong user ID in a GET parameter.
677 public function testApiGetUserWithWrongGetId()
679 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
680 // self::assertOtherUser(api_get_user());
684 * Test the api_get_user() function with an user name in a GET parameter.
688 public function testApiGetUserWithGetName()
690 // self::assertSelfUser(api_get_user());
694 * Test the api_get_user() function with a profile URL in a GET parameter.
698 public function testApiGetUserWithGetUrl()
700 // self::assertSelfUser(api_get_user());
704 * Test the api_get_user() function with an user ID in the API path.
708 public function testApiGetUserWithNumericCalledApi()
710 // global $called_api;
711 // $called_api = ['api_path'];
712 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
713 // self::assertOtherUser(api_get_user());
717 * Test the api_get_user() function with the $called_api global variable.
721 public function testApiGetUserWithCalledApi()
723 // global $called_api;
724 // $called_api = ['api', 'api_path'];
725 // self::assertSelfUser(api_get_user());
729 * Test the Arrays::walkRecursive() function.
733 public function testApiWalkRecursive()
738 Arrays::walkRecursive(
741 // Should we test this with a callback that actually does something?
749 * Test the Arrays::walkRecursive() function with an array.
753 public function testApiWalkRecursiveWithArray()
755 $array = [['item1'], ['item2']];
758 Arrays::walkRecursive(
761 // Should we test this with a callback that actually does something?
769 * Test the BaseApi::reformatXML() function.
773 public function testApiReformatXml()
777 self::assertTrue(ApiResponse::reformatXML($item, $key));
778 self::assertEquals('true', $item);
782 * Test the BaseApi::reformatXML() function with a statusnet_api key.
786 public function testApiReformatXmlWithStatusnetKey()
789 $key = 'statusnet_api';
790 self::assertTrue(ApiResponse::reformatXML($item, $key));
791 self::assertEquals('statusnet:api', $key);
795 * Test the BaseApi::reformatXML() function with a friendica_api key.
799 public function testApiReformatXmlWithFriendicaKey()
802 $key = 'friendica_api';
803 self::assertTrue(ApiResponse::reformatXML($item, $key));
804 self::assertEquals('friendica:api', $key);
808 * Test the BaseApi::createXML() function.
812 public function testApiCreateXml()
815 '<?xml version="1.0"?>' . "\n" .
816 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
817 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
818 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
819 ' <data>some_data</data>' . "\n" .
820 '</root_element>' . "\n",
821 DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
826 * Test the BaseApi::createXML() function without any XML namespace.
830 public function testApiCreateXmlWithoutNamespaces()
833 '<?xml version="1.0"?>' . "\n" .
835 ' <data>some_data</data>' . "\n" .
837 DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
842 * Test the BaseApi::formatData() function.
846 public function testApiFormatData()
848 $data = ['some_data'];
849 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
853 * Test the BaseApi::formatData() function with an XML result.
857 public function testApiFormatDataWithXml()
860 '<?xml version="1.0"?>' . "\n" .
861 '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
862 'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
863 'xmlns:georss="http://www.georss.org/georss">' . "\n" .
864 ' <data>some_data</data>' . "\n" .
865 '</root_element>' . "\n",
866 DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
871 * Test the api_statuses_mediap() function.
875 public function testApiStatusesMediap()
877 DI::args()->setArgc(2);
885 'tmp_name' => $this->getTempImage(),
886 'name' => 'spacer.png',
887 'type' => 'image/png'
890 $_GET['status'] = '<b>Status content</b>';
892 $result = api_statuses_mediap('json');
893 self::assertStatus($result['status']);
897 * Test the api_statuses_mediap() function without an authenticated user.
901 public function testApiStatusesMediapWithoutAuthenticatedUser()
903 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
904 BasicAuth::setCurrentUserID();
905 $_SESSION['authenticated'] = false;
906 api_statuses_mediap('json');
910 * Test the api_statuses_update() function.
914 public function testApiStatusesUpdate()
916 $_REQUEST['status'] = 'Status content #friendica';
917 $_REQUEST['in_reply_to_status_id'] = -1;
918 $_REQUEST['lat'] = 48;
919 $_REQUEST['long'] = 7;
926 'tmp_name' => $this->getTempImage(),
927 'name' => 'spacer.png',
928 'type' => 'image/png'
932 $result = api_statuses_update('json');
933 self::assertStatus($result['status']);
937 * Test the api_statuses_update() function with an HTML status.
941 public function testApiStatusesUpdateWithHtml()
943 $_REQUEST['htmlstatus'] = '<b>Status content</b>';
945 $result = api_statuses_update('json');
946 self::assertStatus($result['status']);
950 * Test the api_statuses_update() function without an authenticated user.
954 public function testApiStatusesUpdateWithoutAuthenticatedUser()
956 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
957 BasicAuth::setCurrentUserID();
958 $_SESSION['authenticated'] = false;
959 api_statuses_update('json');
963 * Test the api_statuses_update() function with a parent status.
967 public function testApiStatusesUpdateWithParent()
969 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
973 * Test the api_statuses_update() function with a media_ids parameter.
977 public function testApiStatusesUpdateWithMediaIds()
979 $this->markTestIncomplete();
983 * Test the api_statuses_update() function with the throttle limit reached.
987 public function testApiStatusesUpdateWithDayThrottleReached()
989 $this->markTestIncomplete();
993 * Test the api_media_upload() function.
994 * @runInSeparateProcess
995 * @preserveGlobalState disabled
997 public function testApiMediaUpload()
999 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1004 * Test the api_media_upload() function without an authenticated user.
1008 public function testApiMediaUploadWithoutAuthenticatedUser()
1010 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1011 BasicAuth::setCurrentUserID();
1012 $_SESSION['authenticated'] = false;
1017 * Test the api_media_upload() function with an invalid uploaded media.
1021 public function testApiMediaUploadWithMedia()
1023 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1027 'tmp_name' => 'tmp_name'
1034 * Test the api_media_upload() function with an valid uploaded media.
1038 public function testApiMediaUploadWithValidMedia()
1046 'tmp_name' => $this->getTempImage(),
1047 'name' => 'spacer.png',
1048 'type' => 'image/png'
1052 DI::args()->setArgc(2);
1054 $result = api_media_upload();
1055 self::assertEquals('image/png', $result['media']['image']['image_type']);
1056 self::assertEquals(1, $result['media']['image']['w']);
1057 self::assertEquals(1, $result['media']['image']['h']);
1058 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1062 * Test the api_statuses_repeat() function.
1066 public function testApiStatusesRepeat()
1068 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1069 api_statuses_repeat('json');
1073 * Test the api_statuses_repeat() function without an authenticated user.
1077 public function testApiStatusesRepeatWithoutAuthenticatedUser()
1079 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1080 BasicAuth::setCurrentUserID();
1081 $_SESSION['authenticated'] = false;
1082 api_statuses_repeat('json');
1086 * Test the api_statuses_repeat() function with an ID.
1090 public function testApiStatusesRepeatWithId()
1092 DI::args()->setArgv(['', '', '', 1]);
1093 $result = api_statuses_repeat('json');
1094 self::assertStatus($result['status']);
1096 // Also test with a shared status
1097 DI::args()->setArgv(['', '', '', 5]);
1098 $result = api_statuses_repeat('json');
1099 self::assertStatus($result['status']);
1103 * Test the api_favorites_create_destroy() function.
1107 public function testApiFavoritesCreateDestroy()
1109 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1110 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1111 api_favorites_create_destroy('json');
1115 * Test the api_favorites_create_destroy() function with an invalid ID.
1119 public function testApiFavoritesCreateDestroyWithInvalidId()
1121 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1122 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1123 api_favorites_create_destroy('json');
1127 * Test the api_favorites_create_destroy() function with an invalid action.
1131 public function testApiFavoritesCreateDestroyWithInvalidAction()
1133 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1134 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1135 $_REQUEST['id'] = 1;
1136 api_favorites_create_destroy('json');
1140 * Test the api_favorites_create_destroy() function with the create action.
1144 public function testApiFavoritesCreateDestroyWithCreateAction()
1146 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1147 $_REQUEST['id'] = 3;
1148 $result = api_favorites_create_destroy('json');
1149 self::assertStatus($result['status']);
1153 * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1157 public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1159 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1160 $_REQUEST['id'] = 3;
1161 $result = api_favorites_create_destroy('rss');
1162 self::assertXml($result, 'status');
1166 * Test the api_favorites_create_destroy() function with the destroy action.
1170 public function testApiFavoritesCreateDestroyWithDestroyAction()
1172 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1173 $_REQUEST['id'] = 3;
1174 $result = api_favorites_create_destroy('json');
1175 self::assertStatus($result['status']);
1179 * Test the api_favorites_create_destroy() function without an authenticated user.
1183 public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1185 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1186 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1187 BasicAuth::setCurrentUserID();
1188 $_SESSION['authenticated'] = false;
1189 api_favorites_create_destroy('json');
1195 * Test the api_format_messages() function.
1199 public function testApiFormatMessages()
1201 $result = api_format_messages(
1202 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1203 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1204 ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1206 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1207 self::assertEquals(1, $result['id']);
1208 self::assertEquals(2, $result['recipient_id']);
1209 self::assertEquals(3, $result['sender_id']);
1210 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1211 self::assertEquals('sender_name', $result['sender_screen_name']);
1215 * Test the api_format_messages() function with HTML.
1219 public function testApiFormatMessagesWithHtmlText()
1221 $_GET['getText'] = 'html';
1222 $result = api_format_messages(
1223 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1224 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1225 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1227 self::assertEquals('item_title', $result['title']);
1228 self::assertEquals('<strong>item_body</strong>', $result['text']);
1232 * Test the api_format_messages() function with plain text.
1236 public function testApiFormatMessagesWithPlainText()
1238 $_GET['getText'] = 'plain';
1239 $result = api_format_messages(
1240 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1241 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1242 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1244 self::assertEquals('item_title', $result['title']);
1245 self::assertEquals('item_body', $result['text']);
1249 * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1253 public function testApiFormatMessagesWithoutUserObjects()
1255 $_GET['getUserObjects'] = 'false';
1256 $result = api_format_messages(
1257 ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1258 ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1259 ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1261 self::assertTrue(!isset($result['sender']));
1262 self::assertTrue(!isset($result['recipient']));
1266 * Test the api_convert_item() function.
1270 public function testApiConvertItem()
1273 $result = api_convert_item(
1275 'network' => 'feed',
1276 'title' => 'item_title',
1278 // We need a long string to test that it is correctly cut
1279 'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
1280 'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
1281 'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
1282 'laudantium atque commodi alias voluptatem non possimus aperiam ' .
1283 'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
1284 'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
1285 'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
1286 'veritatis nihil distinctio qui eum repellat officia illum quos ' .
1287 'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
1288 'omnis exercitationem quo magnam consequatur maxime aut illum ' .
1289 'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
1290 'temporibus corporis ratione blanditiis perspiciatis impedit ' .
1291 'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
1292 'sunt consequatur inventore dolor officiis pariatur doloremque ' .
1293 'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
1294 'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
1295 'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
1296 'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
1297 'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
1298 'repellat officia illum quos impedit quam iste esse unde qui ' .
1299 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
1300 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
1301 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
1302 'plink' => 'item_plink'
1305 self::assertStringStartsWith('item_title', $result['text']);
1306 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
1311 * Test the api_convert_item() function with an empty item body.
1315 public function testApiConvertItemWithoutBody()
1318 $result = api_convert_item(
1320 'network' => 'feed',
1321 'title' => 'item_title',
1324 'plink' => 'item_plink'
1327 self::assertEquals("item_title", $result['text']);
1328 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
1333 * Test the api_convert_item() function with the title in the body.
1337 public function testApiConvertItemWithTitleInBody()
1340 $result = api_convert_item(
1342 'title' => 'item_title',
1343 'body' => 'item_title item_body',
1347 self::assertEquals('item_title item_body', $result['text']);
1348 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
1353 * Test the api_get_attachments() function.
1357 public function testApiGetAttachments()
1360 // self::assertEmpty(api_get_attachments($body, 0));
1364 * Test the api_get_attachments() function with an img tag.
1368 public function testApiGetAttachmentsWithImage()
1370 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
1371 // self::assertIsArray(api_get_attachments($body, 0));
1375 * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
1379 public function testApiGetAttachmentsWithImageAndAndStatus()
1381 // $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
1382 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
1383 // self::assertIsArray(api_get_attachments($body, 0));
1387 * Test the api_get_entitities() function.
1391 public function testApiGetEntitities()
1394 // self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
1398 * Test the api_get_entitities() function with the include_entities parameter.
1402 public function testApiGetEntititiesWithIncludeEntities()
1405 $_REQUEST['include_entities'] = 'true';
1407 $result = api_get_entitities($text, 'bbcode', 0);
1408 self::assertIsArray($result['hashtags']);
1409 self::assertIsArray($result['symbols']);
1410 self::assertIsArray($result['urls']);
1411 self::assertIsArray($result['user_mentions']);
1416 * Test the api_format_items_embeded_images() function.
1420 public function testApiFormatItemsEmbededImages()
1424 'text ' . DI::baseUrl() . '/display/item_guid',
1425 api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
1431 * Test the api_format_items_activities() function.
1435 public function testApiFormatItemsActivities()
1437 $item = ['uid' => 0, 'uri-id' => 1];
1438 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid']);
1439 self::assertArrayHasKey('like', $result);
1440 self::assertArrayHasKey('dislike', $result);
1441 self::assertArrayHasKey('attendyes', $result);
1442 self::assertArrayHasKey('attendno', $result);
1443 self::assertArrayHasKey('attendmaybe', $result);
1447 * Test the api_format_items_activities() function with an XML result.
1451 public function testApiFormatItemsActivitiesWithXml()
1453 $item = ['uid' => 0, 'uri-id' => 1];
1454 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid'], 'xml');
1455 self::assertArrayHasKey('friendica:like', $result);
1456 self::assertArrayHasKey('friendica:dislike', $result);
1457 self::assertArrayHasKey('friendica:attendyes', $result);
1458 self::assertArrayHasKey('friendica:attendno', $result);
1459 self::assertArrayHasKey('friendica:attendmaybe', $result);
1463 * Test the api_format_items() function.
1464 * @doesNotPerformAssertions
1466 public function testApiFormatItems()
1469 $items = Post::selectToArray([], ['uid' => 42]);
1470 foreach ($items as $item) {
1471 $status = api_format_item($item);
1472 self::assertStatus($status);
1478 * Test the api_format_items() function with an XML result.
1479 * @doesNotPerformAssertions
1481 public function testApiFormatItemsWithXml()
1484 $items = Post::selectToArray([], ['uid' => 42]);
1485 foreach ($items as $item) {
1486 $status = api_format_item($item, 'xml');
1487 self::assertStatus($status);
1493 * Test the api_lists_list() function.
1497 public function testApiListsList()
1499 $result = api_lists_list('json');
1500 self::assertEquals(['lists_list' => []], $result);
1504 * Test the api_lists_ownerships() function.
1508 public function testApiListsOwnerships()
1510 $result = api_lists_ownerships('json');
1511 foreach ($result['lists']['lists'] as $list) {
1512 self::assertList($list);
1517 * Test the api_lists_ownerships() function without an authenticated user.
1521 public function testApiListsOwnershipsWithoutAuthenticatedUser()
1523 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1524 BasicAuth::setCurrentUserID();
1525 $_SESSION['authenticated'] = false;
1526 api_lists_ownerships('json');
1530 * Test the api_statuses_f() function.
1534 public function testApiStatusesFWithIncoming()
1536 // $result = api_statuses_f('incoming');
1537 // self::assertArrayHasKey('user', $result);
1542 * Test the api_direct_messages_new() function.
1546 public function testApiDirectMessagesNew()
1548 $result = api_direct_messages_new('json');
1549 self::assertNull($result);
1553 * Test the api_direct_messages_new() function without an authenticated user.
1557 public function testApiDirectMessagesNewWithoutAuthenticatedUser()
1559 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1560 BasicAuth::setCurrentUserID();
1561 $_SESSION['authenticated'] = false;
1562 api_direct_messages_new('json');
1566 * Test the api_direct_messages_new() function with an user ID.
1570 public function testApiDirectMessagesNewWithUserId()
1572 $_POST['text'] = 'message_text';
1573 $_REQUEST['user_id'] = $this->otherUser['id'];
1574 $result = api_direct_messages_new('json');
1575 self::assertEquals(['direct_message' => ['error' => -1]], $result);
1579 * Test the api_direct_messages_new() function with a screen name.
1583 public function testApiDirectMessagesNewWithScreenName()
1585 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1586 $_POST['text'] = 'message_text';
1587 $_REQUEST['user_id'] = $this->friendUser['id'];
1588 $result = api_direct_messages_new('json');
1589 self::assertStringContainsString('message_text', $result['direct_message']['text']);
1590 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
1591 self::assertEquals(1, $result['direct_message']['friendica_seen']);
1595 * Test the api_direct_messages_new() function with a title.
1599 public function testApiDirectMessagesNewWithTitle()
1601 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1602 $_POST['text'] = 'message_text';
1603 $_REQUEST['user_id'] = $this->friendUser['id'];
1604 $_REQUEST['title'] = 'message_title';
1605 $result = api_direct_messages_new('json');
1606 self::assertStringContainsString('message_text', $result['direct_message']['text']);
1607 self::assertStringContainsString('message_title', $result['direct_message']['text']);
1608 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
1609 self::assertEquals(1, $result['direct_message']['friendica_seen']);
1613 * Test the api_direct_messages_new() function with an RSS result.
1617 public function testApiDirectMessagesNewWithRss()
1619 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1620 $_POST['text'] = 'message_text';
1621 $_REQUEST['user_id'] = $this->friendUser['id'];
1622 $result = api_direct_messages_new('rss');
1623 self::assertXml($result, 'direct-messages');
1627 * Test the api_direct_messages_destroy() function.
1631 public function testApiDirectMessagesDestroy()
1633 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1634 api_direct_messages_destroy('json');
1638 * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
1642 public function testApiDirectMessagesDestroyWithVerbose()
1644 $_GET['friendica_verbose'] = 'true';
1645 $result = api_direct_messages_destroy('json');
1649 'result' => 'error',
1650 'message' => 'message id or parenturi not specified'
1658 * Test the api_direct_messages_destroy() function without an authenticated user.
1662 public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
1664 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1665 BasicAuth::setCurrentUserID();
1666 $_SESSION['authenticated'] = false;
1667 api_direct_messages_destroy('json');
1671 * Test the api_direct_messages_destroy() function with a non-zero ID.
1675 public function testApiDirectMessagesDestroyWithId()
1677 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1678 $_REQUEST['id'] = 1;
1679 api_direct_messages_destroy('json');
1683 * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
1687 public function testApiDirectMessagesDestroyWithIdAndVerbose()
1689 $_REQUEST['id'] = 1;
1690 $_REQUEST['friendica_parenturi'] = 'parent_uri';
1691 $_GET['friendica_verbose'] = 'true';
1692 $result = api_direct_messages_destroy('json');
1696 'result' => 'error',
1697 'message' => 'message id not in database'
1705 * Test the api_direct_messages_destroy() function with a non-zero ID.
1709 public function testApiDirectMessagesDestroyWithCorrectId()
1711 $this->markTestIncomplete('We need to add a dataset for this.');
1715 * Test the api_direct_messages_box() function.
1719 public function testApiDirectMessagesBoxWithSentbox()
1721 $_REQUEST['page'] = -1;
1722 $_REQUEST['max_id'] = 10;
1723 $result = api_direct_messages_box('json', 'sentbox', 'false');
1724 self::assertArrayHasKey('direct_message', $result);
1728 * Test the api_direct_messages_box() function.
1732 public function testApiDirectMessagesBoxWithConversation()
1734 $result = api_direct_messages_box('json', 'conversation', 'false');
1735 self::assertArrayHasKey('direct_message', $result);
1739 * Test the api_direct_messages_box() function.
1743 public function testApiDirectMessagesBoxWithAll()
1745 $result = api_direct_messages_box('json', 'all', 'false');
1746 self::assertArrayHasKey('direct_message', $result);
1750 * Test the api_direct_messages_box() function.
1754 public function testApiDirectMessagesBoxWithInbox()
1756 $result = api_direct_messages_box('json', 'inbox', 'false');
1757 self::assertArrayHasKey('direct_message', $result);
1761 * Test the api_direct_messages_box() function.
1765 public function testApiDirectMessagesBoxWithVerbose()
1767 $result = api_direct_messages_box('json', 'sentbox', 'true');
1771 'result' => 'error',
1772 'message' => 'no mails available'
1780 * Test the api_direct_messages_box() function with a RSS result.
1784 public function testApiDirectMessagesBoxWithRss()
1786 $result = api_direct_messages_box('rss', 'sentbox', 'false');
1787 self::assertXml($result, 'direct-messages');
1791 * Test the api_direct_messages_box() function without an authenticated user.
1795 public function testApiDirectMessagesBoxWithUnallowedUser()
1797 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1798 BasicAuth::setCurrentUserID();
1799 api_direct_messages_box('json', 'sentbox', 'false');
1803 * Test the api_direct_messages_sentbox() function.
1807 public function testApiDirectMessagesSentbox()
1809 $result = api_direct_messages_sentbox('json');
1810 self::assertArrayHasKey('direct_message', $result);
1814 * Test the api_direct_messages_inbox() function.
1818 public function testApiDirectMessagesInbox()
1820 $result = api_direct_messages_inbox('json');
1821 self::assertArrayHasKey('direct_message', $result);
1825 * Test the api_direct_messages_all() function.
1829 public function testApiDirectMessagesAll()
1831 $result = api_direct_messages_all('json');
1832 self::assertArrayHasKey('direct_message', $result);
1836 * Test the api_direct_messages_conversation() function.
1840 public function testApiDirectMessagesConversation()
1842 $result = api_direct_messages_conversation('json');
1843 self::assertArrayHasKey('direct_message', $result);
1847 * Test the api_oauth_request_token() function.
1851 public function testApiOauthRequestToken()
1853 $this->markTestIncomplete('exit() kills phpunit as well');
1857 * Test the api_oauth_access_token() function.
1861 public function testApiOauthAccessToken()
1863 $this->markTestIncomplete('exit() kills phpunit as well');
1867 * Test the api_fr_photos_list() function.
1871 public function testApiFrPhotosList()
1873 $result = api_fr_photos_list('json');
1874 self::assertArrayHasKey('photo', $result);
1878 * Test the api_fr_photos_list() function without an authenticated user.
1882 public function testApiFrPhotosListWithoutAuthenticatedUser()
1884 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1885 BasicAuth::setCurrentUserID();
1886 $_SESSION['authenticated'] = false;
1887 api_fr_photos_list('json');
1891 * Test the api_fr_photo_create_update() function.
1893 public function testApiFrPhotoCreateUpdate()
1895 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1896 api_fr_photo_create_update('json');
1900 * Test the api_fr_photo_create_update() function without an authenticated user.
1904 public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
1906 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1907 BasicAuth::setCurrentUserID();
1908 $_SESSION['authenticated'] = false;
1909 api_fr_photo_create_update('json');
1913 * Test the api_fr_photo_create_update() function with an album name.
1917 public function testApiFrPhotoCreateUpdateWithAlbum()
1919 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1920 $_REQUEST['album'] = 'album_name';
1921 api_fr_photo_create_update('json');
1925 * Test the api_fr_photo_create_update() function with the update mode.
1929 public function testApiFrPhotoCreateUpdateWithUpdate()
1931 $this->markTestIncomplete('We need to create a dataset for this');
1935 * Test the api_fr_photo_create_update() function with an uploaded file.
1939 public function testApiFrPhotoCreateUpdateWithFile()
1941 $this->markTestIncomplete();
1945 * Test the api_fr_photo_detail() function.
1949 public function testApiFrPhotoDetail()
1951 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1952 api_fr_photo_detail('json');
1956 * Test the api_fr_photo_detail() function without an authenticated user.
1960 public function testApiFrPhotoDetailWithoutAuthenticatedUser()
1962 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1963 BasicAuth::setCurrentUserID();
1964 $_SESSION['authenticated'] = false;
1965 api_fr_photo_detail('json');
1969 * Test the api_fr_photo_detail() function with a photo ID.
1973 public function testApiFrPhotoDetailWithPhotoId()
1975 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1976 $_REQUEST['photo_id'] = 1;
1977 api_fr_photo_detail('json');
1981 * Test the api_fr_photo_detail() function with a correct photo ID.
1985 public function testApiFrPhotoDetailCorrectPhotoId()
1987 $this->markTestIncomplete('We need to create a dataset for this.');
1991 * Test the api_account_update_profile_image() function.
1995 public function testApiAccountUpdateProfileImage()
1997 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1998 api_account_update_profile_image('json');
2002 * Test the api_account_update_profile_image() function without an authenticated user.
2006 public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
2008 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2009 BasicAuth::setCurrentUserID();
2010 $_SESSION['authenticated'] = false;
2011 api_account_update_profile_image('json');
2015 * Test the api_account_update_profile_image() function with an uploaded file.
2019 public function testApiAccountUpdateProfileImageWithUpload()
2021 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2022 $this->markTestIncomplete();
2026 * Test the check_acl_input() function.
2030 public function testCheckAclInput()
2032 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
2033 // Where does this result come from?
2034 self::assertEquals(1, $result);
2038 * Test the check_acl_input() function with an empty ACL string.
2042 public function testCheckAclInputWithEmptyAclString()
2044 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
2045 self::assertFalse($result);
2049 * Test the save_media_to_database() function.
2053 public function testSaveMediaToDatabase()
2055 $this->markTestIncomplete();
2059 * Test the post_photo_item() function.
2063 public function testPostPhotoItem()
2065 $this->markTestIncomplete();
2069 * Test the prepare_photo_data() function.
2073 public function testPreparePhotoData()
2075 $this->markTestIncomplete();
2079 * Test the api_share_as_retweet() function with a valid item.
2083 public function testApiShareAsRetweetWithValidItem()
2085 $this->markTestIncomplete();
2089 * Test the api_in_reply_to() function with a valid item.
2093 public function testApiInReplyToWithValidItem()
2095 $this->markTestIncomplete();
2099 * Test the api_clean_plain_items() function.
2103 public function testApiCleanPlainItems()
2105 $_REQUEST['include_entities'] = 'true';
2106 $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
2107 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
2111 * Test the api_best_nickname() function with contacts.
2115 public function testApiBestNicknameWithContacts()
2117 $this->markTestIncomplete();
2121 * Test the api_friendica_group_show() function.
2125 public function testApiFriendicaGroupShow()
2127 $this->markTestIncomplete();
2131 * Test the api_friendica_group_delete() function.
2135 public function testApiFriendicaGroupDelete()
2137 $this->markTestIncomplete();
2141 * Test the api_lists_destroy() function.
2145 public function testApiListsDestroy()
2147 $this->markTestIncomplete();
2151 * Test the group_create() function.
2155 public function testGroupCreate()
2157 $this->markTestIncomplete();
2161 * Test the api_friendica_group_create() function.
2165 public function testApiFriendicaGroupCreate()
2167 $this->markTestIncomplete();
2171 * Test the api_lists_create() function.
2175 public function testApiListsCreate()
2177 $this->markTestIncomplete();
2181 * Test the api_friendica_group_update() function.
2185 public function testApiFriendicaGroupUpdate()
2187 $this->markTestIncomplete();
2191 * Test the api_lists_update() function.
2195 public function testApiListsUpdate()
2197 $this->markTestIncomplete();
2201 * Test the api_friendica_activity() function.
2205 public function testApiFriendicaActivity()
2207 $this->markTestIncomplete();
2211 * Test the api_friendica_notification_seen() function.
2215 public function testApiFriendicaNotificationSeen()
2217 $this->markTestIncomplete();
2221 * Test the api_friendica_direct_messages_setseen() function.
2225 public function testApiFriendicaDirectMessagesSetseen()
2227 $this->markTestIncomplete();
2231 * Test the api_friendica_direct_messages_search() function.
2235 public function testApiFriendicaDirectMessagesSearch()
2237 $this->markTestIncomplete();