]> git.mxchange.org Git - friendica.git/blob - tests/legacy/ApiTest.php
Partially fixing source detection
[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', BaseApi::getCurrentApplication()['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', BaseApi::getCurrentApplication()['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', BaseApi::getCurrentApplication()['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                 $args = DI::args()->determine($_SERVER, $_GET);
401
402                 self::assertEquals(
403                         'callback_name(["some_data"])',
404                         api_call($this->app, $args)
405                 );
406         }
407
408         /**
409          * Test the api_call() function with the profiled enabled.
410          *
411          * @runInSeparateProcess
412          * @preserveGlobalState disabled
413          */
414         public function testApiCallWithProfiler()
415         {
416                 global $API;
417                 $API['api_path']           = [
418                         'method' => 'method',
419                         'func'   => function () {
420                                 return ['data' => ['some_data']];
421                         }
422                 ];
423
424                 $_SERVER['REQUEST_METHOD'] = 'method';
425                 $_SERVER['QUERY_STRING'] = 'pagename=api_path';
426
427                 $args = DI::args()->determine($_SERVER, $_GET);
428
429                 $this->config->set('system', 'profiler', true);
430                 $this->config->set('rendertime', 'callstack', true);
431                 $this->app->callstack = [
432                         'database'       => ['some_function' => 200],
433                         'database_write' => ['some_function' => 200],
434                         'cache'          => ['some_function' => 200],
435                         'cache_write'    => ['some_function' => 200],
436                         'network'        => ['some_function' => 200]
437                 ];
438
439                 self::assertEquals(
440                         '["some_data"]',
441                         api_call($this->app, $args)
442                 );
443         }
444
445         /**
446          * Test the api_call() function with a JSON result.
447          *
448          * @runInSeparateProcess
449          * @preserveGlobalState disabled
450          */
451         public function testApiCallWithJson()
452         {
453                 global $API;
454                 $API['api_path']           = [
455                         'method' => 'method',
456                         'func'   => function () {
457                                 return ['data' => ['some_data']];
458                         }
459                 ];
460                 $_SERVER['REQUEST_METHOD'] = 'method';
461                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.json';
462
463                 $args = DI::args()->determine($_SERVER, $_GET);
464
465                 self::assertEquals(
466                         '["some_data"]',
467                         api_call($this->app, $args)
468                 );
469         }
470
471         /**
472          * Test the api_call() function with an XML result.
473          *
474          * @runInSeparateProcess
475          * @preserveGlobalState disabled
476          */
477         public function testApiCallWithXml()
478         {
479                 global $API;
480                 $API['api_path']           = [
481                         'method' => 'method',
482                         'func'   => function () {
483                                 return 'some_data';
484                         }
485                 ];
486                 $_SERVER['REQUEST_METHOD'] = 'method';
487                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.xml';
488
489                 $args = DI::args()->determine($_SERVER, $_GET);
490
491                 self::assertEquals(
492                         'some_data',
493                         api_call($this->app, $args)
494                 );
495         }
496
497         /**
498          * Test the api_call() function with an RSS result.
499          *
500          * @runInSeparateProcess
501          * @preserveGlobalState disabled
502          */
503         public function testApiCallWithRss()
504         {
505                 global $API;
506                 $API['api_path']           = [
507                         'method' => 'method',
508                         'func'   => function () {
509                                 return 'some_data';
510                         }
511                 ];
512                 $_SERVER['REQUEST_METHOD'] = 'method';
513                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.rss';
514
515                 $args = DI::args()->determine($_SERVER, $_GET);
516
517                 self::assertEquals(
518                         '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
519                         'some_data',
520                         api_call($this->app, $args)
521                 );
522         }
523
524         /**
525          * Test the api_call() function with an Atom result.
526          *
527          * @runInSeparateProcess
528          * @preserveGlobalState disabled
529          */
530         public function testApiCallWithAtom()
531         {
532                 global $API;
533                 $API['api_path']           = [
534                         'method' => 'method',
535                         'func'   => function () {
536                                 return 'some_data';
537                         }
538                 ];
539                 $_SERVER['REQUEST_METHOD'] = 'method';
540                 $_SERVER['QUERY_STRING'] = 'pagename=api_path.atom';
541
542                 $args = DI::args()->determine($_SERVER, $_GET);
543
544                 self::assertEquals(
545                         '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
546                         'some_data',
547                         api_call($this->app, $args)
548                 );
549         }
550
551         /**
552          * Test the api_rss_extra() function.
553          *
554          * @return void
555          */
556         public function testApiRssExtra()
557         {
558                 /*
559                 $user_info = ['url' => 'user_url', 'lang' => 'en'];
560                 $result    = api_rss_extra([], $user_info);
561                 self::assertEquals($user_info, $result['$user']);
562                 self::assertEquals($user_info['url'], $result['$rss']['alternate']);
563                 self::assertArrayHasKey('self', $result['$rss']);
564                 self::assertArrayHasKey('base', $result['$rss']);
565                 self::assertArrayHasKey('updated', $result['$rss']);
566                 self::assertArrayHasKey('atom_updated', $result['$rss']);
567                 self::assertArrayHasKey('language', $result['$rss']);
568                 self::assertArrayHasKey('logo', $result['$rss']);
569                 */
570         }
571
572         /**
573          * Test the api_rss_extra() function without any user info.
574          *
575          * @return void
576          */
577         public function testApiRssExtraWithoutUserInfo()
578         {
579                 /*
580                 $result = api_rss_extra([], null);
581                 self::assertIsArray($result['$user']);
582                 self::assertArrayHasKey('alternate', $result['$rss']);
583                 self::assertArrayHasKey('self', $result['$rss']);
584                 self::assertArrayHasKey('base', $result['$rss']);
585                 self::assertArrayHasKey('updated', $result['$rss']);
586                 self::assertArrayHasKey('atom_updated', $result['$rss']);
587                 self::assertArrayHasKey('language', $result['$rss']);
588                 self::assertArrayHasKey('logo', $result['$rss']);
589                 */
590         }
591
592         /**
593          * Test the api_get_user() function.
594          *
595          * @return void
596          */
597         public function testApiGetUser()
598         {
599                 // $user = api_get_user();
600                 // self::assertSelfUser($user);
601                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
602                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
603                 // self::assertEquals('ededed', $user['profile_background_color']);
604         }
605
606         /**
607          * Test the api_get_user() function with a Frio schema.
608          *
609          * @return void
610          */
611         public function testApiGetUserWithFrioSchema()
612         {
613                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
614                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
615                 // $user = api_get_user();
616                 // self::assertSelfUser($user);
617                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
618                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
619                 // self::assertEquals('ededed', $user['profile_background_color']);
620         }
621
622         /**
623          * Test the api_get_user() function with an empty Frio schema.
624          *
625          * @return void
626          */
627         public function testApiGetUserWithEmptyFrioSchema()
628         {
629                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
630                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
631                 // $user = api_get_user();
632                 // self::assertSelfUser($user);
633                 // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
634                 // self::assertEquals('6fdbe8', $user['profile_link_color']);
635                 // self::assertEquals('ededed', $user['profile_background_color']);
636         }
637
638         /**
639          * Test the api_get_user() function with a custom Frio schema.
640          *
641          * @return void
642          */
643         public function testApiGetUserWithCustomFrioSchema()
644         {
645                 // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
646                 // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
647                 // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
648                 // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
649                 // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
650                 // $user = api_get_user();
651                 // self::assertSelfUser($user);
652                 // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
653                 // self::assertEquals('123456', $user['profile_link_color']);
654                 // self::assertEquals('123456', $user['profile_background_color']);
655         }
656
657         /**
658          * Test the api_get_user() function with an user that is not allowed to use the API.
659          *
660          * @runInSeparateProcess
661          * @preserveGlobalState disabled
662          */
663         public function testApiGetUserWithoutApiUser()
664         {
665                 // api_get_user() with empty parameters is not used anymore
666                 /*
667                 $_SERVER['PHP_AUTH_USER'] = 'Test user';
668                 $_SERVER['PHP_AUTH_PW']   = 'password';
669                 BasicAuth::setCurrentUserID();
670                 self::assertFalse(api_get_user());
671                 */
672         }
673
674         /**
675          * Test the api_get_user() function with an user ID in a GET parameter.
676          *
677          * @return void
678          */
679         public function testApiGetUserWithGetId()
680         {
681                 // self::assertOtherUser(api_get_user());
682         }
683
684         /**
685          * Test the api_get_user() function with a wrong user ID in a GET parameter.
686          *
687          * @return void
688          */
689         public function testApiGetUserWithWrongGetId()
690         {
691                 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
692                 // self::assertOtherUser(api_get_user());
693         }
694
695         /**
696          * Test the api_get_user() function with an user name in a GET parameter.
697          *
698          * @return void
699          */
700         public function testApiGetUserWithGetName()
701         {
702                 // self::assertSelfUser(api_get_user());
703         }
704
705         /**
706          * Test the api_get_user() function with a profile URL in a GET parameter.
707          *
708          * @return void
709          */
710         public function testApiGetUserWithGetUrl()
711         {
712                 // self::assertSelfUser(api_get_user());
713         }
714
715         /**
716          * Test the api_get_user() function with an user ID in the API path.
717          *
718          * @return void
719          */
720         public function testApiGetUserWithNumericCalledApi()
721         {
722                 // global $called_api;
723                 // $called_api         = ['api_path'];
724                 // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
725                 // self::assertOtherUser(api_get_user());
726         }
727
728         /**
729          * Test the api_get_user() function with the $called_api global variable.
730          *
731          * @return void
732          */
733         public function testApiGetUserWithCalledApi()
734         {
735                 // global $called_api;
736                 // $called_api = ['api', 'api_path'];
737                 // self::assertSelfUser(api_get_user());
738         }
739
740         /**
741          * Test the Arrays::walkRecursive() function.
742          *
743          * @return void
744          */
745         public function testApiWalkRecursive()
746         {
747                 $array = ['item1'];
748                 self::assertEquals(
749                         $array,
750                         Arrays::walkRecursive(
751                                 $array,
752                                 function () {
753                                         // Should we test this with a callback that actually does something?
754                                         return true;
755                                 }
756                         )
757                 );
758         }
759
760         /**
761          * Test the Arrays::walkRecursive() function with an array.
762          *
763          * @return void
764          */
765         public function testApiWalkRecursiveWithArray()
766         {
767                 $array = [['item1'], ['item2']];
768                 self::assertEquals(
769                         $array,
770                         Arrays::walkRecursive(
771                                 $array,
772                                 function () {
773                                         // Should we test this with a callback that actually does something?
774                                         return true;
775                                 }
776                         )
777                 );
778         }
779
780         /**
781          * Test the BaseApi::reformatXML() function.
782          *
783          * @return void
784          */
785         public function testApiReformatXml()
786         {
787                 $item = true;
788                 $key  = '';
789                 self::assertTrue(ApiResponse::reformatXML($item, $key));
790                 self::assertEquals('true', $item);
791         }
792
793         /**
794          * Test the BaseApi::reformatXML() function with a statusnet_api key.
795          *
796          * @return void
797          */
798         public function testApiReformatXmlWithStatusnetKey()
799         {
800                 $item = '';
801                 $key  = 'statusnet_api';
802                 self::assertTrue(ApiResponse::reformatXML($item, $key));
803                 self::assertEquals('statusnet:api', $key);
804         }
805
806         /**
807          * Test the BaseApi::reformatXML() function with a friendica_api key.
808          *
809          * @return void
810          */
811         public function testApiReformatXmlWithFriendicaKey()
812         {
813                 $item = '';
814                 $key  = 'friendica_api';
815                 self::assertTrue(ApiResponse::reformatXML($item, $key));
816                 self::assertEquals('friendica:api', $key);
817         }
818
819         /**
820          * Test the BaseApi::createXML() function.
821          *
822          * @return void
823          */
824         public function testApiCreateXml()
825         {
826                 self::assertEquals(
827                         '<?xml version="1.0"?>' . "\n" .
828                         '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
829                         'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
830                         'xmlns:georss="http://www.georss.org/georss">' . "\n" .
831                         '  <data>some_data</data>' . "\n" .
832                         '</root_element>' . "\n",
833                         DI::apiResponse()->createXML(['data' => ['some_data']], 'root_element')
834                 );
835         }
836
837         /**
838          * Test the BaseApi::createXML() function without any XML namespace.
839          *
840          * @return void
841          */
842         public function testApiCreateXmlWithoutNamespaces()
843         {
844                 self::assertEquals(
845                         '<?xml version="1.0"?>' . "\n" .
846                         '<ok>' . "\n" .
847                         '  <data>some_data</data>' . "\n" .
848                         '</ok>' . "\n",
849                         DI::apiResponse()->createXML(['data' => ['some_data']], 'ok')
850                 );
851         }
852
853         /**
854          * Test the BaseApi::formatData() function.
855          *
856          * @return void
857          */
858         public function testApiFormatData()
859         {
860                 $data = ['some_data'];
861                 self::assertEquals($data, DI::apiResponse()->formatData('root_element', 'json', $data));
862         }
863
864         /**
865          * Test the BaseApi::formatData() function with an XML result.
866          *
867          * @return void
868          */
869         public function testApiFormatDataWithXml()
870         {
871                 self::assertEquals(
872                         '<?xml version="1.0"?>' . "\n" .
873                         '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
874                         'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
875                         'xmlns:georss="http://www.georss.org/georss">' . "\n" .
876                         '  <data>some_data</data>' . "\n" .
877                         '</root_element>' . "\n",
878                         DI::apiResponse()->formatData('root_element', 'xml', ['data' => ['some_data']])
879                 );
880         }
881
882         /**
883          * Test the api_account_verify_credentials() function.
884          *
885          * @return void
886          */
887         public function testApiAccountVerifyCredentials()
888         {
889                 self::assertArrayHasKey('user', api_account_verify_credentials('json'));
890         }
891
892         /**
893          * Test the api_account_verify_credentials() function without an authenticated user.
894          *
895          * @return void
896          */
897         public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
898         {
899                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
900                 BasicAuth::setCurrentUserID();
901                 $_SESSION['authenticated'] = false;
902                 api_account_verify_credentials('json');
903         }
904
905         /**
906          * Test the requestdata() function.
907          *
908          * @return void
909          */
910         public function testRequestdata()
911         {
912                 self::assertNull(requestdata('variable_name'));
913         }
914
915         /**
916          * Test the requestdata() function with a POST parameter.
917          *
918          * @return void
919          */
920         public function testRequestdataWithPost()
921         {
922                 $_POST['variable_name'] = 'variable_value';
923                 self::assertEquals('variable_value', requestdata('variable_name'));
924         }
925
926         /**
927          * Test the requestdata() function with a GET parameter.
928          *
929          * @return void
930          */
931         public function testRequestdataWithGet()
932         {
933                 $_GET['variable_name'] = 'variable_value';
934                 self::assertEquals('variable_value', requestdata('variable_name'));
935         }
936
937         /**
938          * Test the api_statuses_mediap() function.
939          *
940          * @return void
941          */
942         public function testApiStatusesMediap()
943         {
944                 DI::args()->setArgc(2);
945
946                 $_FILES         = [
947                         'media' => [
948                                 'id'       => 666,
949                                 'size'     => 666,
950                                 'width'    => 666,
951                                 'height'   => 666,
952                                 'tmp_name' => $this->getTempImage(),
953                                 'name'     => 'spacer.png',
954                                 'type'     => 'image/png'
955                         ]
956                 ];
957                 $_GET['status'] = '<b>Status content</b>';
958
959                 $result = api_statuses_mediap('json');
960                 self::assertStatus($result['status']);
961         }
962
963         /**
964          * Test the api_statuses_mediap() function without an authenticated user.
965          *
966          * @return void
967          */
968         public function testApiStatusesMediapWithoutAuthenticatedUser()
969         {
970                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
971                 BasicAuth::setCurrentUserID();
972                 $_SESSION['authenticated'] = false;
973                 api_statuses_mediap('json');
974         }
975
976         /**
977          * Test the api_statuses_update() function.
978          *
979          * @return void
980          */
981         public function testApiStatusesUpdate()
982         {
983                 $_GET['status']                = 'Status content #friendica';
984                 $_GET['in_reply_to_status_id'] = -1;
985                 $_GET['lat']                   = 48;
986                 $_GET['long']                  = 7;
987                 $_FILES                        = [
988                         'media' => [
989                                 'id'       => 666,
990                                 'size'     => 666,
991                                 'width'    => 666,
992                                 'height'   => 666,
993                                 'tmp_name' => $this->getTempImage(),
994                                 'name'     => 'spacer.png',
995                                 'type'     => 'image/png'
996                         ]
997                 ];
998
999                 $result = api_statuses_update('json');
1000                 self::assertStatus($result['status']);
1001         }
1002
1003         /**
1004          * Test the api_statuses_update() function with an HTML status.
1005          *
1006          * @return void
1007          */
1008         public function testApiStatusesUpdateWithHtml()
1009         {
1010                 $_GET['htmlstatus'] = '<b>Status content</b>';
1011
1012                 $result = api_statuses_update('json');
1013                 self::assertStatus($result['status']);
1014         }
1015
1016         /**
1017          * Test the api_statuses_update() function without an authenticated user.
1018          *
1019          * @return void
1020          */
1021         public function testApiStatusesUpdateWithoutAuthenticatedUser()
1022         {
1023                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1024                 BasicAuth::setCurrentUserID();
1025                 $_SESSION['authenticated'] = false;
1026                 api_statuses_update('json');
1027         }
1028
1029         /**
1030          * Test the api_statuses_update() function with a parent status.
1031          *
1032          * @return void
1033          */
1034         public function testApiStatusesUpdateWithParent()
1035         {
1036                 $this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
1037         }
1038
1039         /**
1040          * Test the api_statuses_update() function with a media_ids parameter.
1041          *
1042          * @return void
1043          */
1044         public function testApiStatusesUpdateWithMediaIds()
1045         {
1046                 $this->markTestIncomplete();
1047         }
1048
1049         /**
1050          * Test the api_statuses_update() function with the throttle limit reached.
1051          *
1052          * @return void
1053          */
1054         public function testApiStatusesUpdateWithDayThrottleReached()
1055         {
1056                 $this->markTestIncomplete();
1057         }
1058
1059         /**
1060          * Test the api_media_upload() function.
1061          * @runInSeparateProcess
1062          * @preserveGlobalState disabled
1063          */
1064         public function testApiMediaUpload()
1065         {
1066                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1067                 api_media_upload();
1068         }
1069
1070         /**
1071          * Test the api_media_upload() function without an authenticated user.
1072          *
1073          * @return void
1074          */
1075         public function testApiMediaUploadWithoutAuthenticatedUser()
1076         {
1077                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1078                 BasicAuth::setCurrentUserID();
1079                 $_SESSION['authenticated'] = false;
1080                 api_media_upload();
1081         }
1082
1083         /**
1084          * Test the api_media_upload() function with an invalid uploaded media.
1085          *
1086          * @return void
1087          */
1088         public function testApiMediaUploadWithMedia()
1089         {
1090                 $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
1091                 $_FILES = [
1092                         'media' => [
1093                                 'id'       => 666,
1094                                 'tmp_name' => 'tmp_name'
1095                         ]
1096                 ];
1097                 api_media_upload();
1098         }
1099
1100         /**
1101          * Test the api_media_upload() function with an valid uploaded media.
1102          *
1103          * @return void
1104          */
1105         public function testApiMediaUploadWithValidMedia()
1106         {
1107                 $_FILES    = [
1108                         'media' => [
1109                                 'id'       => 666,
1110                                 'size'     => 666,
1111                                 'width'    => 666,
1112                                 'height'   => 666,
1113                                 'tmp_name' => $this->getTempImage(),
1114                                 'name'     => 'spacer.png',
1115                                 'type'     => 'image/png'
1116                         ]
1117                 ];
1118                 $app       = DI::app();
1119                 DI::args()->setArgc(2);
1120
1121                 $result = api_media_upload();
1122                 self::assertEquals('image/png', $result['media']['image']['image_type']);
1123                 self::assertEquals(1, $result['media']['image']['w']);
1124                 self::assertEquals(1, $result['media']['image']['h']);
1125                 self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
1126         }
1127
1128         /**
1129          * Test the api_status_show() function.
1130          */
1131         public function testApiStatusShowWithJson()
1132         {
1133                 // $result = api_status_show('json', 1);
1134                 // self::assertStatus($result['status']);
1135         }
1136
1137         /**
1138          * Test the api_status_show() function with an XML result.
1139          */
1140         public function testApiStatusShowWithXml()
1141         {
1142                 // $result = api_status_show('xml', 1);
1143                 // self::assertXml($result, 'statuses');
1144         }
1145
1146         /**
1147          * Test the api_get_last_status() function
1148          */
1149         public function testApiGetLastStatus()
1150         {
1151                 // $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
1152                 // self::assertNotNull($item);
1153         }
1154
1155         /**
1156          * Test the api_users_show() function.
1157          *
1158          * @return void
1159          */
1160         public function testApiUsersShow()
1161         {
1162                 $result = api_users_show('json');
1163                 // We can't use assertSelfUser() here because the user object is missing some properties.
1164                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1165                 self::assertEquals('DFRN', $result['user']['location']);
1166                 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1167                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1168                 self::assertTrue($result['user']['verified']);
1169         }
1170
1171         /**
1172          * Test the api_users_show() function with an XML result.
1173          *
1174          * @return void
1175          */
1176         public function testApiUsersShowWithXml()
1177         {
1178                 $result = api_users_show('xml');
1179                 self::assertXml($result, 'statuses');
1180         }
1181
1182         /**
1183          * Test the api_users_search() function.
1184          *
1185          * @return void
1186          */
1187         public function testApiUsersSearch()
1188         {
1189                 $_GET['q'] = 'othercontact';
1190                 $result    = api_users_search('json');
1191                 self::assertOtherUser($result['users'][0]);
1192         }
1193
1194         /**
1195          * Test the api_users_search() function with an XML result.
1196          *
1197          * @return void
1198          */
1199         public function testApiUsersSearchWithXml()
1200         {
1201                 $_GET['q'] = 'othercontact';
1202                 $result    = api_users_search('xml');
1203                 self::assertXml($result, 'users');
1204         }
1205
1206         /**
1207          * Test the api_users_search() function without a GET q parameter.
1208          *
1209          * @return void
1210          */
1211         public function testApiUsersSearchWithoutQuery()
1212         {
1213                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1214                 api_users_search('json');
1215         }
1216
1217         /**
1218          * Test the api_users_lookup() function.
1219          *
1220          * @return void
1221          */
1222         public function testApiUsersLookup()
1223         {
1224                 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1225                 api_users_lookup('json');
1226         }
1227
1228         /**
1229          * Test the api_users_lookup() function with an user ID.
1230          *
1231          * @return void
1232          */
1233         public function testApiUsersLookupWithUserId()
1234         {
1235                 $_REQUEST['user_id'] = $this->otherUser['id'];
1236                 $result              = api_users_lookup('json');
1237                 self::assertOtherUser($result['users'][0]);
1238         }
1239
1240         /**
1241          * Test the api_search() function.
1242          *
1243          * @return void
1244          */
1245         public function testApiSearch()
1246         {
1247                 $_REQUEST['q']      = 'reply';
1248                 $_REQUEST['max_id'] = 10;
1249                 $result             = api_search('json');
1250                 foreach ($result['status'] as $status) {
1251                         self::assertStatus($status);
1252                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1253                 }
1254         }
1255
1256         /**
1257          * Test the api_search() function a count parameter.
1258          *
1259          * @return void
1260          */
1261         public function testApiSearchWithCount()
1262         {
1263                 $_REQUEST['q']     = 'reply';
1264                 $_REQUEST['count'] = 20;
1265                 $result            = api_search('json');
1266                 foreach ($result['status'] as $status) {
1267                         self::assertStatus($status);
1268                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1269                 }
1270         }
1271
1272         /**
1273          * Test the api_search() function with an rpp parameter.
1274          *
1275          * @return void
1276          */
1277         public function testApiSearchWithRpp()
1278         {
1279                 $_REQUEST['q']   = 'reply';
1280                 $_REQUEST['rpp'] = 20;
1281                 $result          = api_search('json');
1282                 foreach ($result['status'] as $status) {
1283                         self::assertStatus($status);
1284                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1285                 }
1286         }
1287
1288         /**
1289          * Test the api_search() function with an q parameter contains hashtag.
1290          * @doesNotPerformAssertions
1291          */
1292         public function testApiSearchWithHashtag()
1293         {
1294                 $_REQUEST['q'] = '%23friendica';
1295                 $result        = api_search('json');
1296                 foreach ($result['status'] as $status) {
1297                         self::assertStatus($status);
1298                         self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1299                 }
1300         }
1301
1302         /**
1303          * Test the api_search() function with an exclude_replies parameter.
1304          * @doesNotPerformAssertions
1305          */
1306         public function testApiSearchWithExcludeReplies()
1307         {
1308                 $_REQUEST['max_id']          = 10;
1309                 $_REQUEST['exclude_replies'] = true;
1310                 $_REQUEST['q']               = 'friendica';
1311                 $result                      = api_search('json');
1312                 foreach ($result['status'] as $status) {
1313                         self::assertStatus($status);
1314                 }
1315         }
1316
1317         /**
1318          * Test the api_search() function without an authenticated user.
1319          *
1320          * @return void
1321          */
1322         public function testApiSearchWithUnallowedUser()
1323         {
1324                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1325                 BasicAuth::setCurrentUserID();
1326                 api_search('json');
1327         }
1328
1329         /**
1330          * Test the api_search() function without any GET query parameter.
1331          *
1332          * @return void
1333          */
1334         public function testApiSearchWithoutQuery()
1335         {
1336                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1337                 api_search('json');
1338         }
1339
1340         /**
1341          * Test the api_statuses_home_timeline() function.
1342          *
1343          * @return void
1344          */
1345         public function testApiStatusesHomeTimeline()
1346         {
1347                 $_REQUEST['max_id']          = 10;
1348                 $_REQUEST['exclude_replies'] = true;
1349                 $_REQUEST['conversation_id'] = 1;
1350                 $result                      = api_statuses_home_timeline('json');
1351                 self::assertNotEmpty($result['status']);
1352                 foreach ($result['status'] as $status) {
1353                         self::assertStatus($status);
1354                 }
1355         }
1356
1357         /**
1358          * Test the api_statuses_home_timeline() function with a negative page parameter.
1359          *
1360          * @return void
1361          */
1362         public function testApiStatusesHomeTimelineWithNegativePage()
1363         {
1364                 $_REQUEST['page'] = -2;
1365                 $result           = api_statuses_home_timeline('json');
1366                 self::assertNotEmpty($result['status']);
1367                 foreach ($result['status'] as $status) {
1368                         self::assertStatus($status);
1369                 }
1370         }
1371
1372         /**
1373          * Test the api_statuses_home_timeline() with an unallowed user.
1374          *
1375          * @return void
1376          */
1377         public function testApiStatusesHomeTimelineWithUnallowedUser()
1378         {
1379                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1380                 BasicAuth::setCurrentUserID();
1381                 api_statuses_home_timeline('json');
1382         }
1383
1384         /**
1385          * Test the api_statuses_home_timeline() function with an RSS result.
1386          *
1387          * @return void
1388          */
1389         public function testApiStatusesHomeTimelineWithRss()
1390         {
1391                 $result = api_statuses_home_timeline('rss');
1392                 self::assertXml($result, 'statuses');
1393         }
1394
1395         /**
1396          * Test the api_statuses_public_timeline() function.
1397          *
1398          * @return void
1399          */
1400         public function testApiStatusesPublicTimeline()
1401         {
1402                 $_REQUEST['max_id']          = 10;
1403                 $_REQUEST['conversation_id'] = 1;
1404                 $result                      = api_statuses_public_timeline('json');
1405                 self::assertNotEmpty($result['status']);
1406                 foreach ($result['status'] as $status) {
1407                         self::assertStatus($status);
1408                 }
1409         }
1410
1411         /**
1412          * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1413          *
1414          * @return void
1415          */
1416         public function testApiStatusesPublicTimelineWithExcludeReplies()
1417         {
1418                 $_REQUEST['max_id']          = 10;
1419                 $_REQUEST['exclude_replies'] = true;
1420                 $result                      = api_statuses_public_timeline('json');
1421                 self::assertNotEmpty($result['status']);
1422                 foreach ($result['status'] as $status) {
1423                         self::assertStatus($status);
1424                 }
1425         }
1426
1427         /**
1428          * Test the api_statuses_public_timeline() function with a negative page parameter.
1429          *
1430          * @return void
1431          */
1432         public function testApiStatusesPublicTimelineWithNegativePage()
1433         {
1434                 $_REQUEST['page'] = -2;
1435                 $result           = api_statuses_public_timeline('json');
1436                 self::assertNotEmpty($result['status']);
1437                 foreach ($result['status'] as $status) {
1438                         self::assertStatus($status);
1439                 }
1440         }
1441
1442         /**
1443          * Test the api_statuses_public_timeline() function with an unallowed user.
1444          *
1445          * @return void
1446          */
1447         public function testApiStatusesPublicTimelineWithUnallowedUser()
1448         {
1449                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1450                 BasicAuth::setCurrentUserID();
1451                 api_statuses_public_timeline('json');
1452         }
1453
1454         /**
1455          * Test the api_statuses_public_timeline() function with an RSS result.
1456          *
1457          * @return void
1458          */
1459         public function testApiStatusesPublicTimelineWithRss()
1460         {
1461                 $result = api_statuses_public_timeline('rss');
1462                 self::assertXml($result, 'statuses');
1463         }
1464
1465         /**
1466          * Test the api_statuses_networkpublic_timeline() function.
1467          *
1468          * @return void
1469          */
1470         public function testApiStatusesNetworkpublicTimeline()
1471         {
1472                 $_REQUEST['max_id'] = 10;
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          * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1482          *
1483          * @return void
1484          */
1485         public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1486         {
1487                 $_REQUEST['page'] = -2;
1488                 $result           = api_statuses_networkpublic_timeline('json');
1489                 self::assertNotEmpty($result['status']);
1490                 foreach ($result['status'] as $status) {
1491                         self::assertStatus($status);
1492                 }
1493         }
1494
1495         /**
1496          * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1497          *
1498          * @return void
1499          */
1500         public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1501         {
1502                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1503                 BasicAuth::setCurrentUserID();
1504                 api_statuses_networkpublic_timeline('json');
1505         }
1506
1507         /**
1508          * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1509          *
1510          * @return void
1511          */
1512         public function testApiStatusesNetworkpublicTimelineWithRss()
1513         {
1514                 $result = api_statuses_networkpublic_timeline('rss');
1515                 self::assertXml($result, 'statuses');
1516         }
1517
1518         /**
1519          * Test the api_statuses_show() function.
1520          *
1521          * @return void
1522          */
1523         public function testApiStatusesShow()
1524         {
1525                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1526                 api_statuses_show('json');
1527         }
1528
1529         /**
1530          * Test the api_statuses_show() function with an ID.
1531          *
1532          * @return void
1533          */
1534         public function testApiStatusesShowWithId()
1535         {
1536                 DI::args()->setArgv(['', '', '', 1]);
1537                 $result = api_statuses_show('json');
1538                 self::assertStatus($result['status']);
1539         }
1540
1541         /**
1542          * Test the api_statuses_show() function with the conversation parameter.
1543          *
1544          * @return void
1545          */
1546         public function testApiStatusesShowWithConversation()
1547         {
1548                 DI::args()->setArgv(['', '', '', 1]);
1549                 $_REQUEST['conversation'] = 1;
1550                 $result                   = api_statuses_show('json');
1551                 self::assertNotEmpty($result['status']);
1552                 foreach ($result['status'] as $status) {
1553                         self::assertStatus($status);
1554                 }
1555         }
1556
1557         /**
1558          * Test the api_statuses_show() function with an unallowed user.
1559          *
1560          * @return void
1561          */
1562         public function testApiStatusesShowWithUnallowedUser()
1563         {
1564                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1565                 BasicAuth::setCurrentUserID();
1566                 api_statuses_show('json');
1567         }
1568
1569         /**
1570          * Test the api_conversation_show() function.
1571          *
1572          * @return void
1573          */
1574         public function testApiConversationShow()
1575         {
1576                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1577                 api_conversation_show('json');
1578         }
1579
1580         /**
1581          * Test the api_conversation_show() function with an ID.
1582          *
1583          * @return void
1584          */
1585         public function testApiConversationShowWithId()
1586         {
1587                 DI::args()->setArgv(['', '', '', 1]);
1588                 $_REQUEST['max_id'] = 10;
1589                 $_REQUEST['page']   = -2;
1590                 $result             = api_conversation_show('json');
1591                 self::assertNotEmpty($result['status']);
1592                 foreach ($result['status'] as $status) {
1593                         self::assertStatus($status);
1594                 }
1595         }
1596
1597         /**
1598          * Test the api_conversation_show() function with an unallowed user.
1599          *
1600          * @return void
1601          */
1602         public function testApiConversationShowWithUnallowedUser()
1603         {
1604                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1605                 BasicAuth::setCurrentUserID();
1606                 api_conversation_show('json');
1607         }
1608
1609         /**
1610          * Test the api_statuses_repeat() function.
1611          *
1612          * @return void
1613          */
1614         public function testApiStatusesRepeat()
1615         {
1616                 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1617                 api_statuses_repeat('json');
1618         }
1619
1620         /**
1621          * Test the api_statuses_repeat() function without an authenticated user.
1622          *
1623          * @return void
1624          */
1625         public function testApiStatusesRepeatWithoutAuthenticatedUser()
1626         {
1627                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1628                 BasicAuth::setCurrentUserID();
1629                 $_SESSION['authenticated'] = false;
1630                 api_statuses_repeat('json');
1631         }
1632
1633         /**
1634          * Test the api_statuses_repeat() function with an ID.
1635          *
1636          * @return void
1637          */
1638         public function testApiStatusesRepeatWithId()
1639         {
1640                 DI::args()->setArgv(['', '', '', 1]);
1641                 $result = api_statuses_repeat('json');
1642                 self::assertStatus($result['status']);
1643
1644                 // Also test with a shared status
1645                 DI::args()->setArgv(['', '', '', 5]);
1646                 $result = api_statuses_repeat('json');
1647                 self::assertStatus($result['status']);
1648         }
1649
1650         /**
1651          * Test the api_statuses_destroy() function.
1652          *
1653          * @return void
1654          */
1655         public function testApiStatusesDestroy()
1656         {
1657                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1658                 api_statuses_destroy('json');
1659         }
1660
1661         /**
1662          * Test the api_statuses_destroy() function without an authenticated user.
1663          *
1664          * @return void
1665          */
1666         public function testApiStatusesDestroyWithoutAuthenticatedUser()
1667         {
1668                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1669                 BasicAuth::setCurrentUserID();
1670                 $_SESSION['authenticated'] = false;
1671                 api_statuses_destroy('json');
1672         }
1673
1674         /**
1675          * Test the api_statuses_destroy() function with an ID.
1676          *
1677          * @return void
1678          */
1679         public function testApiStatusesDestroyWithId()
1680         {
1681                 DI::args()->setArgv(['', '', '', 1]);
1682                 $result = api_statuses_destroy('json');
1683                 self::assertStatus($result['status']);
1684         }
1685
1686         /**
1687          * Test the api_statuses_mentions() function.
1688          *
1689          * @return void
1690          */
1691         public function testApiStatusesMentions()
1692         {
1693                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1694                 $_REQUEST['max_id'] = 10;
1695                 $result             = api_statuses_mentions('json');
1696                 self::assertEmpty($result['status']);
1697                 // We should test with mentions in the database.
1698         }
1699
1700         /**
1701          * Test the api_statuses_mentions() function with a negative page parameter.
1702          *
1703          * @return void
1704          */
1705         public function testApiStatusesMentionsWithNegativePage()
1706         {
1707                 $_REQUEST['page'] = -2;
1708                 $result           = api_statuses_mentions('json');
1709                 self::assertEmpty($result['status']);
1710         }
1711
1712         /**
1713          * Test the api_statuses_mentions() function with an unallowed user.
1714          *
1715          * @return void
1716          */
1717         public function testApiStatusesMentionsWithUnallowedUser()
1718         {
1719                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1720                 BasicAuth::setCurrentUserID();
1721                 api_statuses_mentions('json');
1722         }
1723
1724         /**
1725          * Test the api_statuses_mentions() function with an RSS result.
1726          *
1727          * @return void
1728          */
1729         public function testApiStatusesMentionsWithRss()
1730         {
1731                 $result = api_statuses_mentions('rss');
1732                 self::assertXml($result, 'statuses');
1733         }
1734
1735         /**
1736          * Test the api_statuses_user_timeline() function.
1737          *
1738          * @return void
1739          */
1740         public function testApiStatusesUserTimeline()
1741         {
1742                 $_REQUEST['user_id']         = 42;
1743                 $_REQUEST['max_id']          = 10;
1744                 $_REQUEST['exclude_replies'] = true;
1745                 $_REQUEST['conversation_id'] = 7;
1746
1747                 $result = api_statuses_user_timeline('json');
1748                 self::assertNotEmpty($result['status']);
1749                 foreach ($result['status'] as $status) {
1750                         self::assertStatus($status);
1751                 }
1752         }
1753
1754         /**
1755          * Test the api_statuses_user_timeline() function with a negative page parameter.
1756          *
1757          * @return void
1758          */
1759         public function testApiStatusesUserTimelineWithNegativePage()
1760         {
1761                 $_REQUEST['user_id'] = 42;
1762                 $_REQUEST['page']    = -2;
1763
1764                 $result = api_statuses_user_timeline('json');
1765                 self::assertNotEmpty($result['status']);
1766                 foreach ($result['status'] as $status) {
1767                         self::assertStatus($status);
1768                 }
1769         }
1770
1771         /**
1772          * Test the api_statuses_user_timeline() function with an RSS result.
1773          *
1774          * @return void
1775          */
1776         public function testApiStatusesUserTimelineWithRss()
1777         {
1778                 $result = api_statuses_user_timeline('rss');
1779                 self::assertXml($result, 'statuses');
1780         }
1781
1782         /**
1783          * Test the api_statuses_user_timeline() function with an unallowed user.
1784          *
1785          * @return void
1786          */
1787         public function testApiStatusesUserTimelineWithUnallowedUser()
1788         {
1789                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1790                 BasicAuth::setCurrentUserID();
1791                 api_statuses_user_timeline('json');
1792         }
1793
1794         /**
1795          * Test the api_favorites_create_destroy() function.
1796          *
1797          * @return void
1798          */
1799         public function testApiFavoritesCreateDestroy()
1800         {
1801                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1802                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1803                 api_favorites_create_destroy('json');
1804         }
1805
1806         /**
1807          * Test the api_favorites_create_destroy() function with an invalid ID.
1808          *
1809          * @return void
1810          */
1811         public function testApiFavoritesCreateDestroyWithInvalidId()
1812         {
1813                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1814                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1815                 api_favorites_create_destroy('json');
1816         }
1817
1818         /**
1819          * Test the api_favorites_create_destroy() function with an invalid action.
1820          *
1821          * @return void
1822          */
1823         public function testApiFavoritesCreateDestroyWithInvalidAction()
1824         {
1825                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1826                 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1827                 $_REQUEST['id'] = 1;
1828                 api_favorites_create_destroy('json');
1829         }
1830
1831         /**
1832          * Test the api_favorites_create_destroy() function with the create action.
1833          *
1834          * @return void
1835          */
1836         public function testApiFavoritesCreateDestroyWithCreateAction()
1837         {
1838                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1839                 $_REQUEST['id'] = 3;
1840                 $result         = api_favorites_create_destroy('json');
1841                 self::assertStatus($result['status']);
1842         }
1843
1844         /**
1845          * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1846          *
1847          * @return void
1848          */
1849         public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1850         {
1851                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1852                 $_REQUEST['id'] = 3;
1853                 $result         = api_favorites_create_destroy('rss');
1854                 self::assertXml($result, 'status');
1855         }
1856
1857         /**
1858          * Test the api_favorites_create_destroy() function with the destroy action.
1859          *
1860          * @return void
1861          */
1862         public function testApiFavoritesCreateDestroyWithDestroyAction()
1863         {
1864                 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1865                 $_REQUEST['id'] = 3;
1866                 $result         = api_favorites_create_destroy('json');
1867                 self::assertStatus($result['status']);
1868         }
1869
1870         /**
1871          * Test the api_favorites_create_destroy() function without an authenticated user.
1872          *
1873          * @return void
1874          */
1875         public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1876         {
1877                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1878                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1879                 BasicAuth::setCurrentUserID();
1880                 $_SESSION['authenticated'] = false;
1881                 api_favorites_create_destroy('json');
1882         }
1883
1884         /**
1885          * Test the api_favorites() function.
1886          *
1887          * @return void
1888          */
1889         public function testApiFavorites()
1890         {
1891                 $_REQUEST['page']   = -1;
1892                 $_REQUEST['max_id'] = 10;
1893                 $result             = api_favorites('json');
1894                 foreach ($result['status'] as $status) {
1895                         self::assertStatus($status);
1896                 }
1897         }
1898
1899         /**
1900          * Test the api_favorites() function with an RSS result.
1901          *
1902          * @return void
1903          */
1904         public function testApiFavoritesWithRss()
1905         {
1906                 $result = api_favorites('rss');
1907                 self::assertXml($result, 'statuses');
1908         }
1909
1910         /**
1911          * Test the api_favorites() function with an unallowed user.
1912          *
1913          * @return void
1914          */
1915         public function testApiFavoritesWithUnallowedUser()
1916         {
1917                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1918                 BasicAuth::setCurrentUserID();
1919                 api_favorites('json');
1920         }
1921
1922         /**
1923          * Test the api_format_messages() function.
1924          *
1925          * @return void
1926          */
1927         public function testApiFormatMessages()
1928         {
1929                 $result = api_format_messages(
1930                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1931                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1932                         ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1933                 );
1934                 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1935                 self::assertEquals(1, $result['id']);
1936                 self::assertEquals(2, $result['recipient_id']);
1937                 self::assertEquals(3, $result['sender_id']);
1938                 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1939                 self::assertEquals('sender_name', $result['sender_screen_name']);
1940         }
1941
1942         /**
1943          * Test the api_format_messages() function with HTML.
1944          *
1945          * @return void
1946          */
1947         public function testApiFormatMessagesWithHtmlText()
1948         {
1949                 $_GET['getText'] = 'html';
1950                 $result          = api_format_messages(
1951                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1952                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1953                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1954                 );
1955                 self::assertEquals('item_title', $result['title']);
1956                 self::assertEquals('<strong>item_body</strong>', $result['text']);
1957         }
1958
1959         /**
1960          * Test the api_format_messages() function with plain text.
1961          *
1962          * @return void
1963          */
1964         public function testApiFormatMessagesWithPlainText()
1965         {
1966                 $_GET['getText'] = 'plain';
1967                 $result          = api_format_messages(
1968                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1969                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1970                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1971                 );
1972                 self::assertEquals('item_title', $result['title']);
1973                 self::assertEquals('item_body', $result['text']);
1974         }
1975
1976         /**
1977          * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1978          *
1979          * @return void
1980          */
1981         public function testApiFormatMessagesWithoutUserObjects()
1982         {
1983                 $_GET['getUserObjects'] = 'false';
1984                 $result                 = api_format_messages(
1985                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1986                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1987                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1988                 );
1989                 self::assertTrue(!isset($result['sender']));
1990                 self::assertTrue(!isset($result['recipient']));
1991         }
1992
1993         /**
1994          * Test the api_convert_item() function.
1995          *
1996          * @return void
1997          */
1998         public function testApiConvertItem()
1999         {
2000                 /*
2001                 $result = api_convert_item(
2002                         [
2003                                 'network' => 'feed',
2004                                 'title'   => 'item_title',
2005                                 'uri-id'  => 1,
2006                                 // We need a long string to test that it is correctly cut
2007                                 'body'    => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
2008                                                          'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
2009                                                          'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
2010                                                          'laudantium atque commodi alias voluptatem non possimus aperiam ' .
2011                                                          'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
2012                                                          'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
2013                                                          'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
2014                                                          'veritatis nihil distinctio qui eum repellat officia illum quos ' .
2015                                                          'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
2016                                                          'omnis exercitationem quo magnam consequatur maxime aut illum ' .
2017                                                          'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
2018                                                          'temporibus corporis ratione blanditiis perspiciatis impedit ' .
2019                                                          'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
2020                                                          'sunt consequatur inventore dolor officiis pariatur doloremque ' .
2021                                                          'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
2022                                                          'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
2023                                                          'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
2024                                                          'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
2025                                                          'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
2026                                                          'repellat officia illum quos impedit quam iste esse unde qui ' .
2027                                                          'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
2028                                                          'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
2029                                                          'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
2030                                 'plink'   => 'item_plink'
2031                         ]
2032                 );
2033                 self::assertStringStartsWith('item_title', $result['text']);
2034                 self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
2035                 */
2036         }
2037
2038         /**
2039          * Test the api_convert_item() function with an empty item body.
2040          *
2041          * @return void
2042          */
2043         public function testApiConvertItemWithoutBody()
2044         {
2045                 /*
2046                 $result = api_convert_item(
2047                         [
2048                                 'network' => 'feed',
2049                                 'title'   => 'item_title',
2050                                 'uri-id'  => -1,
2051                                 'body'    => '',
2052                                 'plink'   => 'item_plink'
2053                         ]
2054                 );
2055                 self::assertEquals("item_title", $result['text']);
2056                 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2057                 */
2058         }
2059
2060         /**
2061          * Test the api_convert_item() function with the title in the body.
2062          *
2063          * @return void
2064          */
2065         public function testApiConvertItemWithTitleInBody()
2066         {
2067                 /*
2068                 $result = api_convert_item(
2069                         [
2070                                 'title'  => 'item_title',
2071                                 'body'   => 'item_title item_body',
2072                                 'uri-id' => 1,
2073                         ]
2074                 );
2075                 self::assertEquals('item_title item_body', $result['text']);
2076                 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2077                 */
2078         }
2079
2080         /**
2081          * Test the api_get_attachments() function.
2082          *
2083          * @return void
2084          */
2085         public function testApiGetAttachments()
2086         {
2087                 // $body = 'body';
2088                 // self::assertEmpty(api_get_attachments($body, 0));
2089         }
2090
2091         /**
2092          * Test the api_get_attachments() function with an img tag.
2093          *
2094          * @return void
2095          */
2096         public function testApiGetAttachmentsWithImage()
2097         {
2098                 // $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2099                 // self::assertIsArray(api_get_attachments($body, 0));
2100         }
2101
2102         /**
2103          * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2104          *
2105          * @return void
2106          */
2107         public function testApiGetAttachmentsWithImageAndAndStatus()
2108         {
2109                 // $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2110                 // $body                       = '[img]http://via.placeholder.com/1x1.png[/img]';
2111                 // self::assertIsArray(api_get_attachments($body, 0));
2112         }
2113
2114         /**
2115          * Test the api_get_entitities() function.
2116          *
2117          * @return void
2118          */
2119         public function testApiGetEntitities()
2120         {
2121                 // $text = 'text';
2122                 // self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2123         }
2124
2125         /**
2126          * Test the api_get_entitities() function with the include_entities parameter.
2127          *
2128          * @return void
2129          */
2130         public function testApiGetEntititiesWithIncludeEntities()
2131         {
2132                 /*
2133                 $_REQUEST['include_entities'] = 'true';
2134                 $text                         = 'text';
2135                 $result                       = api_get_entitities($text, 'bbcode', 0);
2136                 self::assertIsArray($result['hashtags']);
2137                 self::assertIsArray($result['symbols']);
2138                 self::assertIsArray($result['urls']);
2139                 self::assertIsArray($result['user_mentions']);
2140                 */
2141         }
2142
2143         /**
2144          * Test the api_format_items_embeded_images() function.
2145          *
2146          * @return void
2147          */
2148         public function testApiFormatItemsEmbededImages()
2149         {
2150                 /*
2151                 self::assertEquals(
2152                         'text ' . DI::baseUrl() . '/display/item_guid',
2153                         api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2154                 );
2155                 */
2156         }
2157
2158         /**
2159          * Test the api_format_items_activities() function.
2160          *
2161          * @return void
2162          */
2163         public function testApiFormatItemsActivities()
2164         {
2165                 $item   = ['uid' => 0, 'uri-id' => 1];
2166                 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid']);
2167                 self::assertArrayHasKey('like', $result);
2168                 self::assertArrayHasKey('dislike', $result);
2169                 self::assertArrayHasKey('attendyes', $result);
2170                 self::assertArrayHasKey('attendno', $result);
2171                 self::assertArrayHasKey('attendmaybe', $result);
2172         }
2173
2174         /**
2175          * Test the api_format_items_activities() function with an XML result.
2176          *
2177          * @return void
2178          */
2179         public function testApiFormatItemsActivitiesWithXml()
2180         {
2181                 $item   = ['uid' => 0, 'uri-id' => 1];
2182                 $result = DI::friendicaActivities()->createFromUriId($item['uri-id'], $item['uid'], 'xml');
2183                 self::assertArrayHasKey('friendica:like', $result);
2184                 self::assertArrayHasKey('friendica:dislike', $result);
2185                 self::assertArrayHasKey('friendica:attendyes', $result);
2186                 self::assertArrayHasKey('friendica:attendno', $result);
2187                 self::assertArrayHasKey('friendica:attendmaybe', $result);
2188         }
2189
2190         /**
2191          * Test the api_format_items() function.
2192          * @doesNotPerformAssertions
2193          */
2194         public function testApiFormatItems()
2195         {
2196                 /*
2197                 $items = Post::selectToArray([], ['uid' => 42]);
2198                 foreach ($items as $item) {
2199                         $status = api_format_item($item);
2200                         self::assertStatus($status);
2201                 }
2202                 */
2203         }
2204
2205         /**
2206          * Test the api_format_items() function with an XML result.
2207          * @doesNotPerformAssertions
2208          */
2209         public function testApiFormatItemsWithXml()
2210         {
2211                 /*
2212                 $items = Post::selectToArray([], ['uid' => 42]);
2213                 foreach ($items as $item) {
2214                         $status = api_format_item($item, 'xml');
2215                         self::assertStatus($status);
2216                 }
2217                 */
2218         }
2219
2220         /**
2221          * Test the api_lists_list() function.
2222          *
2223          * @return void
2224          */
2225         public function testApiListsList()
2226         {
2227                 $result = api_lists_list('json');
2228                 self::assertEquals(['lists_list' => []], $result);
2229         }
2230
2231         /**
2232          * Test the api_lists_ownerships() function.
2233          *
2234          * @return void
2235          */
2236         public function testApiListsOwnerships()
2237         {
2238                 $result = api_lists_ownerships('json');
2239                 foreach ($result['lists']['lists'] as $list) {
2240                         self::assertList($list);
2241                 }
2242         }
2243
2244         /**
2245          * Test the api_lists_ownerships() function without an authenticated user.
2246          *
2247          * @return void
2248          */
2249         public function testApiListsOwnershipsWithoutAuthenticatedUser()
2250         {
2251                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2252                 BasicAuth::setCurrentUserID();
2253                 $_SESSION['authenticated'] = false;
2254                 api_lists_ownerships('json');
2255         }
2256
2257         /**
2258          * Test the api_lists_statuses() function.
2259          *
2260          * @return void
2261          */
2262         public function testApiListsStatuses()
2263         {
2264                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2265                 api_lists_statuses('json');
2266         }
2267
2268         /**
2269          * Test the api_lists_statuses() function with a list ID.
2270          * @doesNotPerformAssertions
2271          */
2272         public function testApiListsStatusesWithListId()
2273         {
2274                 $_REQUEST['list_id'] = 1;
2275                 $_REQUEST['page']    = -1;
2276                 $_REQUEST['max_id']  = 10;
2277                 $result              = api_lists_statuses('json');
2278                 foreach ($result['status'] as $status) {
2279                         self::assertStatus($status);
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                 $_POST['name']        = 'new_name';
2966                 $_POST['description'] = 'new_description';
2967                 $result               = api_account_update_profile('json');
2968                 // We can't use assertSelfUser() here because the user object is missing some properties.
2969                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
2970                 self::assertEquals('DFRN', $result['user']['location']);
2971                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
2972                 self::assertEquals('new_name', $result['user']['name']);
2973                 self::assertEquals('new_description', $result['user']['description']);
2974         }
2975
2976         /**
2977          * Test the check_acl_input() function.
2978          *
2979          * @return void
2980          */
2981         public function testCheckAclInput()
2982         {
2983                 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
2984                 // Where does this result come from?
2985                 self::assertEquals(1, $result);
2986         }
2987
2988         /**
2989          * Test the check_acl_input() function with an empty ACL string.
2990          *
2991          * @return void
2992          */
2993         public function testCheckAclInputWithEmptyAclString()
2994         {
2995                 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
2996                 self::assertFalse($result);
2997         }
2998
2999         /**
3000          * Test the save_media_to_database() function.
3001          *
3002          * @return void
3003          */
3004         public function testSaveMediaToDatabase()
3005         {
3006                 $this->markTestIncomplete();
3007         }
3008
3009         /**
3010          * Test the post_photo_item() function.
3011          *
3012          * @return void
3013          */
3014         public function testPostPhotoItem()
3015         {
3016                 $this->markTestIncomplete();
3017         }
3018
3019         /**
3020          * Test the prepare_photo_data() function.
3021          *
3022          * @return void
3023          */
3024         public function testPreparePhotoData()
3025         {
3026                 $this->markTestIncomplete();
3027         }
3028
3029         /**
3030          * Test the api_share_as_retweet() function with a valid item.
3031          *
3032          * @return void
3033          */
3034         public function testApiShareAsRetweetWithValidItem()
3035         {
3036                 $this->markTestIncomplete();
3037         }
3038
3039         /**
3040          * Test the api_in_reply_to() function with a valid item.
3041          *
3042          * @return void
3043          */
3044         public function testApiInReplyToWithValidItem()
3045         {
3046                 $this->markTestIncomplete();
3047         }
3048
3049         /**
3050          * Test the api_clean_plain_items() function.
3051          *
3052          * @return void
3053          */
3054         public function testApiCleanPlainItems()
3055         {
3056                 $_REQUEST['include_entities'] = 'true';
3057                 $result                       = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3058                 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3059         }
3060
3061         /**
3062          * Test the api_best_nickname() function with contacts.
3063          *
3064          * @return void
3065          */
3066         public function testApiBestNicknameWithContacts()
3067         {
3068                 $this->markTestIncomplete();
3069         }
3070
3071         /**
3072          * Test the api_friendica_group_show() function.
3073          *
3074          * @return void
3075          */
3076         public function testApiFriendicaGroupShow()
3077         {
3078                 $this->markTestIncomplete();
3079         }
3080
3081         /**
3082          * Test the api_friendica_group_delete() function.
3083          *
3084          * @return void
3085          */
3086         public function testApiFriendicaGroupDelete()
3087         {
3088                 $this->markTestIncomplete();
3089         }
3090
3091         /**
3092          * Test the api_lists_destroy() function.
3093          *
3094          * @return void
3095          */
3096         public function testApiListsDestroy()
3097         {
3098                 $this->markTestIncomplete();
3099         }
3100
3101         /**
3102          * Test the group_create() function.
3103          *
3104          * @return void
3105          */
3106         public function testGroupCreate()
3107         {
3108                 $this->markTestIncomplete();
3109         }
3110
3111         /**
3112          * Test the api_friendica_group_create() function.
3113          *
3114          * @return void
3115          */
3116         public function testApiFriendicaGroupCreate()
3117         {
3118                 $this->markTestIncomplete();
3119         }
3120
3121         /**
3122          * Test the api_lists_create() function.
3123          *
3124          * @return void
3125          */
3126         public function testApiListsCreate()
3127         {
3128                 $this->markTestIncomplete();
3129         }
3130
3131         /**
3132          * Test the api_friendica_group_update() function.
3133          *
3134          * @return void
3135          */
3136         public function testApiFriendicaGroupUpdate()
3137         {
3138                 $this->markTestIncomplete();
3139         }
3140
3141         /**
3142          * Test the api_lists_update() function.
3143          *
3144          * @return void
3145          */
3146         public function testApiListsUpdate()
3147         {
3148                 $this->markTestIncomplete();
3149         }
3150
3151         /**
3152          * Test the api_friendica_activity() function.
3153          *
3154          * @return void
3155          */
3156         public function testApiFriendicaActivity()
3157         {
3158                 $this->markTestIncomplete();
3159         }
3160
3161         /**
3162          * Test the api_friendica_notification_seen() function.
3163          *
3164          * @return void
3165          */
3166         public function testApiFriendicaNotificationSeen()
3167         {
3168                 $this->markTestIncomplete();
3169         }
3170
3171         /**
3172          * Test the api_friendica_direct_messages_setseen() function.
3173          *
3174          * @return void
3175          */
3176         public function testApiFriendicaDirectMessagesSetseen()
3177         {
3178                 $this->markTestIncomplete();
3179         }
3180
3181         /**
3182          * Test the api_friendica_direct_messages_search() function.
3183          *
3184          * @return void
3185          */
3186         public function testApiFriendicaDirectMessagesSearch()
3187         {
3188                 $this->markTestIncomplete();
3189         }
3190 }