]> git.mxchange.org Git - friendica.git/blob - tests/legacy/ApiTest.php
API: Fix profile_url handling / missing constant
[friendica.git] / tests / legacy / ApiTest.php
1 <?php
2 /**
3  * ApiTest class.
4  */
5
6 namespace Friendica\Test\legacy;
7
8 use Friendica\App;
9 use Friendica\Core\Config\Capability\IManageConfigValues;
10 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
11 use Friendica\Core\Protocol;
12 use Friendica\DI;
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;
23
24 require_once __DIR__ . '/../../include/api.php';
25
26 /**
27  * Tests for the API functions.
28  *
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
31  *
32  * @backupGlobals enabled
33  */
34 class ApiTest extends FixtureTest
35 {
36         /**
37          * @var TestHandler Can handle log-outputs
38          */
39         protected $logOutput;
40
41         /** @var array */
42         protected $selfUser;
43         /** @var array */
44         protected $friendUser;
45         /** @var array */
46         protected $otherUser;
47
48         protected $wrongUserId;
49
50         /** @var App */
51         protected $app;
52
53         /** @var IManageConfigValues */
54         protected $config;
55
56         /**
57          * Create variables used by tests.
58          */
59         protected function setUp() : void
60         {
61                 global $API, $called_api;
62                 $API = [];
63                 $called_api = [];
64
65                 parent::setUp();
66
67                 /** @var IManageConfigValues $config */
68                 $this->config = $this->dice->create(IManageConfigValues::class);
69
70                 $this->config->set('system', 'url', 'http://localhost');
71                 $this->config->set('system', 'hostname', 'localhost');
72                 $this->config->set('system', 'worker_dont_fork', true);
73
74                 // Default config
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');
80
81
82                 /** @var App app */
83                 $this->app = DI::app();
84
85                 DI::args()->setArgc(1);
86
87                 // User data that the test database is populated with
88                 $this->selfUser   = [
89                         'id'   => 42,
90                         'name' => 'Self contact',
91                         'nick' => 'selfcontact',
92                         'nurl' => 'http://localhost/profile/selfcontact'
93                 ];
94                 $this->friendUser = [
95                         'id'   => 44,
96                         'name' => 'Friend contact',
97                         'nick' => 'friendcontact',
98                         'nurl' => 'http://localhost/profile/friendcontact'
99                 ];
100                 $this->otherUser  = [
101                         'id'   => 43,
102                         'name' => 'othercontact',
103                         'nick' => 'othercontact',
104                         'nurl' => 'http://localhost/profile/othercontact'
105                 ];
106
107                 // User ID that we know is not in the database
108                 $this->wrongUserId = 666;
109
110                 DI::session()->start();
111
112                 // Most API require login so we force the session
113                 $_SESSION = [
114                         'authenticated' => true,
115                         'uid'           => $this->selfUser['id']
116                 ];
117                 BasicAuth::setCurrentUserID($this->selfUser['id']);
118         }
119
120         /**
121          * Assert that an user array contains expected keys.
122          *
123          * @param array $user User array
124          *
125          * @return void
126          */
127         private function assertSelfUser(array $user)
128         {
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']);
137         }
138
139         /**
140          * Assert that an user array contains expected keys.
141          *
142          * @param array $user User array
143          *
144          * @return void
145          */
146         private function assertOtherUser(array $user = [])
147         {
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']);
153         }
154
155         /**
156          * Assert that a status array contains expected keys.
157          *
158          * @param array $status Status array
159          *
160          * @return void
161          */
162         private function assertStatus(array $status = [])
163         {
164                 self::assertIsString($status['text'] ?? '');
165                 self::assertIsInt($status['id'] ?? '');
166                 // We could probably do more checks here.
167         }
168
169         /**
170          * Assert that a list array contains expected keys.
171          *
172          * @param array $list List array
173          *
174          * @return void
175          */
176         private function assertList(array $list = [])
177         {
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.
183         }
184
185         /**
186          * Assert that the string is XML and contain the root element.
187          *
188          * @param string $result       XML string
189          * @param string $root_element Root element name
190          *
191          * @return void
192          */
193         private function assertXml($result = '', $root_element = '')
194         {
195                 self::assertStringStartsWith('<?xml version="1.0"?>', $result);
196                 self::assertStringContainsString('<' . $root_element, $result);
197                 // We could probably do more checks here.
198         }
199
200         /**
201          * Get the path to a temporary empty PNG image.
202          *
203          * @return string Path
204          */
205         private function getTempImage()
206         {
207                 $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file');
208                 file_put_contents(
209                         $tmpFile,
210                         base64_decode(
211                         // Empty 1x1 px PNG image
212                                 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
213                         )
214                 );
215
216                 return $tmpFile;
217         }
218
219         /**
220          * Test the api_user() function.
221          *
222          * @return void
223          */
224         public function testApiUser()
225         {
226                 self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
227         }
228
229         /**
230          * Test the api_user() function with an unallowed user.
231          *
232          * @return void
233          */
234         public function testApiUserWithUnallowedUser()
235         {
236                 // self::assertEquals(false, api_user());
237         }
238
239         /**
240          * Test the api_source() function.
241          *
242          * @return void
243          */
244         public function testApiSource()
245         {
246                 self::assertEquals('api', BasicAuth::getCurrentApplicationToken()['name']);
247         }
248
249         /**
250          * Test the api_source() function with a Twidere user agent.
251          *
252          * @return void
253          */
254         public function testApiSourceWithTwidere()
255         {
256                 $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
257                 self::assertEquals('Twidere', BasicAuth::getCurrentApplicationToken()['name']);
258         }
259
260         /**
261          * Test the api_source() function with a GET parameter.
262          *
263          * @return void
264          */
265         public function testApiSourceWithGet()
266         {
267                 $_REQUEST['source'] = 'source_name';
268                 self::assertEquals('source_name', BasicAuth::getCurrentApplicationToken()['name']);
269         }
270
271         /**
272          * Test the api_date() function.
273          *
274          * @return void
275          */
276         public function testApiDate()
277         {
278                 self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', DateTimeFormat::utc('1990-10-10', DateTimeFormat::API));
279         }
280
281         /**
282          * Test the api_register_func() function.
283          *
284          * @return void
285          */
286         public function testApiRegisterFunc()
287         {
288                 global $API;
289                 self::assertNull(
290                         api_register_func(
291                                 'api_path',
292                                 function () {
293                                 },
294                                 true,
295                                 'method'
296                         )
297                 );
298                 self::assertTrue($API['api_path']['auth']);
299                 self::assertEquals('method', $API['api_path']['method']);
300                 self::assertTrue(is_callable($API['api_path']['func']));
301         }
302
303         /**
304          * Test the BasicAuth::getCurrentUserID() function without any login.
305          *
306          * @runInSeparateProcess
307          * @preserveGlobalState disabled
308          * @preserveGlobalState disabled
309          */
310         public function testApiLoginWithoutLogin()
311         {
312                 BasicAuth::setCurrentUserID();
313                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
314                 BasicAuth::getCurrentUserID(true);
315         }
316
317         /**
318          * Test the BasicAuth::getCurrentUserID() function with a bad login.
319          *
320          * @runInSeparateProcess
321          * @preserveGlobalState disabled
322          * @preserveGlobalState disabled
323          */
324         public function testApiLoginWithBadLogin()
325         {
326                 BasicAuth::setCurrentUserID();
327                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
328                 $_SERVER['PHP_AUTH_USER'] = 'user@server';
329                 BasicAuth::getCurrentUserID(true);
330         }
331
332         /**
333          * Test the BasicAuth::getCurrentUserID() function with oAuth.
334          *
335          * @return void
336          */
337         public function testApiLoginWithOauth()
338         {
339                 $this->markTestIncomplete('Can we test this easily?');
340         }
341
342         /**
343          * Test the BasicAuth::getCurrentUserID() function with authentication provided by an addon.
344          *
345          * @return void
346          */
347         public function testApiLoginWithAddonAuth()
348         {
349                 $this->markTestIncomplete('Can we test this easily?');
350         }
351
352         /**
353          * Test the BasicAuth::getCurrentUserID() function with a correct login.
354          *
355          * @runInSeparateProcess
356          * @preserveGlobalState disabled
357          * @doesNotPerformAssertions
358          */
359         public function testApiLoginWithCorrectLogin()
360         {
361                 BasicAuth::setCurrentUserID();
362                 $_SERVER['PHP_AUTH_USER'] = 'Test user';
363                 $_SERVER['PHP_AUTH_PW']   = 'password';
364                 BasicAuth::getCurrentUserID(true);
365         }
366
367         /**
368          * Test the BasicAuth::getCurrentUserID() function with a remote user.
369          *
370          * @runInSeparateProcess
371          * @preserveGlobalState disabled
372          */
373         public function testApiLoginWithRemoteUser()
374         {
375                 BasicAuth::setCurrentUserID();
376                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
377                 $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
378                 BasicAuth::getCurrentUserID(true);
379         }
380
381         /**
382          * Test the api_call() function.
383          *
384          * @runInSeparateProcess
385          * @preserveGlobalState disabled
386          */
387         public function testApiCall()
388         {
389                 global $API;
390                 $API['api_path']           = [
391                         'method' => 'method',
392                         'func'   => function () {
393                                 return ['data' => ['some_data']];
394                         }
395                 ];
396                 $_SERVER['REQUEST_METHOD'] = 'method';
397                 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
398                 $_GET['callback']          = 'callback_name';
399
400                 self::assertEquals(
401                         'callback_name(["some_data"])',
402                         api_call('api_path', 'json')
403                 );
404         }
405
406         /**
407          * Test the api_call() function with the profiled enabled.
408          *
409          * @runInSeparateProcess
410          * @preserveGlobalState disabled
411          */
412         public function testApiCallWithProfiler()
413         {
414                 global $API;
415                 $API['api_path']           = [
416                         'method' => 'method',
417                         'func'   => function () {
418                                 return ['data' => ['some_data']];
419                         }
420                 ];
421
422                 $_SERVER['REQUEST_METHOD'] = 'method';
423                 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
424
425                 $this->config->set('system', 'profiler', true);
426                 $this->config->set('rendertime', 'callstack', true);
427                 $this->app->callstack = [
428                         'database'       => ['some_function' => 200],
429                         'database_write' => ['some_function' => 200],
430                         'cache'          => ['some_function' => 200],
431                         'cache_write'    => ['some_function' => 200],
432                         'network'        => ['some_function' => 200]
433                 ];
434
435                 self::assertEquals(
436                         '["some_data"]',
437                         api_call('api_path', 'json')
438                 );
439         }
440
441         /**
442          * Test the api_call() function with a JSON result.
443          *
444          * @runInSeparateProcess
445          * @preserveGlobalState disabled
446          */
447         public function testApiCallWithJson()
448         {
449                 global $API;
450                 $API['api_path']           = [
451                         'method' => 'method',
452                         'func'   => function () {
453                                 return ['data' => ['some_data']];
454                         }
455                 ];
456                 $_SERVER['REQUEST_METHOD'] = 'method';
457                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
458
459                 self::assertEquals(
460                         '["some_data"]',
461                         api_call('api_path.json', 'json')
462                 );
463         }
464
465         /**
466          * Test the api_call() function with an XML result.
467          *
468          * @runInSeparateProcess
469          * @preserveGlobalState disabled
470          */
471         public function testApiCallWithXml()
472         {
473                 global $API;
474                 $API['api_path']           = [
475                         'method' => 'method',
476                         'func'   => function () {
477                                 return 'some_data';
478                         }
479                 ];
480                 $_SERVER['REQUEST_METHOD'] = 'method';
481                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
482
483                 $args = DI::args()->determine($_SERVER, $_GET);
484
485                 self::assertEquals(
486                         'some_data',
487                         api_call('api_path.xml', 'xml')
488                 );
489         }
490
491         /**
492          * Test the api_call() function with an RSS result.
493          *
494          * @runInSeparateProcess
495          * @preserveGlobalState disabled
496          */
497         public function testApiCallWithRss()
498         {
499                 global $API;
500                 $API['api_path']           = [
501                         'method' => 'method',
502                         'func'   => function () {
503                                 return 'some_data';
504                         }
505                 ];
506                 $_SERVER['REQUEST_METHOD'] = 'method';
507                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
508
509                 self::assertEquals(
510                         '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
511                         'some_data',
512                         api_call('api_path.rss', 'rss')
513                 );
514         }
515
516         /**
517          * Test the api_call() function with an Atom result.
518          *
519          * @runInSeparateProcess
520          * @preserveGlobalState disabled
521          */
522         public function testApiCallWithAtom()
523         {
524                 global $API;
525                 $API['api_path']           = [
526                         'method' => 'method',
527                         'func'   => function () {
528                                 return 'some_data';
529                         }
530                 ];
531                 $_SERVER['REQUEST_METHOD'] = 'method';
532                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
533
534                 self::assertEquals(
535                         '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
536                         'some_data',
537                         api_call('api_path.atom', 'atom')
538                 );
539         }
540
541         /**
542          * Test the api_rss_extra() function.
543          *
544          * @return void
545          */
546         public function testApiRssExtra()
547         {
548                 /*
549                 $user_info = ['url' => 'user_url', 'lang' => 'en'];
550                 $result    = api_rss_extra([], $user_info);
551                 self::assertEquals($user_info, $result['$user']);
552                 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
553                 self::assertArrayHasKey('self', $result['$rss']);
554                 self::assertArrayHasKey('base', $result['$rss']);
555                 self::assertArrayHasKey('updated', $result['$rss']);
556                 self::assertArrayHasKey('atom_updated', $result['$rss']);
557                 self::assertArrayHasKey('language', $result['$rss']);
558                 self::assertArrayHasKey('logo', $result['$rss']);
559                 */
560         }
561
562         /**
563          * Test the api_rss_extra() function without any user info.
564          *
565          * @return void
566          */
567         public function testApiRssExtraWithoutUserInfo()
568         {
569                 /*
570                 $result = api_rss_extra([], null);
571                 self::assertIsArray($result['$user']);
572                 self::assertArrayHasKey('alternate', $result['$rss']);
573                 self::assertArrayHasKey('self', $result['$rss']);
574                 self::assertArrayHasKey('base', $result['$rss']);
575                 self::assertArrayHasKey('updated', $result['$rss']);
576                 self::assertArrayHasKey('atom_updated', $result['$rss']);
577                 self::assertArrayHasKey('language', $result['$rss']);
578                 self::assertArrayHasKey('logo', $result['$rss']);
579                 */
580         }
581
582         /**
583          * Test the api_get_user() function.
584          *
585          * @return void
586          */
587         public function testApiGetUser()
588         {
589                 // $user = api_get_user();
590                 // self::assertSelfUser($user);
591                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
592                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
593                 // self::assertEquals('ededed', $user['profile_background_color']);
594         }
595
596         /**
597          * Test the api_get_user() function with a Frio schema.
598          *
599          * @return void
600          */
601         public function testApiGetUserWithFrioSchema()
602         {
603                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
604                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
605                 // $user = api_get_user();
606                 // self::assertSelfUser($user);
607                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
608                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
609                 // self::assertEquals('ededed', $user['profile_background_color']);
610         }
611
612         /**
613          * Test the api_get_user() function with an empty Frio schema.
614          *
615          * @return void
616          */
617         public function testApiGetUserWithEmptyFrioSchema()
618         {
619                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
620                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
621                 // $user = api_get_user();
622                 // self::assertSelfUser($user);
623                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
624                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
625                 // self::assertEquals('ededed', $user['profile_background_color']);
626         }
627
628         /**
629          * Test the api_get_user() function with a custom Frio schema.
630          *
631          * @return void
632          */
633         public function testApiGetUserWithCustomFrioSchema()
634         {
635                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
636                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
637                 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
638                 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
639                 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
640                 // $user = api_get_user();
641                 // self::assertSelfUser($user);
642                 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
643                 // self::assertEquals('123456', $user['profile_link_color']);
644                 // self::assertEquals('123456', $user['profile_background_color']);
645         }
646
647         /**
648          * Test the api_get_user() function with an user that is not allowed to use the API.
649          *
650          * @runInSeparateProcess
651          * @preserveGlobalState disabled
652          */
653         public function testApiGetUserWithoutApiUser()
654         {
655                 // api_get_user() with empty parameters is not used anymore
656                 /*
657                 $_SERVER['PHP_AUTH_USER'] = 'Test user';
658                 $_SERVER['PHP_AUTH_PW']   = 'password';
659                 BasicAuth::setCurrentUserID();
660                 self::assertFalse(api_get_user());
661                 */
662         }
663
664         /**
665          * Test the api_get_user() function with an user ID in a GET parameter.
666          *
667          * @return void
668          */
669         public function testApiGetUserWithGetId()
670         {
671                 // self::assertOtherUser(api_get_user());
672         }
673
674         /**
675          * Test the api_get_user() function with a wrong user ID in a GET parameter.
676          *
677          * @return void
678          */
679         public function testApiGetUserWithWrongGetId()
680         {
681                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
682                 // self::assertOtherUser(api_get_user());
683         }
684
685         /**
686          * Test the api_get_user() function with an user name in a GET parameter.
687          *
688          * @return void
689          */
690         public function testApiGetUserWithGetName()
691         {
692                 // self::assertSelfUser(api_get_user());
693         }
694
695         /**
696          * Test the api_get_user() function with a profile URL in a GET parameter.
697          *
698          * @return void
699          */
700         public function testApiGetUserWithGetUrl()
701         {
702                 // self::assertSelfUser(api_get_user());
703         }
704
705         /**
706          * Test the api_get_user() function with an user ID in the API path.
707          *
708          * @return void
709          */
710         public function testApiGetUserWithNumericCalledApi()
711         {
712                 // global $called_api;
713                 // $called_api         = ['api_path'];
714                 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
715                 // self::assertOtherUser(api_get_user());
716         }
717
718         /**
719          * Test the api_get_user() function with the $called_api global variable.
720          *
721          * @return void
722          */
723         public function testApiGetUserWithCalledApi()
724         {
725                 // global $called_api;
726                 // $called_api = ['api', 'api_path'];
727                 // self::assertSelfUser(api_get_user());
728         }
729
730         /**
731          * Test the Arrays::walkRecursive() function.
732          *
733          * @return void
734          */
735         public function testApiWalkRecursive()
736         {
737                 $array = ['item1'];
738                 self::assertEquals(
739                         $array,
740                         Arrays::walkRecursive(
741                                 $array,
742                                 function () {
743                                         // Should we test this with a callback that actually does something?
744                                         return true;
745                                 }
746                         )
747                 );
748         }
749
750         /**
751          * Test the Arrays::walkRecursive() function with an array.
752          *
753          * @return void
754          */
755         public function testApiWalkRecursiveWithArray()
756         {
757                 $array = [['item1'], ['item2']];
758                 self::assertEquals(
759                         $array,
760                         Arrays::walkRecursive(
761                                 $array,
762                                 function () {
763                                         // Should we test this with a callback that actually does something?
764                                         return true;
765                                 }
766                         )
767                 );
768         }
769
770         /**
771          * Test the BaseApi::reformatXML() function.
772          *
773          * @return void
774          */
775         public function testApiReformatXml()
776         {
777                 $item = true;
778                 $key  = '';
779                 self::assertTrue(ApiResponse::reformatXML($item, $key));
780                 self::assertEquals('true', $item);
781         }
782
783         /**
784          * Test the BaseApi::reformatXML() function with a statusnet_api key.
785          *
786          * @return void
787          */
788         public function testApiReformatXmlWithStatusnetKey()
789         {
790                 $item = '';
791                 $key  = 'statusnet_api';
792                 self::assertTrue(ApiResponse::reformatXML($item, $key));
793                 self::assertEquals('statusnet:api', $key);
794         }
795
796         /**
797          * Test the BaseApi::reformatXML() function with a friendica_api key.
798          *
799          * @return void
800          */
801         public function testApiReformatXmlWithFriendicaKey()
802         {
803                 $item = '';
804                 $key  = 'friendica_api';
805                 self::assertTrue(ApiResponse::reformatXML($item, $key));
806                 self::assertEquals('friendica:api', $key);
807         }
808
809         /**
810          * Test the BaseApi::createXML() function.
811          *
812          * @return void
813          */
814         public function testApiCreateXml()
815         {
816                 self::assertEquals(
817                         '<?xml version="1.0"?>' . "\n" .
818                         '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
819                         'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
820                         'xmlns:georss="http://www.georss.org/georss">' . "\n" .
821                         '  <data>some_data</data>' . "\n" .
822                         '</root_element>' . "\n",
823                         DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
824                 );
825         }
826
827         /**
828          * Test the BaseApi::createXML() function without any XML namespace.
829          *
830          * @return void
831          */
832         public function testApiCreateXmlWithoutNamespaces()
833         {
834                 self::assertEquals(
835                         '<?xml version="1.0"?>' . "\n" .
836                         '<ok>' . "\n" .
837                         '  <data>some_data</data>' . "\n" .
838                         '</ok>' . "\n",
839                         DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
840                 );
841         }
842
843         /**
844          * Test the BaseApi::formatData() function.
845          *
846          * @return void
847          */
848         public function testApiFormatData()
849         {
850                 $data = ['some_data'];
851                 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
852         }
853
854         /**
855          * Test the BaseApi::formatData() function with an XML result.
856          *
857          * @return void
858          */
859         public function testApiFormatDataWithXml()
860         {
861                 self::assertEquals(
862                         '<?xml version="1.0"?>' . "\n" .
863                         '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
864                         'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
865                         'xmlns:georss="http://www.georss.org/georss">' . "\n" .
866                         '  <data>some_data</data>' . "\n" .
867                         '</root_element>' . "\n",
868                         DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
869                 );
870         }
871
872         /**
873          * Test the api_account_verify_credentials() function.
874          *
875          * @return void
876          */
877         public function testApiAccountVerifyCredentials()
878         {
879                 // self::assertArrayHasKey('user', api_account_verify_credentials('json'));
880         }
881
882         /**
883          * Test the api_account_verify_credentials() function without an authenticated user.
884          *
885          * @return void
886          */
887         public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
888         {
889                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
890                 // BasicAuth::setCurrentUserID();
891                 // $_SESSION['authenticated'] = false;
892                 // api_account_verify_credentials('json');
893         }
894
895         /**
896          * Test the api_statuses_mediap() function.
897          *
898          * @return void
899          */
900         public function testApiStatusesMediap()
901         {
902                 DI::args()->setArgc(2);
903
904                 $_FILES         = [
905                         'media' => [
906                                 'id'       => 666,
907                                 'size'     => 666,
908                                 'width'    => 666,
909                                 'height'   => 666,
910                                 'tmp_name' => $this->getTempImage(),
911                                 'name'     => 'spacer.png',
912                                 'type'     => 'image/png'
913                         ]
914                 ];
915                 $_GET['status'] = '<b>Status content</b>';
916
917                 $result = api_statuses_mediap('json');
918                 self::assertStatus($result['status']);
919         }
920
921         /**
922          * Test the api_statuses_mediap() function without an authenticated user.
923          *
924          * @return void
925          */
926         public function testApiStatusesMediapWithoutAuthenticatedUser()
927         {
928                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
929                 BasicAuth::setCurrentUserID();
930                 $_SESSION['authenticated'] = false;
931                 api_statuses_mediap('json');
932         }
933
934         /**
935          * Test the api_statuses_update() function.
936          *
937          * @return void
938          */
939         public function testApiStatusesUpdate()
940         {
941                 $_REQUEST['status']                = 'Status content #friendica';
942                 $_REQUEST['in_reply_to_status_id'] = -1;
943                 $_REQUEST['lat']                   = 48;
944                 $_REQUEST['long']                  = 7;
945                 $_FILES                            = [
946                         'media' => [
947                                 'id'       => 666,
948                                 'size'     => 666,
949                                 'width'    => 666,
950                                 'height'   => 666,
951                                 'tmp_name' => $this->getTempImage(),
952                                 'name'     => 'spacer.png',
953                                 'type'     => 'image/png'
954                         ]
955                 ];
956
957                 $result = api_statuses_update('json');
958                 self::assertStatus($result['status']);
959         }
960
961         /**
962          * Test the api_statuses_update() function with an HTML status.
963          *
964          * @return void
965          */
966         public function testApiStatusesUpdateWithHtml()
967         {
968                 $_REQUEST['htmlstatus'] = '<b>Status content</b>';
969
970                 $result = api_statuses_update('json');
971                 self::assertStatus($result['status']);
972         }
973
974         /**
975          * Test the api_statuses_update() function without an authenticated user.
976          *
977          * @return void
978          */
979         public function testApiStatusesUpdateWithoutAuthenticatedUser()
980         {
981                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
982                 BasicAuth::setCurrentUserID();
983                 $_SESSION['authenticated'] = false;
984                 api_statuses_update('json');
985         }
986
987         /**
988          * Test the api_statuses_update() function with a parent status.
989          *
990          * @return void
991          */
992         public function testApiStatusesUpdateWithParent()
993         {
994                 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
995         }
996
997         /**
998          * Test the api_statuses_update() function with a media_ids parameter.
999          *
1000          * @return void
1001          */
1002         public function testApiStatusesUpdateWithMediaIds()
1003         {
1004                 $this->markTestIncomplete();
1005         }
1006
1007         /**
1008          * Test the api_statuses_update() function with the throttle limit reached.
1009          *
1010          * @return void
1011          */
1012         public function testApiStatusesUpdateWithDayThrottleReached()
1013         {
1014                 $this->markTestIncomplete();
1015         }
1016
1017         /**
1018          * Test the api_media_upload() function.
1019          * @runInSeparateProcess
1020          * @preserveGlobalState disabled
1021          */
1022         public function testApiMediaUpload()
1023         {
1024                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1025                 api_media_upload();
1026         }
1027
1028         /**
1029          * Test the api_media_upload() function without an authenticated user.
1030          *
1031          * @return void
1032          */
1033         public function testApiMediaUploadWithoutAuthenticatedUser()
1034         {
1035                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1036                 BasicAuth::setCurrentUserID();
1037                 $_SESSION['authenticated'] = false;
1038                 api_media_upload();
1039         }
1040
1041         /**
1042          * Test the api_media_upload() function with an invalid uploaded media.
1043          *
1044          * @return void
1045          */
1046         public function testApiMediaUploadWithMedia()
1047         {
1048                 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1049                 $_FILES = [
1050                         'media' => [
1051                                 'id'       => 666,
1052                                 'tmp_name' => 'tmp_name'
1053                         ]
1054                 ];
1055                 api_media_upload();
1056         }
1057
1058         /**
1059          * Test the api_media_upload() function with an valid uploaded media.
1060          *
1061          * @return void
1062          */
1063         public function testApiMediaUploadWithValidMedia()
1064         {
1065                 $_FILES    = [
1066                         'media' => [
1067                                 'id'       => 666,
1068                                 'size'     => 666,
1069                                 'width'    => 666,
1070                                 'height'   => 666,
1071                                 'tmp_name' => $this->getTempImage(),
1072                                 'name'     => 'spacer.png',
1073                                 'type'     => 'image/png'
1074                         ]
1075                 ];
1076                 $app       = DI::app();
1077                 DI::args()->setArgc(2);
1078
1079                 $result = api_media_upload();
1080                 self::assertEquals('image/png', $result['media']['image']['image_type']);
1081                 self::assertEquals(1, $result['media']['image']['w']);
1082                 self::assertEquals(1, $result['media']['image']['h']);
1083                 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1084         }
1085
1086         /**
1087          * Test the api_status_show() function.
1088          */
1089         public function testApiStatusShowWithJson()
1090         {
1091                 // $result = api_status_show('json', 1);
1092                 // self::assertStatus($result['status']);
1093         }
1094
1095         /**
1096          * Test the api_status_show() function with an XML result.
1097          */
1098         public function testApiStatusShowWithXml()
1099         {
1100                 // $result = api_status_show('xml', 1);
1101                 // self::assertXml($result, 'statuses');
1102         }
1103
1104         /**
1105          * Test the api_get_last_status() function
1106          */
1107         public function testApiGetLastStatus()
1108         {
1109                 // $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1110                 // self::assertNotNull($item);
1111         }
1112
1113         /**
1114          * Test the api_users_show() function.
1115          *
1116          * @return void
1117          */
1118         public function testApiUsersShow()
1119         {
1120                 /*
1121                 $result = api_users_show('json');
1122                 // We can't use assertSelfUser() here because the user object is missing some properties.
1123                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1124                 self::assertEquals('DFRN', $result['user']['location']);
1125                 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1126                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1127                 self::assertTrue($result['user']['verified']);
1128                 */
1129         }
1130
1131         /**
1132          * Test the api_users_show() function with an XML result.
1133          *
1134          * @return void
1135          */
1136         public function testApiUsersShowWithXml()
1137         {
1138                 // $result = api_users_show('xml');
1139                 // self::assertXml($result, 'statuses');
1140         }
1141
1142         /**
1143          * Test the api_users_search() function.
1144          *
1145          * @return void
1146          */
1147         public function testApiUsersSearch()
1148         {
1149                 // $_GET['q'] = 'othercontact';
1150                 // $result    = api_users_search('json');
1151                 // self::assertOtherUser($result['users'][0]);
1152         }
1153
1154         /**
1155          * Test the api_users_search() function with an XML result.
1156          *
1157          * @return void
1158          */
1159         public function testApiUsersSearchWithXml()
1160         {
1161                 // $_GET['q'] = 'othercontact';
1162                 // $result    = api_users_search('xml');
1163                 // self::assertXml($result, 'users');
1164         }
1165
1166         /**
1167          * Test the api_users_search() function without a GET q parameter.
1168          *
1169          * @return void
1170          */
1171         public function testApiUsersSearchWithoutQuery()
1172         {
1173                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1174                 // api_users_search('json');
1175         }
1176
1177         /**
1178          * Test the api_users_lookup() function.
1179          *
1180          * @return void
1181          */
1182         public function testApiUsersLookup()
1183         {
1184                 // $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1185                 // api_users_lookup('json');
1186         }
1187
1188         /**
1189          * Test the api_users_lookup() function with an user ID.
1190          *
1191          * @return void
1192          */
1193         public function testApiUsersLookupWithUserId()
1194         {
1195                 // $_REQUEST['user_id'] = $this->otherUser['id'];
1196                 // $result              = api_users_lookup('json');
1197                 // self::assertOtherUser($result['users'][0]);
1198         }
1199
1200         /**
1201          * Test the api_search() function.
1202          *
1203          * @return void
1204          */
1205         public function testApiSearch()
1206         {
1207                 /*
1208                 $_REQUEST['q']      = 'reply';
1209                 $_REQUEST['max_id'] = 10;
1210                 $result             = api_search('json');
1211                 foreach ($result['status'] as $status) {
1212                         self::assertStatus($status);
1213                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1214                 }
1215                 */
1216         }
1217
1218         /**
1219          * Test the api_search() function a count parameter.
1220          *
1221          * @return void
1222          */
1223         public function testApiSearchWithCount()
1224         {
1225                 /*
1226                 $_REQUEST['q']     = 'reply';
1227                 $_REQUEST['count'] = 20;
1228                 $result            = api_search('json');
1229                 foreach ($result['status'] as $status) {
1230                         self::assertStatus($status);
1231                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1232                 }
1233                 */
1234         }
1235
1236         /**
1237          * Test the api_search() function with an rpp parameter.
1238          *
1239          * @return void
1240          */
1241         public function testApiSearchWithRpp()
1242         {
1243                 /*
1244                 $_REQUEST['q']   = 'reply';
1245                 $_REQUEST['rpp'] = 20;
1246                 $result          = api_search('json');
1247                 foreach ($result['status'] as $status) {
1248                         self::assertStatus($status);
1249                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1250                 }
1251                 */
1252         }
1253
1254         /**
1255          * Test the api_search() function with an q parameter contains hashtag.
1256          * @doesNotPerformAssertions
1257          */
1258         public function testApiSearchWithHashtag()
1259         {
1260                 /*
1261                 $_REQUEST['q'] = '%23friendica';
1262                 $result        = api_search('json');
1263                 foreach ($result['status'] as $status) {
1264                         self::assertStatus($status);
1265                         self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1266                 }
1267                 */
1268         }
1269
1270         /**
1271          * Test the api_search() function with an exclude_replies parameter.
1272          * @doesNotPerformAssertions
1273          */
1274         public function testApiSearchWithExcludeReplies()
1275         {
1276                 /*
1277                 $_REQUEST['max_id']          = 10;
1278                 $_REQUEST['exclude_replies'] = true;
1279                 $_REQUEST['q']               = 'friendica';
1280                 $result                      = api_search('json');
1281                 foreach ($result['status'] as $status) {
1282                         self::assertStatus($status);
1283                 }
1284                 */
1285         }
1286
1287         /**
1288          * Test the api_search() function without an authenticated user.
1289          *
1290          * @return void
1291          */
1292         public function testApiSearchWithUnallowedUser()
1293         {
1294                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1295                 // BasicAuth::setCurrentUserID();
1296                 // api_search('json');
1297         }
1298
1299         /**
1300          * Test the api_search() function without any GET query parameter.
1301          *
1302          * @return void
1303          */
1304         public function testApiSearchWithoutQuery()
1305         {
1306                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1307                 // api_search('json');
1308         }
1309
1310         /**
1311          * Test the api_statuses_home_timeline() function.
1312          *
1313          * @return void
1314          */
1315         public function testApiStatusesHomeTimeline()
1316         {
1317                 /*
1318                 $_REQUEST['max_id']          = 10;
1319                 $_REQUEST['exclude_replies'] = true;
1320                 $_REQUEST['conversation_id'] = 1;
1321                 $result                      = api_statuses_home_timeline('json');
1322                 self::assertNotEmpty($result['status']);
1323                 foreach ($result['status'] as $status) {
1324                         self::assertStatus($status);
1325                 }
1326                 */
1327         }
1328
1329         /**
1330          * Test the api_statuses_home_timeline() function with a negative page parameter.
1331          *
1332          * @return void
1333          */
1334         public function testApiStatusesHomeTimelineWithNegativePage()
1335         {
1336                 /*
1337                 $_REQUEST['page'] = -2;
1338                 $result           = api_statuses_home_timeline('json');
1339                 self::assertNotEmpty($result['status']);
1340                 foreach ($result['status'] as $status) {
1341                         self::assertStatus($status);
1342                 }
1343                 */
1344         }
1345
1346         /**
1347          * Test the api_statuses_home_timeline() with an unallowed user.
1348          *
1349          * @return void
1350          */
1351         public function testApiStatusesHomeTimelineWithUnallowedUser()
1352         {
1353                 /*
1354                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1355                 BasicAuth::setCurrentUserID();
1356                 api_statuses_home_timeline('json');
1357                 */
1358         }
1359
1360         /**
1361          * Test the api_statuses_home_timeline() function with an RSS result.
1362          *
1363          * @return void
1364          */
1365         public function testApiStatusesHomeTimelineWithRss()
1366         {
1367                 // $result = api_statuses_home_timeline('rss');
1368                 // self::assertXml($result, 'statuses');
1369         }
1370
1371         /**
1372          * Test the api_statuses_public_timeline() function.
1373          *
1374          * @return void
1375          */
1376         public function testApiStatusesPublicTimeline()
1377         {
1378                 /*
1379                 $_REQUEST['max_id']          = 10;
1380                 $_REQUEST['conversation_id'] = 1;
1381                 $result                      = api_statuses_public_timeline('json');
1382                 self::assertNotEmpty($result['status']);
1383                 foreach ($result['status'] as $status) {
1384                         self::assertStatus($status);
1385                 }
1386                 */
1387         }
1388
1389         /**
1390          * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1391          *
1392          * @return void
1393          */
1394         public function testApiStatusesPublicTimelineWithExcludeReplies()
1395         {
1396                 /*
1397                 $_REQUEST['max_id']          = 10;
1398                 $_REQUEST['exclude_replies'] = true;
1399                 $result                      = api_statuses_public_timeline('json');
1400                 self::assertNotEmpty($result['status']);
1401                 foreach ($result['status'] as $status) {
1402                         self::assertStatus($status);
1403                 }
1404                 */
1405         }
1406
1407         /**
1408          * Test the api_statuses_public_timeline() function with a negative page parameter.
1409          *
1410          * @return void
1411          */
1412         public function testApiStatusesPublicTimelineWithNegativePage()
1413         {
1414                 /*
1415                 $_REQUEST['page'] = -2;
1416                 $result           = api_statuses_public_timeline('json');
1417                 self::assertNotEmpty($result['status']);
1418                 foreach ($result['status'] as $status) {
1419                         self::assertStatus($status);
1420                 }
1421                 */
1422         }
1423
1424         /**
1425          * Test the api_statuses_public_timeline() function with an unallowed user.
1426          *
1427          * @return void
1428          */
1429         public function testApiStatusesPublicTimelineWithUnallowedUser()
1430         {
1431                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1432                 // BasicAuth::setCurrentUserID();
1433                 // api_statuses_public_timeline('json');
1434         }
1435
1436         /**
1437          * Test the api_statuses_public_timeline() function with an RSS result.
1438          *
1439          * @return void
1440          */
1441         public function testApiStatusesPublicTimelineWithRss()
1442         {
1443                 // $result = api_statuses_public_timeline('rss');
1444                 // self::assertXml($result, 'statuses');
1445         }
1446
1447         /**
1448          * Test the api_statuses_networkpublic_timeline() function.
1449          *
1450          * @return void
1451          */
1452         public function testApiStatusesNetworkpublicTimeline()
1453         {
1454                 /*
1455                 $_REQUEST['max_id'] = 10;
1456                 $result             = api_statuses_networkpublic_timeline('json');
1457                 self::assertNotEmpty($result['status']);
1458                 foreach ($result['status'] as $status) {
1459                         self::assertStatus($status);
1460                 }
1461                 */
1462         }
1463
1464         /**
1465          * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1466          *
1467          * @return void
1468          */
1469         public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1470         {
1471                 /*
1472                 $_REQUEST['page'] = -2;
1473                 $result           = api_statuses_networkpublic_timeline('json');
1474                 self::assertNotEmpty($result['status']);
1475                 foreach ($result['status'] as $status) {
1476                         self::assertStatus($status);
1477                 }
1478                 */
1479         }
1480
1481         /**
1482          * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1483          *
1484          * @return void
1485          */
1486         public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1487         {
1488                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1489                 // BasicAuth::setCurrentUserID();
1490                 // api_statuses_networkpublic_timeline('json');
1491         }
1492
1493         /**
1494          * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1495          *
1496          * @return void
1497          */
1498         public function testApiStatusesNetworkpublicTimelineWithRss()
1499         {
1500                 // $result = api_statuses_networkpublic_timeline('rss');
1501                 // self::assertXml($result, 'statuses');
1502         }
1503
1504         /**
1505          * Test the api_statuses_show() function.
1506          *
1507          * @return void
1508          */
1509         public function testApiStatusesShow()
1510         {
1511                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1512                 // api_statuses_show('json');
1513         }
1514
1515         /**
1516          * Test the api_statuses_show() function with an ID.
1517          *
1518          * @return void
1519          */
1520         public function testApiStatusesShowWithId()
1521         {
1522                 // DI::args()->setArgv(['', '', '', 1]);
1523                 // $result = api_statuses_show('json');
1524                 // self::assertStatus($result['status']);
1525         }
1526
1527         /**
1528          * Test the api_statuses_show() function with the conversation parameter.
1529          *
1530          * @return void
1531          */
1532         public function testApiStatusesShowWithConversation()
1533         {
1534                 /*
1535                 DI::args()->setArgv(['', '', '', 1]);
1536                 $_REQUEST['conversation'] = 1;
1537                 $result                   = api_statuses_show('json');
1538                 self::assertNotEmpty($result['status']);
1539                 foreach ($result['status'] as $status) {
1540                         self::assertStatus($status);
1541                 }
1542                 */
1543         }
1544
1545         /**
1546          * Test the api_statuses_show() function with an unallowed user.
1547          *
1548          * @return void
1549          */
1550         public function testApiStatusesShowWithUnallowedUser()
1551         {
1552                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1553                 // BasicAuth::setCurrentUserID();
1554                 // api_statuses_show('json');
1555         }
1556
1557         /**
1558          * Test the api_conversation_show() function.
1559          *
1560          * @return void
1561          */
1562         public function testApiConversationShow()
1563         {
1564                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1565                 // api_conversation_show('json');
1566         }
1567
1568         /**
1569          * Test the api_conversation_show() function with an ID.
1570          *
1571          * @return void
1572          */
1573         public function testApiConversationShowWithId()
1574         {
1575                 /*
1576                 DI::args()->setArgv(['', '', '', 1]);
1577                 $_REQUEST['max_id'] = 10;
1578                 $_REQUEST['page']   = -2;
1579                 $result             = api_conversation_show('json');
1580                 self::assertNotEmpty($result['status']);
1581                 foreach ($result['status'] as $status) {
1582                         self::assertStatus($status);
1583                 }
1584                 */
1585         }
1586
1587         /**
1588          * Test the api_conversation_show() function with an unallowed user.
1589          *
1590          * @return void
1591          */
1592         public function testApiConversationShowWithUnallowedUser()
1593         {
1594                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1595                 // BasicAuth::setCurrentUserID();
1596                 // api_conversation_show('json');
1597         }
1598
1599         /**
1600          * Test the api_statuses_repeat() function.
1601          *
1602          * @return void
1603          */
1604         public function testApiStatusesRepeat()
1605         {
1606                 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1607                 api_statuses_repeat('json');
1608         }
1609
1610         /**
1611          * Test the api_statuses_repeat() function without an authenticated user.
1612          *
1613          * @return void
1614          */
1615         public function testApiStatusesRepeatWithoutAuthenticatedUser()
1616         {
1617                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1618                 BasicAuth::setCurrentUserID();
1619                 $_SESSION['authenticated'] = false;
1620                 api_statuses_repeat('json');
1621         }
1622
1623         /**
1624          * Test the api_statuses_repeat() function with an ID.
1625          *
1626          * @return void
1627          */
1628         public function testApiStatusesRepeatWithId()
1629         {
1630                 DI::args()->setArgv(['', '', '', 1]);
1631                 $result = api_statuses_repeat('json');
1632                 self::assertStatus($result['status']);
1633
1634                 // Also test with a shared status
1635                 DI::args()->setArgv(['', '', '', 5]);
1636                 $result = api_statuses_repeat('json');
1637                 self::assertStatus($result['status']);
1638         }
1639
1640         /**
1641          * Test the api_statuses_destroy() function.
1642          *
1643          * @return void
1644          */
1645         public function testApiStatusesDestroy()
1646         {
1647                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1648                 // api_statuses_destroy('json');
1649         }
1650
1651         /**
1652          * Test the api_statuses_destroy() function without an authenticated user.
1653          *
1654          * @return void
1655          */
1656         public function testApiStatusesDestroyWithoutAuthenticatedUser()
1657         {
1658                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1659                 // BasicAuth::setCurrentUserID();
1660                 // $_SESSION['authenticated'] = false;
1661                 // api_statuses_destroy('json');
1662         }
1663
1664         /**
1665          * Test the api_statuses_destroy() function with an ID.
1666          *
1667          * @return void
1668          */
1669         public function testApiStatusesDestroyWithId()
1670         {
1671                 // DI::args()->setArgv(['', '', '', 1]);
1672                 // $result = api_statuses_destroy('json');
1673                 // self::assertStatus($result['status']);
1674         }
1675
1676         /**
1677          * Test the api_statuses_mentions() function.
1678          *
1679          * @return void
1680          */
1681         public function testApiStatusesMentions()
1682         {
1683                 /*
1684                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1685                 $_REQUEST['max_id'] = 10;
1686                 $result             = api_statuses_mentions('json');
1687                 self::assertEmpty($result['status']);
1688                 // We should test with mentions in the database.
1689                 */
1690         }
1691
1692         /**
1693          * Test the api_statuses_mentions() function with a negative page parameter.
1694          *
1695          * @return void
1696          */
1697         public function testApiStatusesMentionsWithNegativePage()
1698         {
1699                 // $_REQUEST['page'] = -2;
1700                 // $result           = api_statuses_mentions('json');
1701                 // self::assertEmpty($result['status']);
1702         }
1703
1704         /**
1705          * Test the api_statuses_mentions() function with an unallowed user.
1706          *
1707          * @return void
1708          */
1709         public function testApiStatusesMentionsWithUnallowedUser()
1710         {
1711                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1712                 // BasicAuth::setCurrentUserID();
1713                 // api_statuses_mentions('json');
1714         }
1715
1716         /**
1717          * Test the api_statuses_mentions() function with an RSS result.
1718          *
1719          * @return void
1720          */
1721         public function testApiStatusesMentionsWithRss()
1722         {
1723                 // $result = api_statuses_mentions('rss');
1724                 // self::assertXml($result, 'statuses');
1725         }
1726
1727         /**
1728          * Test the api_statuses_user_timeline() function.
1729          *
1730          * @return void
1731          */
1732         public function testApiStatusesUserTimeline()
1733         {
1734         /*
1735                 $_REQUEST['user_id']         = 42;
1736                 $_REQUEST['max_id']          = 10;
1737                 $_REQUEST['exclude_replies'] = true;
1738                 $_REQUEST['conversation_id'] = 7;
1739
1740                 $result = api_statuses_user_timeline('json');
1741                 self::assertNotEmpty($result['status']);
1742                 foreach ($result['status'] as $status) {
1743                         self::assertStatus($status);
1744                 }
1745                 */
1746         }
1747
1748         /**
1749          * Test the api_statuses_user_timeline() function with a negative page parameter.
1750          *
1751          * @return void
1752          */
1753         public function testApiStatusesUserTimelineWithNegativePage()
1754         {
1755                 /*
1756                 $_REQUEST['user_id'] = 42;
1757                 $_REQUEST['page']    = -2;
1758
1759                 $result = api_statuses_user_timeline('json');
1760                 self::assertNotEmpty($result['status']);
1761                 foreach ($result['status'] as $status) {
1762                         self::assertStatus($status);
1763                 }
1764                 */
1765         }
1766
1767         /**
1768          * Test the api_statuses_user_timeline() function with an RSS result.
1769          *
1770          * @return void
1771          */
1772         public function testApiStatusesUserTimelineWithRss()
1773         {
1774                 // $result = api_statuses_user_timeline('rss');
1775                 // self::assertXml($result, 'statuses');
1776         }
1777
1778         /**
1779          * Test the api_statuses_user_timeline() function with an unallowed user.
1780          *
1781          * @return void
1782          */
1783         public function testApiStatusesUserTimelineWithUnallowedUser()
1784         {
1785                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1786                 // BasicAuth::setCurrentUserID();
1787                 // api_statuses_user_timeline('json');
1788         }
1789
1790         /**
1791          * Test the api_favorites_create_destroy() function.
1792          *
1793          * @return void
1794          */
1795         public function testApiFavoritesCreateDestroy()
1796         {
1797                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1798                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1799                 api_favorites_create_destroy('json');
1800         }
1801
1802         /**
1803          * Test the api_favorites_create_destroy() function with an invalid ID.
1804          *
1805          * @return void
1806          */
1807         public function testApiFavoritesCreateDestroyWithInvalidId()
1808         {
1809                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1810                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1811                 api_favorites_create_destroy('json');
1812         }
1813
1814         /**
1815          * Test the api_favorites_create_destroy() function with an invalid action.
1816          *
1817          * @return void
1818          */
1819         public function testApiFavoritesCreateDestroyWithInvalidAction()
1820         {
1821                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1822                 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1823                 $_REQUEST['id'] = 1;
1824                 api_favorites_create_destroy('json');
1825         }
1826
1827         /**
1828          * Test the api_favorites_create_destroy() function with the create action.
1829          *
1830          * @return void
1831          */
1832         public function testApiFavoritesCreateDestroyWithCreateAction()
1833         {
1834                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1835                 $_REQUEST['id'] = 3;
1836                 $result         = api_favorites_create_destroy('json');
1837                 self::assertStatus($result['status']);
1838         }
1839
1840         /**
1841          * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1842          *
1843          * @return void
1844          */
1845         public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1846         {
1847                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1848                 $_REQUEST['id'] = 3;
1849                 $result         = api_favorites_create_destroy('rss');
1850                 self::assertXml($result, 'status');
1851         }
1852
1853         /**
1854          * Test the api_favorites_create_destroy() function with the destroy action.
1855          *
1856          * @return void
1857          */
1858         public function testApiFavoritesCreateDestroyWithDestroyAction()
1859         {
1860                 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1861                 $_REQUEST['id'] = 3;
1862                 $result         = api_favorites_create_destroy('json');
1863                 self::assertStatus($result['status']);
1864         }
1865
1866         /**
1867          * Test the api_favorites_create_destroy() function without an authenticated user.
1868          *
1869          * @return void
1870          */
1871         public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1872         {
1873                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1874                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1875                 BasicAuth::setCurrentUserID();
1876                 $_SESSION['authenticated'] = false;
1877                 api_favorites_create_destroy('json');
1878         }
1879
1880         /**
1881          * Test the api_favorites() function.
1882          *
1883          * @return void
1884          */
1885         public function testApiFavorites()
1886         {
1887                 /*
1888                 $_REQUEST['page']   = -1;
1889                 $_REQUEST['max_id'] = 10;
1890                 $result             = api_favorites('json');
1891                 foreach ($result['status'] as $status) {
1892                         self::assertStatus($status);
1893                 }
1894                 */
1895         }
1896
1897         /**
1898          * Test the api_favorites() function with an RSS result.
1899          *
1900          * @return void
1901          */
1902         public function testApiFavoritesWithRss()
1903         {
1904                 // $result = api_favorites('rss');
1905                 // self::assertXml($result, 'statuses');
1906         }
1907
1908         /**
1909          * Test the api_favorites() function with an unallowed user.
1910          *
1911          * @return void
1912          */
1913         public function testApiFavoritesWithUnallowedUser()
1914         {
1915                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1916                 // BasicAuth::setCurrentUserID();
1917                 // api_favorites('json');
1918         }
1919
1920         /**
1921          * Test the api_format_messages() function.
1922          *
1923          * @return void
1924          */
1925         public function testApiFormatMessages()
1926         {
1927                 $result = api_format_messages(
1928                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1929                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1930                         ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1931                 );
1932                 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1933                 self::assertEquals(1, $result['id']);
1934                 self::assertEquals(2, $result['recipient_id']);
1935                 self::assertEquals(3, $result['sender_id']);
1936                 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1937                 self::assertEquals('sender_name', $result['sender_screen_name']);
1938         }
1939
1940         /**
1941          * Test the api_format_messages() function with HTML.
1942          *
1943          * @return void
1944          */
1945         public function testApiFormatMessagesWithHtmlText()
1946         {
1947                 $_GET['getText'] = 'html';
1948                 $result          = api_format_messages(
1949                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1950                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1951                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1952                 );
1953                 self::assertEquals('item_title', $result['title']);
1954                 self::assertEquals('<strong>item_body</strong>', $result['text']);
1955         }
1956
1957         /**
1958          * Test the api_format_messages() function with plain text.
1959          *
1960          * @return void
1961          */
1962         public function testApiFormatMessagesWithPlainText()
1963         {
1964                 $_GET['getText'] = 'plain';
1965                 $result          = api_format_messages(
1966                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1967                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1968                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1969                 );
1970                 self::assertEquals('item_title', $result['title']);
1971                 self::assertEquals('item_body', $result['text']);
1972         }
1973
1974         /**
1975          * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1976          *
1977          * @return void
1978          */
1979         public function testApiFormatMessagesWithoutUserObjects()
1980         {
1981                 $_GET['getUserObjects'] = 'false';
1982                 $result                 = api_format_messages(
1983                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1984                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1985                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1986                 );
1987                 self::assertTrue(!isset($result['sender']));
1988                 self::assertTrue(!isset($result['recipient']));
1989         }
1990
1991         /**
1992          * Test the api_convert_item() function.
1993          *
1994          * @return void
1995          */
1996         public function testApiConvertItem()
1997         {
1998                 /*
1999                 $result = api_convert_item(
2000                         [
2001                                 'network' => 'feed',
2002                                 'title'   => 'item_title',
2003                                 'uri-id'  => 1,
2004                                 // We need a long string to test that it is correctly cut
2005                                 'body'    => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2006                                                          'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2007                                                          'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2008                                                          'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2009                                                          'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2010                                                          'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2011                                                          'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2012                                                          'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2013                                                          'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2014                                                          'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2015                                                          'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2016                                                          'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2017                                                          'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2018                                                          'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2019                                                          'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2020                                                          'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2021                                                          'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2022                                                          'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2023                                                          'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2024                                                          'repellat officia illum quos impedit quam iste esse unde qui ' .
2025                                                          'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2026                                                          'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2027                                                          'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2028                                 'plink'   => 'item_plink'
2029                         ]
2030                 );
2031                 self::assertStringStartsWith('item_title', $result['text']);
2032                 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2033                 */
2034         }
2035
2036         /**
2037          * Test the api_convert_item() function with an empty item body.
2038          *
2039          * @return void
2040          */
2041         public function testApiConvertItemWithoutBody()
2042         {
2043                 /*
2044                 $result = api_convert_item(
2045                         [
2046                                 'network' => 'feed',
2047                                 'title'   => 'item_title',
2048                                 'uri-id'  => -1,
2049                                 'body'    => '',
2050                                 'plink'   => 'item_plink'
2051                         ]
2052                 );
2053                 self::assertEquals("item_title", $result['text']);
2054                 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2055                 */
2056         }
2057
2058         /**
2059          * Test the api_convert_item() function with the title in the body.
2060          *
2061          * @return void
2062          */
2063         public function testApiConvertItemWithTitleInBody()
2064         {
2065                 /*
2066                 $result = api_convert_item(
2067                         [
2068                                 'title'  => 'item_title',
2069                                 'body'   => 'item_title item_body',
2070                                 'uri-id' => 1,
2071                         ]
2072                 );
2073                 self::assertEquals('item_title item_body', $result['text']);
2074                 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2075                 */
2076         }
2077
2078         /**
2079          * Test the api_get_attachments() function.
2080          *
2081          * @return void
2082          */
2083         public function testApiGetAttachments()
2084         {
2085                 // $body = 'body';
2086                 // self::assertEmpty(api_get_attachments($body, 0));
2087         }
2088
2089         /**
2090          * Test the api_get_attachments() function with an img tag.
2091          *
2092          * @return void
2093          */
2094         public function testApiGetAttachmentsWithImage()
2095         {
2096                 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2097                 // self::assertIsArray(api_get_attachments($body, 0));
2098         }
2099
2100         /**
2101          * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2102          *
2103          * @return void
2104          */
2105         public function testApiGetAttachmentsWithImageAndAndStatus()
2106         {
2107                 // $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2108                 // $body                       = '[img]http://via.placeholder.com/1x1.png[/img]';
2109                 // self::assertIsArray(api_get_attachments($body, 0));
2110         }
2111
2112         /**
2113          * Test the api_get_entitities() function.
2114          *
2115          * @return void
2116          */
2117         public function testApiGetEntitities()
2118         {
2119                 // $text = 'text';
2120                 // self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2121         }
2122
2123         /**
2124          * Test the api_get_entitities() function with the include_entities parameter.
2125          *
2126          * @return void
2127          */
2128         public function testApiGetEntititiesWithIncludeEntities()
2129         {
2130                 /*
2131                 $_REQUEST['include_entities'] = 'true';
2132                 $text                         = 'text';
2133                 $result                       = api_get_entitities($text, 'bbcode', 0);
2134                 self::assertIsArray($result['hashtags']);
2135                 self::assertIsArray($result['symbols']);
2136                 self::assertIsArray($result['urls']);
2137                 self::assertIsArray($result['user_mentions']);
2138                 */
2139         }
2140
2141         /**
2142          * Test the api_format_items_embeded_images() function.
2143          *
2144          * @return void
2145          */
2146         public function testApiFormatItemsEmbededImages()
2147         {
2148                 /*
2149                 self::assertEquals(
2150                         'text ' . DI::baseUrl() . '/display/item_guid',
2151                         api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2152                 );
2153                 */
2154         }
2155
2156         /**
2157          * Test the api_format_items_activities() function.
2158          *
2159          * @return void
2160          */
2161         public function testApiFormatItemsActivities()
2162         {
2163                 $item   = ['uid' => 0, 'uri-id' => 1];
2164                 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid']);
2165                 self::assertArrayHasKey('like', $result);
2166                 self::assertArrayHasKey('dislike', $result);
2167                 self::assertArrayHasKey('attendyes', $result);
2168                 self::assertArrayHasKey('attendno', $result);
2169                 self::assertArrayHasKey('attendmaybe', $result);
2170         }
2171
2172         /**
2173          * Test the api_format_items_activities() function with an XML result.
2174          *
2175          * @return void
2176          */
2177         public function testApiFormatItemsActivitiesWithXml()
2178         {
2179                 $item   = ['uid' => 0, 'uri-id' => 1];
2180                 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid'], 'xml');
2181                 self::assertArrayHasKey('friendica:like', $result);
2182                 self::assertArrayHasKey('friendica:dislike', $result);
2183                 self::assertArrayHasKey('friendica:attendyes', $result);
2184                 self::assertArrayHasKey('friendica:attendno', $result);
2185                 self::assertArrayHasKey('friendica:attendmaybe', $result);
2186         }
2187
2188         /**
2189          * Test the api_format_items() function.
2190          * @doesNotPerformAssertions
2191          */
2192         public function testApiFormatItems()
2193         {
2194                 /*
2195                 $items = Post::selectToArray([], ['uid' => 42]);
2196                 foreach ($items as $item) {
2197                         $status = api_format_item($item);
2198                         self::assertStatus($status);
2199                 }
2200                 */
2201         }
2202
2203         /**
2204          * Test the api_format_items() function with an XML result.
2205          * @doesNotPerformAssertions
2206          */
2207         public function testApiFormatItemsWithXml()
2208         {
2209                 /*
2210                 $items = Post::selectToArray([], ['uid' => 42]);
2211                 foreach ($items as $item) {
2212                         $status = api_format_item($item, 'xml');
2213                         self::assertStatus($status);
2214                 }
2215                 */
2216         }
2217
2218         /**
2219          * Test the api_lists_list() function.
2220          *
2221          * @return void
2222          */
2223         public function testApiListsList()
2224         {
2225                 $result = api_lists_list('json');
2226                 self::assertEquals(['lists_list' => []], $result);
2227         }
2228
2229         /**
2230          * Test the api_lists_ownerships() function.
2231          *
2232          * @return void
2233          */
2234         public function testApiListsOwnerships()
2235         {
2236                 $result = api_lists_ownerships('json');
2237                 foreach ($result['lists']['lists'] as $list) {
2238                         self::assertList($list);
2239                 }
2240         }
2241
2242         /**
2243          * Test the api_lists_ownerships() function without an authenticated user.
2244          *
2245          * @return void
2246          */
2247         public function testApiListsOwnershipsWithoutAuthenticatedUser()
2248         {
2249                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2250                 BasicAuth::setCurrentUserID();
2251                 $_SESSION['authenticated'] = false;
2252                 api_lists_ownerships('json');
2253         }
2254
2255         /**
2256          * Test the api_lists_statuses() function.
2257          *
2258          * @return void
2259          */
2260         public function testApiListsStatuses()
2261         {
2262                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2263                 // api_lists_statuses('json');
2264         }
2265
2266         /**
2267          * Test the api_lists_statuses() function with a list ID.
2268          * @doesNotPerformAssertions
2269          */
2270         public function testApiListsStatusesWithListId()
2271         {
2272                 /*
2273                 $_REQUEST['list_id'] = 1;
2274                 $_REQUEST['page']    = -1;
2275                 $_REQUEST['max_id']  = 10;
2276                 $result              = api_lists_statuses('json');
2277                 foreach ($result['status'] as $status) {
2278                         self::assertStatus($status);
2279                 }
2280                 */
2281         }
2282
2283         /**
2284          * Test the api_lists_statuses() function with a list ID and a RSS result.
2285          *
2286          * @return void
2287          */
2288         public function testApiListsStatusesWithListIdAndRss()
2289         {
2290                 // $_REQUEST['list_id'] = 1;
2291                 // $result              = api_lists_statuses('rss');
2292                 // self::assertXml($result, 'statuses');
2293         }
2294
2295         /**
2296          * Test the api_lists_statuses() function with an unallowed user.
2297          *
2298          * @return void
2299          */
2300         public function testApiListsStatusesWithUnallowedUser()
2301         {
2302                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2303                 // BasicAuth::setCurrentUserID();
2304                 // api_lists_statuses('json');
2305         }
2306
2307         /**
2308          * Test the api_statuses_f() function.
2309          *
2310          * @return void
2311          */
2312         public function testApiStatusesFWithFriends()
2313         {
2314                 $_GET['page'] = -1;
2315                 $result       = api_statuses_f('friends');
2316                 self::assertArrayHasKey('user', $result);
2317         }
2318
2319         /**
2320          * Test the api_statuses_f() function.
2321          *
2322          * @return void
2323          */
2324         public function testApiStatusesFWithFollowers()
2325         {
2326                 $result = api_statuses_f('followers');
2327                 self::assertArrayHasKey('user', $result);
2328         }
2329
2330         /**
2331          * Test the api_statuses_f() function.
2332          *
2333          * @return void
2334          */
2335         public function testApiStatusesFWithBlocks()
2336         {
2337                 $result = api_statuses_f('blocks');
2338                 self::assertArrayHasKey('user', $result);
2339         }
2340
2341         /**
2342          * Test the api_statuses_f() function.
2343          *
2344          * @return void
2345          */
2346         public function testApiStatusesFWithIncoming()
2347         {
2348                 $result = api_statuses_f('incoming');
2349                 self::assertArrayHasKey('user', $result);
2350         }
2351
2352         /**
2353          * Test the api_statuses_f() function an undefined cursor GET variable.
2354          *
2355          * @return void
2356          */
2357         public function testApiStatusesFWithUndefinedCursor()
2358         {
2359                 $_GET['cursor'] = 'undefined';
2360                 self::assertFalse(api_statuses_f('friends'));
2361         }
2362
2363         /**
2364          * Test the api_statuses_friends() function.
2365          *
2366          * @return void
2367          */
2368         public function testApiStatusesFriends()
2369         {
2370                 $result = api_statuses_friends('json');
2371                 self::assertArrayHasKey('user', $result);
2372         }
2373
2374         /**
2375          * Test the api_statuses_friends() function an undefined cursor GET variable.
2376          *
2377          * @return void
2378          */
2379         public function testApiStatusesFriendsWithUndefinedCursor()
2380         {
2381                 $_GET['cursor'] = 'undefined';
2382                 self::assertFalse(api_statuses_friends('json'));
2383         }
2384
2385         /**
2386          * Test the api_statuses_followers() function.
2387          *
2388          * @return void
2389          */
2390         public function testApiStatusesFollowers()
2391         {
2392                 $result = api_statuses_followers('json');
2393                 self::assertArrayHasKey('user', $result);
2394         }
2395
2396         /**
2397          * Test the api_statuses_followers() function an undefined cursor GET variable.
2398          *
2399          * @return void
2400          */
2401         public function testApiStatusesFollowersWithUndefinedCursor()
2402         {
2403                 $_GET['cursor'] = 'undefined';
2404                 self::assertFalse(api_statuses_followers('json'));
2405         }
2406
2407         /**
2408          * Test the api_blocks_list() function.
2409          *
2410          * @return void
2411          */
2412         public function testApiBlocksList()
2413         {
2414                 $result = api_blocks_list('json');
2415                 self::assertArrayHasKey('user', $result);
2416         }
2417
2418         /**
2419          * Test the api_blocks_list() function an undefined cursor GET variable.
2420          *
2421          * @return void
2422          */
2423         public function testApiBlocksListWithUndefinedCursor()
2424         {
2425                 $_GET['cursor'] = 'undefined';
2426                 self::assertFalse(api_blocks_list('json'));
2427         }
2428
2429         /**
2430          * Test the api_friendships_incoming() function.
2431          *
2432          * @return void
2433          */
2434         public function testApiFriendshipsIncoming()
2435         {
2436                 $result = api_friendships_incoming('json');
2437                 self::assertArrayHasKey('id', $result);
2438         }
2439
2440         /**
2441          * Test the api_friendships_incoming() function an undefined cursor GET variable.
2442          *
2443          * @return void
2444          */
2445         public function testApiFriendshipsIncomingWithUndefinedCursor()
2446         {
2447                 $_GET['cursor'] = 'undefined';
2448                 self::assertFalse(api_friendships_incoming('json'));
2449         }
2450
2451         /**
2452          * Test the api_statusnet_config() function.
2453          *
2454          * @return void
2455          */
2456         public function testApiStatusnetConfig()
2457         {
2458                 /*
2459                 $result = api_statusnet_config('json');
2460                 self::assertEquals('localhost', $result['config']['site']['server']);
2461                 self::assertEquals('default', $result['config']['site']['theme']);
2462                 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2463                 self::assertTrue($result['config']['site']['fancy']);
2464                 self::assertEquals('en', $result['config']['site']['language']);
2465                 self::assertEquals('UTC', $result['config']['site']['timezone']);
2466                 self::assertEquals(200000, $result['config']['site']['textlimit']);
2467                 self::assertEquals('false', $result['config']['site']['private']);
2468                 self::assertEquals('false', $result['config']['site']['ssl']);
2469                 self::assertEquals(30, $result['config']['site']['shorturllength']);
2470                 */
2471         }
2472
2473         /**
2474          * Test the api_direct_messages_new() function.
2475          *
2476          * @return void
2477          */
2478         public function testApiDirectMessagesNew()
2479         {
2480                 $result = api_direct_messages_new('json');
2481                 self::assertNull($result);
2482         }
2483
2484         /**
2485          * Test the api_direct_messages_new() function without an authenticated user.
2486          *
2487          * @return void
2488          */
2489         public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2490         {
2491                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2492                 BasicAuth::setCurrentUserID();
2493                 $_SESSION['authenticated'] = false;
2494                 api_direct_messages_new('json');
2495         }
2496
2497         /**
2498          * Test the api_direct_messages_new() function with an user ID.
2499          *
2500          * @return void
2501          */
2502         public function testApiDirectMessagesNewWithUserId()
2503         {
2504                 $_POST['text']    = 'message_text';
2505                 $_POST['user_id'] = $this->otherUser['id'];
2506                 $result           = api_direct_messages_new('json');
2507                 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2508         }
2509
2510         /**
2511          * Test the api_direct_messages_new() function with a screen name.
2512          *
2513          * @return void
2514          */
2515         public function testApiDirectMessagesNewWithScreenName()
2516         {
2517                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2518                 $_POST['text']    = 'message_text';
2519                 $_POST['user_id'] = $this->friendUser['id'];
2520                 $result           = api_direct_messages_new('json');
2521                 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2522                 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2523                 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2524         }
2525
2526         /**
2527          * Test the api_direct_messages_new() function with a title.
2528          *
2529          * @return void
2530          */
2531         public function testApiDirectMessagesNewWithTitle()
2532         {
2533                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2534                 $_POST['text']     = 'message_text';
2535                 $_POST['user_id']  = $this->friendUser['id'];
2536                 $_REQUEST['title'] = 'message_title';
2537                 $result            = api_direct_messages_new('json');
2538                 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2539                 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2540                 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2541                 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2542         }
2543
2544         /**
2545          * Test the api_direct_messages_new() function with an RSS result.
2546          *
2547          * @return void
2548          */
2549         public function testApiDirectMessagesNewWithRss()
2550         {
2551                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2552                 $_POST['text']    = 'message_text';
2553                 $_POST['user_id'] = $this->friendUser['id'];
2554                 $result           = api_direct_messages_new('rss');
2555                 self::assertXml($result, 'direct-messages');
2556         }
2557
2558         /**
2559          * Test the api_direct_messages_destroy() function.
2560          *
2561          * @return void
2562          */
2563         public function testApiDirectMessagesDestroy()
2564         {
2565                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2566                 api_direct_messages_destroy('json');
2567         }
2568
2569         /**
2570          * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2571          *
2572          * @return void
2573          */
2574         public function testApiDirectMessagesDestroyWithVerbose()
2575         {
2576                 $_GET['friendica_verbose'] = 'true';
2577                 $result                    = api_direct_messages_destroy('json');
2578                 self::assertEquals(
2579                         [
2580                                 '$result' => [
2581                                         'result'  => 'error',
2582                                         'message' => 'message id or parenturi not specified'
2583                                 ]
2584                         ],
2585                         $result
2586                 );
2587         }
2588
2589         /**
2590          * Test the api_direct_messages_destroy() function without an authenticated user.
2591          *
2592          * @return void
2593          */
2594         public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2595         {
2596                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2597                 BasicAuth::setCurrentUserID();
2598                 $_SESSION['authenticated'] = false;
2599                 api_direct_messages_destroy('json');
2600         }
2601
2602         /**
2603          * Test the api_direct_messages_destroy() function with a non-zero ID.
2604          *
2605          * @return void
2606          */
2607         public function testApiDirectMessagesDestroyWithId()
2608         {
2609                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2610                 $_REQUEST['id'] = 1;
2611                 api_direct_messages_destroy('json');
2612         }
2613
2614         /**
2615          * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2616          *
2617          * @return void
2618          */
2619         public function testApiDirectMessagesDestroyWithIdAndVerbose()
2620         {
2621                 $_REQUEST['id']                  = 1;
2622                 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2623                 $_GET['friendica_verbose']       = 'true';
2624                 $result                          = api_direct_messages_destroy('json');
2625                 self::assertEquals(
2626                         [
2627                                 '$result' => [
2628                                         'result'  => 'error',
2629                                         'message' => 'message id not in database'
2630                                 ]
2631                         ],
2632                         $result
2633                 );
2634         }
2635
2636         /**
2637          * Test the api_direct_messages_destroy() function with a non-zero ID.
2638          *
2639          * @return void
2640          */
2641         public function testApiDirectMessagesDestroyWithCorrectId()
2642         {
2643                 $this->markTestIncomplete('We need to add a dataset for this.');
2644         }
2645
2646         /**
2647          * Test the api_direct_messages_box() function.
2648          *
2649          * @return void
2650          */
2651         public function testApiDirectMessagesBoxWithSentbox()
2652         {
2653                 $_REQUEST['page']   = -1;
2654                 $_REQUEST['max_id'] = 10;
2655                 $result             = api_direct_messages_box('json', 'sentbox', 'false');
2656                 self::assertArrayHasKey('direct_message', $result);
2657         }
2658
2659         /**
2660          * Test the api_direct_messages_box() function.
2661          *
2662          * @return void
2663          */
2664         public function testApiDirectMessagesBoxWithConversation()
2665         {
2666                 $result = api_direct_messages_box('json', 'conversation', 'false');
2667                 self::assertArrayHasKey('direct_message', $result);
2668         }
2669
2670         /**
2671          * Test the api_direct_messages_box() function.
2672          *
2673          * @return void
2674          */
2675         public function testApiDirectMessagesBoxWithAll()
2676         {
2677                 $result = api_direct_messages_box('json', 'all', 'false');
2678                 self::assertArrayHasKey('direct_message', $result);
2679         }
2680
2681         /**
2682          * Test the api_direct_messages_box() function.
2683          *
2684          * @return void
2685          */
2686         public function testApiDirectMessagesBoxWithInbox()
2687         {
2688                 $result = api_direct_messages_box('json', 'inbox', 'false');
2689                 self::assertArrayHasKey('direct_message', $result);
2690         }
2691
2692         /**
2693          * Test the api_direct_messages_box() function.
2694          *
2695          * @return void
2696          */
2697         public function testApiDirectMessagesBoxWithVerbose()
2698         {
2699                 $result = api_direct_messages_box('json', 'sentbox', 'true');
2700                 self::assertEquals(
2701                         [
2702                                 '$result' => [
2703                                         'result'  => 'error',
2704                                         'message' => 'no mails available'
2705                                 ]
2706                         ],
2707                         $result
2708                 );
2709         }
2710
2711         /**
2712          * Test the api_direct_messages_box() function with a RSS result.
2713          *
2714          * @return void
2715          */
2716         public function testApiDirectMessagesBoxWithRss()
2717         {
2718                 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2719                 self::assertXml($result, 'direct-messages');
2720         }
2721
2722         /**
2723          * Test the api_direct_messages_box() function without an authenticated user.
2724          *
2725          * @return void
2726          */
2727         public function testApiDirectMessagesBoxWithUnallowedUser()
2728         {
2729                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2730                 BasicAuth::setCurrentUserID();
2731                 api_direct_messages_box('json', 'sentbox', 'false');
2732         }
2733
2734         /**
2735          * Test the api_direct_messages_sentbox() function.
2736          *
2737          * @return void
2738          */
2739         public function testApiDirectMessagesSentbox()
2740         {
2741                 $result = api_direct_messages_sentbox('json');
2742                 self::assertArrayHasKey('direct_message', $result);
2743         }
2744
2745         /**
2746          * Test the api_direct_messages_inbox() function.
2747          *
2748          * @return void
2749          */
2750         public function testApiDirectMessagesInbox()
2751         {
2752                 $result = api_direct_messages_inbox('json');
2753                 self::assertArrayHasKey('direct_message', $result);
2754         }
2755
2756         /**
2757          * Test the api_direct_messages_all() function.
2758          *
2759          * @return void
2760          */
2761         public function testApiDirectMessagesAll()
2762         {
2763                 $result = api_direct_messages_all('json');
2764                 self::assertArrayHasKey('direct_message', $result);
2765         }
2766
2767         /**
2768          * Test the api_direct_messages_conversation() function.
2769          *
2770          * @return void
2771          */
2772         public function testApiDirectMessagesConversation()
2773         {
2774                 $result = api_direct_messages_conversation('json');
2775                 self::assertArrayHasKey('direct_message', $result);
2776         }
2777
2778         /**
2779          * Test the api_oauth_request_token() function.
2780          *
2781          * @return void
2782          */
2783         public function testApiOauthRequestToken()
2784         {
2785                 $this->markTestIncomplete('exit() kills phpunit as well');
2786         }
2787
2788         /**
2789          * Test the api_oauth_access_token() function.
2790          *
2791          * @return void
2792          */
2793         public function testApiOauthAccessToken()
2794         {
2795                 $this->markTestIncomplete('exit() kills phpunit as well');
2796         }
2797
2798         /**
2799          * Test the api_fr_photos_list() function.
2800          *
2801          * @return void
2802          */
2803         public function testApiFrPhotosList()
2804         {
2805                 $result = api_fr_photos_list('json');
2806                 self::assertArrayHasKey('photo', $result);
2807         }
2808
2809         /**
2810          * Test the api_fr_photos_list() function without an authenticated user.
2811          *
2812          * @return void
2813          */
2814         public function testApiFrPhotosListWithoutAuthenticatedUser()
2815         {
2816                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2817                 BasicAuth::setCurrentUserID();
2818                 $_SESSION['authenticated'] = false;
2819                 api_fr_photos_list('json');
2820         }
2821
2822         /**
2823          * Test the api_fr_photo_create_update() function.
2824          */
2825         public function testApiFrPhotoCreateUpdate()
2826         {
2827                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2828                 api_fr_photo_create_update('json');
2829         }
2830
2831         /**
2832          * Test the api_fr_photo_create_update() function without an authenticated user.
2833          *
2834          * @return void
2835          */
2836         public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2837         {
2838                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2839                 BasicAuth::setCurrentUserID();
2840                 $_SESSION['authenticated'] = false;
2841                 api_fr_photo_create_update('json');
2842         }
2843
2844         /**
2845          * Test the api_fr_photo_create_update() function with an album name.
2846          *
2847          * @return void
2848          */
2849         public function testApiFrPhotoCreateUpdateWithAlbum()
2850         {
2851                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2852                 $_REQUEST['album'] = 'album_name';
2853                 api_fr_photo_create_update('json');
2854         }
2855
2856         /**
2857          * Test the api_fr_photo_create_update() function with the update mode.
2858          *
2859          * @return void
2860          */
2861         public function testApiFrPhotoCreateUpdateWithUpdate()
2862         {
2863                 $this->markTestIncomplete('We need to create a dataset for this');
2864         }
2865
2866         /**
2867          * Test the api_fr_photo_create_update() function with an uploaded file.
2868          *
2869          * @return void
2870          */
2871         public function testApiFrPhotoCreateUpdateWithFile()
2872         {
2873                 $this->markTestIncomplete();
2874         }
2875
2876         /**
2877          * Test the api_fr_photo_detail() function.
2878          *
2879          * @return void
2880          */
2881         public function testApiFrPhotoDetail()
2882         {
2883                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2884                 api_fr_photo_detail('json');
2885         }
2886
2887         /**
2888          * Test the api_fr_photo_detail() function without an authenticated user.
2889          *
2890          * @return void
2891          */
2892         public function testApiFrPhotoDetailWithoutAuthenticatedUser()
2893         {
2894                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2895                 BasicAuth::setCurrentUserID();
2896                 $_SESSION['authenticated'] = false;
2897                 api_fr_photo_detail('json');
2898         }
2899
2900         /**
2901          * Test the api_fr_photo_detail() function with a photo ID.
2902          *
2903          * @return void
2904          */
2905         public function testApiFrPhotoDetailWithPhotoId()
2906         {
2907                 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
2908                 $_REQUEST['photo_id'] = 1;
2909                 api_fr_photo_detail('json');
2910         }
2911
2912         /**
2913          * Test the api_fr_photo_detail() function with a correct photo ID.
2914          *
2915          * @return void
2916          */
2917         public function testApiFrPhotoDetailCorrectPhotoId()
2918         {
2919                 $this->markTestIncomplete('We need to create a dataset for this.');
2920         }
2921
2922         /**
2923          * Test the api_account_update_profile_image() function.
2924          *
2925          * @return void
2926          */
2927         public function testApiAccountUpdateProfileImage()
2928         {
2929                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2930                 api_account_update_profile_image('json');
2931         }
2932
2933         /**
2934          * Test the api_account_update_profile_image() function without an authenticated user.
2935          *
2936          * @return void
2937          */
2938         public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
2939         {
2940                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2941                 BasicAuth::setCurrentUserID();
2942                 $_SESSION['authenticated'] = false;
2943                 api_account_update_profile_image('json');
2944         }
2945
2946         /**
2947          * Test the api_account_update_profile_image() function with an uploaded file.
2948          *
2949          * @return void
2950          */
2951         public function testApiAccountUpdateProfileImageWithUpload()
2952         {
2953                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2954                 $this->markTestIncomplete();
2955         }
2956
2957
2958         /**
2959          * Test the api_account_update_profile() function.
2960          *
2961          * @return void
2962          */
2963         public function testApiAccountUpdateProfile()
2964         {
2965                 /*
2966                 $_POST['name']        = 'new_name';
2967                 $_POST['description'] = 'new_description';
2968                 $result               = api_account_update_profile('json');
2969                 // We can't use assertSelfUser() here because the user object is missing some properties.
2970                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
2971                 self::assertEquals('DFRN', $result['user']['location']);
2972                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
2973                 self::assertEquals('new_name', $result['user']['name']);
2974                 self::assertEquals('new_description', $result['user']['description']);
2975                 */
2976         }
2977
2978         /**
2979          * Test the check_acl_input() function.
2980          *
2981          * @return void
2982          */
2983         public function testCheckAclInput()
2984         {
2985                 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
2986                 // Where does this result come from?
2987                 self::assertEquals(1, $result);
2988         }
2989
2990         /**
2991          * Test the check_acl_input() function with an empty ACL string.
2992          *
2993          * @return void
2994          */
2995         public function testCheckAclInputWithEmptyAclString()
2996         {
2997                 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
2998                 self::assertFalse($result);
2999         }
3000
3001         /**
3002          * Test the save_media_to_database() function.
3003          *
3004          * @return void
3005          */
3006         public function testSaveMediaToDatabase()
3007         {
3008                 $this->markTestIncomplete();
3009         }
3010
3011         /**
3012          * Test the post_photo_item() function.
3013          *
3014          * @return void
3015          */
3016         public function testPostPhotoItem()
3017         {
3018                 $this->markTestIncomplete();
3019         }
3020
3021         /**
3022          * Test the prepare_photo_data() function.
3023          *
3024          * @return void
3025          */
3026         public function testPreparePhotoData()
3027         {
3028                 $this->markTestIncomplete();
3029         }
3030
3031         /**
3032          * Test the api_share_as_retweet() function with a valid item.
3033          *
3034          * @return void
3035          */
3036         public function testApiShareAsRetweetWithValidItem()
3037         {
3038                 $this->markTestIncomplete();
3039         }
3040
3041         /**
3042          * Test the api_in_reply_to() function with a valid item.
3043          *
3044          * @return void
3045          */
3046         public function testApiInReplyToWithValidItem()
3047         {
3048                 $this->markTestIncomplete();
3049         }
3050
3051         /**
3052          * Test the api_clean_plain_items() function.
3053          *
3054          * @return void
3055          */
3056         public function testApiCleanPlainItems()
3057         {
3058                 $_REQUEST['include_entities'] = 'true';
3059                 $result                       = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3060                 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3061         }
3062
3063         /**
3064          * Test the api_best_nickname() function with contacts.
3065          *
3066          * @return void
3067          */
3068         public function testApiBestNicknameWithContacts()
3069         {
3070                 $this->markTestIncomplete();
3071         }
3072
3073         /**
3074          * Test the api_friendica_group_show() function.
3075          *
3076          * @return void
3077          */
3078         public function testApiFriendicaGroupShow()
3079         {
3080                 $this->markTestIncomplete();
3081         }
3082
3083         /**
3084          * Test the api_friendica_group_delete() function.
3085          *
3086          * @return void
3087          */
3088         public function testApiFriendicaGroupDelete()
3089         {
3090                 $this->markTestIncomplete();
3091         }
3092
3093         /**
3094          * Test the api_lists_destroy() function.
3095          *
3096          * @return void
3097          */
3098         public function testApiListsDestroy()
3099         {
3100                 $this->markTestIncomplete();
3101         }
3102
3103         /**
3104          * Test the group_create() function.
3105          *
3106          * @return void
3107          */
3108         public function testGroupCreate()
3109         {
3110                 $this->markTestIncomplete();
3111         }
3112
3113         /**
3114          * Test the api_friendica_group_create() function.
3115          *
3116          * @return void
3117          */
3118         public function testApiFriendicaGroupCreate()
3119         {
3120                 $this->markTestIncomplete();
3121         }
3122
3123         /**
3124          * Test the api_lists_create() function.
3125          *
3126          * @return void
3127          */
3128         public function testApiListsCreate()
3129         {
3130                 $this->markTestIncomplete();
3131         }
3132
3133         /**
3134          * Test the api_friendica_group_update() function.
3135          *
3136          * @return void
3137          */
3138         public function testApiFriendicaGroupUpdate()
3139         {
3140                 $this->markTestIncomplete();
3141         }
3142
3143         /**
3144          * Test the api_lists_update() function.
3145          *
3146          * @return void
3147          */
3148         public function testApiListsUpdate()
3149         {
3150                 $this->markTestIncomplete();
3151         }
3152
3153         /**
3154          * Test the api_friendica_activity() function.
3155          *
3156          * @return void
3157          */
3158         public function testApiFriendicaActivity()
3159         {
3160                 $this->markTestIncomplete();
3161         }
3162
3163         /**
3164          * Test the api_friendica_notification_seen() function.
3165          *
3166          * @return void
3167          */
3168         public function testApiFriendicaNotificationSeen()
3169         {
3170                 $this->markTestIncomplete();
3171         }
3172
3173         /**
3174          * Test the api_friendica_direct_messages_setseen() function.
3175          *
3176          * @return void
3177          */
3178         public function testApiFriendicaDirectMessagesSetseen()
3179         {
3180                 $this->markTestIncomplete();
3181         }
3182
3183         /**
3184          * Test the api_friendica_direct_messages_search() function.
3185          *
3186          * @return void
3187          */
3188         public function testApiFriendicaDirectMessagesSearch()
3189         {
3190                 $this->markTestIncomplete();
3191         }
3192 }