]> git.mxchange.org Git - friendica.git/blob - tests/legacy/ApiTest.php
4c9a691469279fa07cf7e2e1f5dd582c1e1d86f7
[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', api_source());
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', api_source());
258         }
259
260         /**
261          * Test the api_source() function with a GET parameter.
262          *
263          * @return void
264          */
265         public function testApiSourceWithGet()
266         {
267                 $_GET['source'] = 'source_name';
268                 self::assertEquals('source_name', api_source());
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
1153                 self::assertNotNull($item);
1154         }
1155
1156         /**
1157          * Test the api_users_show() function.
1158          *
1159          * @return void
1160          */
1161         public function testApiUsersShow()
1162         {
1163                 $result = api_users_show('json');
1164                 // We can't use assertSelfUser() here because the user object is missing some properties.
1165                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
1166                 self::assertEquals('DFRN', $result['user']['location']);
1167                 self::assertEquals($this->selfUser['name'], $result['user']['name']);
1168                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
1169                 self::assertTrue($result['user']['verified']);
1170         }
1171
1172         /**
1173          * Test the api_users_show() function with an XML result.
1174          *
1175          * @return void
1176          */
1177         public function testApiUsersShowWithXml()
1178         {
1179                 $result = api_users_show('xml');
1180                 self::assertXml($result, 'statuses');
1181         }
1182
1183         /**
1184          * Test the api_users_search() function.
1185          *
1186          * @return void
1187          */
1188         public function testApiUsersSearch()
1189         {
1190                 $_GET['q'] = 'othercontact';
1191                 $result    = api_users_search('json');
1192                 self::assertOtherUser($result['users'][0]);
1193         }
1194
1195         /**
1196          * Test the api_users_search() function with an XML result.
1197          *
1198          * @return void
1199          */
1200         public function testApiUsersSearchWithXml()
1201         {
1202                 $_GET['q'] = 'othercontact';
1203                 $result    = api_users_search('xml');
1204                 self::assertXml($result, 'users');
1205         }
1206
1207         /**
1208          * Test the api_users_search() function without a GET q parameter.
1209          *
1210          * @return void
1211          */
1212         public function testApiUsersSearchWithoutQuery()
1213         {
1214                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1215                 api_users_search('json');
1216         }
1217
1218         /**
1219          * Test the api_users_lookup() function.
1220          *
1221          * @return void
1222          */
1223         public function testApiUsersLookup()
1224         {
1225                 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
1226                 api_users_lookup('json');
1227         }
1228
1229         /**
1230          * Test the api_users_lookup() function with an user ID.
1231          *
1232          * @return void
1233          */
1234         public function testApiUsersLookupWithUserId()
1235         {
1236                 $_REQUEST['user_id'] = $this->otherUser['id'];
1237                 $result              = api_users_lookup('json');
1238                 self::assertOtherUser($result['users'][0]);
1239         }
1240
1241         /**
1242          * Test the api_search() function.
1243          *
1244          * @return void
1245          */
1246         public function testApiSearch()
1247         {
1248                 $_REQUEST['q']      = 'reply';
1249                 $_REQUEST['max_id'] = 10;
1250                 $result             = api_search('json');
1251                 foreach ($result['status'] as $status) {
1252                         self::assertStatus($status);
1253                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1254                 }
1255         }
1256
1257         /**
1258          * Test the api_search() function a count parameter.
1259          *
1260          * @return void
1261          */
1262         public function testApiSearchWithCount()
1263         {
1264                 $_REQUEST['q']     = 'reply';
1265                 $_REQUEST['count'] = 20;
1266                 $result            = api_search('json');
1267                 foreach ($result['status'] as $status) {
1268                         self::assertStatus($status);
1269                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1270                 }
1271         }
1272
1273         /**
1274          * Test the api_search() function with an rpp parameter.
1275          *
1276          * @return void
1277          */
1278         public function testApiSearchWithRpp()
1279         {
1280                 $_REQUEST['q']   = 'reply';
1281                 $_REQUEST['rpp'] = 20;
1282                 $result          = api_search('json');
1283                 foreach ($result['status'] as $status) {
1284                         self::assertStatus($status);
1285                         self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
1286                 }
1287         }
1288
1289         /**
1290          * Test the api_search() function with an q parameter contains hashtag.
1291          * @doesNotPerformAssertions
1292          */
1293         public function testApiSearchWithHashtag()
1294         {
1295                 $_REQUEST['q'] = '%23friendica';
1296                 $result        = api_search('json');
1297                 foreach ($result['status'] as $status) {
1298                         self::assertStatus($status);
1299                         self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
1300                 }
1301         }
1302
1303         /**
1304          * Test the api_search() function with an exclude_replies parameter.
1305          * @doesNotPerformAssertions
1306          */
1307         public function testApiSearchWithExcludeReplies()
1308         {
1309                 $_REQUEST['max_id']          = 10;
1310                 $_REQUEST['exclude_replies'] = true;
1311                 $_REQUEST['q']               = 'friendica';
1312                 $result                      = api_search('json');
1313                 foreach ($result['status'] as $status) {
1314                         self::assertStatus($status);
1315                 }
1316         }
1317
1318         /**
1319          * Test the api_search() function without an authenticated user.
1320          *
1321          * @return void
1322          */
1323         public function testApiSearchWithUnallowedUser()
1324         {
1325                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1326                 BasicAuth::setCurrentUserID();
1327                 api_search('json');
1328         }
1329
1330         /**
1331          * Test the api_search() function without any GET query parameter.
1332          *
1333          * @return void
1334          */
1335         public function testApiSearchWithoutQuery()
1336         {
1337                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1338                 api_search('json');
1339         }
1340
1341         /**
1342          * Test the api_statuses_home_timeline() function.
1343          *
1344          * @return void
1345          */
1346         public function testApiStatusesHomeTimeline()
1347         {
1348                 $_REQUEST['max_id']          = 10;
1349                 $_REQUEST['exclude_replies'] = true;
1350                 $_REQUEST['conversation_id'] = 1;
1351                 $result                      = api_statuses_home_timeline('json');
1352                 self::assertNotEmpty($result['status']);
1353                 foreach ($result['status'] as $status) {
1354                         self::assertStatus($status);
1355                 }
1356         }
1357
1358         /**
1359          * Test the api_statuses_home_timeline() function with a negative page parameter.
1360          *
1361          * @return void
1362          */
1363         public function testApiStatusesHomeTimelineWithNegativePage()
1364         {
1365                 $_REQUEST['page'] = -2;
1366                 $result           = api_statuses_home_timeline('json');
1367                 self::assertNotEmpty($result['status']);
1368                 foreach ($result['status'] as $status) {
1369                         self::assertStatus($status);
1370                 }
1371         }
1372
1373         /**
1374          * Test the api_statuses_home_timeline() with an unallowed user.
1375          *
1376          * @return void
1377          */
1378         public function testApiStatusesHomeTimelineWithUnallowedUser()
1379         {
1380                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1381                 BasicAuth::setCurrentUserID();
1382                 api_statuses_home_timeline('json');
1383         }
1384
1385         /**
1386          * Test the api_statuses_home_timeline() function with an RSS result.
1387          *
1388          * @return void
1389          */
1390         public function testApiStatusesHomeTimelineWithRss()
1391         {
1392                 $result = api_statuses_home_timeline('rss');
1393                 self::assertXml($result, 'statuses');
1394         }
1395
1396         /**
1397          * Test the api_statuses_public_timeline() function.
1398          *
1399          * @return void
1400          */
1401         public function testApiStatusesPublicTimeline()
1402         {
1403                 $_REQUEST['max_id']          = 10;
1404                 $_REQUEST['conversation_id'] = 1;
1405                 $result                      = api_statuses_public_timeline('json');
1406                 self::assertNotEmpty($result['status']);
1407                 foreach ($result['status'] as $status) {
1408                         self::assertStatus($status);
1409                 }
1410         }
1411
1412         /**
1413          * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
1414          *
1415          * @return void
1416          */
1417         public function testApiStatusesPublicTimelineWithExcludeReplies()
1418         {
1419                 $_REQUEST['max_id']          = 10;
1420                 $_REQUEST['exclude_replies'] = true;
1421                 $result                      = api_statuses_public_timeline('json');
1422                 self::assertNotEmpty($result['status']);
1423                 foreach ($result['status'] as $status) {
1424                         self::assertStatus($status);
1425                 }
1426         }
1427
1428         /**
1429          * Test the api_statuses_public_timeline() function with a negative page parameter.
1430          *
1431          * @return void
1432          */
1433         public function testApiStatusesPublicTimelineWithNegativePage()
1434         {
1435                 $_REQUEST['page'] = -2;
1436                 $result           = api_statuses_public_timeline('json');
1437                 self::assertNotEmpty($result['status']);
1438                 foreach ($result['status'] as $status) {
1439                         self::assertStatus($status);
1440                 }
1441         }
1442
1443         /**
1444          * Test the api_statuses_public_timeline() function with an unallowed user.
1445          *
1446          * @return void
1447          */
1448         public function testApiStatusesPublicTimelineWithUnallowedUser()
1449         {
1450                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1451                 BasicAuth::setCurrentUserID();
1452                 api_statuses_public_timeline('json');
1453         }
1454
1455         /**
1456          * Test the api_statuses_public_timeline() function with an RSS result.
1457          *
1458          * @return void
1459          */
1460         public function testApiStatusesPublicTimelineWithRss()
1461         {
1462                 $result = api_statuses_public_timeline('rss');
1463                 self::assertXml($result, 'statuses');
1464         }
1465
1466         /**
1467          * Test the api_statuses_networkpublic_timeline() function.
1468          *
1469          * @return void
1470          */
1471         public function testApiStatusesNetworkpublicTimeline()
1472         {
1473                 $_REQUEST['max_id'] = 10;
1474                 $result             = api_statuses_networkpublic_timeline('json');
1475                 self::assertNotEmpty($result['status']);
1476                 foreach ($result['status'] as $status) {
1477                         self::assertStatus($status);
1478                 }
1479         }
1480
1481         /**
1482          * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
1483          *
1484          * @return void
1485          */
1486         public function testApiStatusesNetworkpublicTimelineWithNegativePage()
1487         {
1488                 $_REQUEST['page'] = -2;
1489                 $result           = api_statuses_networkpublic_timeline('json');
1490                 self::assertNotEmpty($result['status']);
1491                 foreach ($result['status'] as $status) {
1492                         self::assertStatus($status);
1493                 }
1494         }
1495
1496         /**
1497          * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
1498          *
1499          * @return void
1500          */
1501         public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
1502         {
1503                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1504                 BasicAuth::setCurrentUserID();
1505                 api_statuses_networkpublic_timeline('json');
1506         }
1507
1508         /**
1509          * Test the api_statuses_networkpublic_timeline() function with an RSS result.
1510          *
1511          * @return void
1512          */
1513         public function testApiStatusesNetworkpublicTimelineWithRss()
1514         {
1515                 $result = api_statuses_networkpublic_timeline('rss');
1516                 self::assertXml($result, 'statuses');
1517         }
1518
1519         /**
1520          * Test the api_statuses_show() function.
1521          *
1522          * @return void
1523          */
1524         public function testApiStatusesShow()
1525         {
1526                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1527                 api_statuses_show('json');
1528         }
1529
1530         /**
1531          * Test the api_statuses_show() function with an ID.
1532          *
1533          * @return void
1534          */
1535         public function testApiStatusesShowWithId()
1536         {
1537                 DI::args()->setArgv(['', '', '', 1]);
1538                 $result = api_statuses_show('json');
1539                 self::assertStatus($result['status']);
1540         }
1541
1542         /**
1543          * Test the api_statuses_show() function with the conversation parameter.
1544          *
1545          * @return void
1546          */
1547         public function testApiStatusesShowWithConversation()
1548         {
1549                 DI::args()->setArgv(['', '', '', 1]);
1550                 $_REQUEST['conversation'] = 1;
1551                 $result                   = api_statuses_show('json');
1552                 self::assertNotEmpty($result['status']);
1553                 foreach ($result['status'] as $status) {
1554                         self::assertStatus($status);
1555                 }
1556         }
1557
1558         /**
1559          * Test the api_statuses_show() function with an unallowed user.
1560          *
1561          * @return void
1562          */
1563         public function testApiStatusesShowWithUnallowedUser()
1564         {
1565                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1566                 BasicAuth::setCurrentUserID();
1567                 api_statuses_show('json');
1568         }
1569
1570         /**
1571          * Test the api_conversation_show() function.
1572          *
1573          * @return void
1574          */
1575         public function testApiConversationShow()
1576         {
1577                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1578                 api_conversation_show('json');
1579         }
1580
1581         /**
1582          * Test the api_conversation_show() function with an ID.
1583          *
1584          * @return void
1585          */
1586         public function testApiConversationShowWithId()
1587         {
1588                 DI::args()->setArgv(['', '', '', 1]);
1589                 $_REQUEST['max_id'] = 10;
1590                 $_REQUEST['page']   = -2;
1591                 $result             = api_conversation_show('json');
1592                 self::assertNotEmpty($result['status']);
1593                 foreach ($result['status'] as $status) {
1594                         self::assertStatus($status);
1595                 }
1596         }
1597
1598         /**
1599          * Test the api_conversation_show() function with an unallowed user.
1600          *
1601          * @return void
1602          */
1603         public function testApiConversationShowWithUnallowedUser()
1604         {
1605                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1606                 BasicAuth::setCurrentUserID();
1607                 api_conversation_show('json');
1608         }
1609
1610         /**
1611          * Test the api_statuses_repeat() function.
1612          *
1613          * @return void
1614          */
1615         public function testApiStatusesRepeat()
1616         {
1617                 $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
1618                 api_statuses_repeat('json');
1619         }
1620
1621         /**
1622          * Test the api_statuses_repeat() function without an authenticated user.
1623          *
1624          * @return void
1625          */
1626         public function testApiStatusesRepeatWithoutAuthenticatedUser()
1627         {
1628                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1629                 BasicAuth::setCurrentUserID();
1630                 $_SESSION['authenticated'] = false;
1631                 api_statuses_repeat('json');
1632         }
1633
1634         /**
1635          * Test the api_statuses_repeat() function with an ID.
1636          *
1637          * @return void
1638          */
1639         public function testApiStatusesRepeatWithId()
1640         {
1641                 DI::args()->setArgv(['', '', '', 1]);
1642                 $result = api_statuses_repeat('json');
1643                 self::assertStatus($result['status']);
1644
1645                 // Also test with a shared status
1646                 DI::args()->setArgv(['', '', '', 5]);
1647                 $result = api_statuses_repeat('json');
1648                 self::assertStatus($result['status']);
1649         }
1650
1651         /**
1652          * Test the api_statuses_destroy() function.
1653          *
1654          * @return void
1655          */
1656         public function testApiStatusesDestroy()
1657         {
1658                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1659                 api_statuses_destroy('json');
1660         }
1661
1662         /**
1663          * Test the api_statuses_destroy() function without an authenticated user.
1664          *
1665          * @return void
1666          */
1667         public function testApiStatusesDestroyWithoutAuthenticatedUser()
1668         {
1669                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1670                 BasicAuth::setCurrentUserID();
1671                 $_SESSION['authenticated'] = false;
1672                 api_statuses_destroy('json');
1673         }
1674
1675         /**
1676          * Test the api_statuses_destroy() function with an ID.
1677          *
1678          * @return void
1679          */
1680         public function testApiStatusesDestroyWithId()
1681         {
1682                 DI::args()->setArgv(['', '', '', 1]);
1683                 $result = api_statuses_destroy('json');
1684                 self::assertStatus($result['status']);
1685         }
1686
1687         /**
1688          * Test the api_statuses_mentions() function.
1689          *
1690          * @return void
1691          */
1692         public function testApiStatusesMentions()
1693         {
1694                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
1695                 $_REQUEST['max_id'] = 10;
1696                 $result             = api_statuses_mentions('json');
1697                 self::assertEmpty($result['status']);
1698                 // We should test with mentions in the database.
1699         }
1700
1701         /**
1702          * Test the api_statuses_mentions() function with a negative page parameter.
1703          *
1704          * @return void
1705          */
1706         public function testApiStatusesMentionsWithNegativePage()
1707         {
1708                 $_REQUEST['page'] = -2;
1709                 $result           = api_statuses_mentions('json');
1710                 self::assertEmpty($result['status']);
1711         }
1712
1713         /**
1714          * Test the api_statuses_mentions() function with an unallowed user.
1715          *
1716          * @return void
1717          */
1718         public function testApiStatusesMentionsWithUnallowedUser()
1719         {
1720                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1721                 BasicAuth::setCurrentUserID();
1722                 api_statuses_mentions('json');
1723         }
1724
1725         /**
1726          * Test the api_statuses_mentions() function with an RSS result.
1727          *
1728          * @return void
1729          */
1730         public function testApiStatusesMentionsWithRss()
1731         {
1732                 $result = api_statuses_mentions('rss');
1733                 self::assertXml($result, 'statuses');
1734         }
1735
1736         /**
1737          * Test the api_statuses_user_timeline() function.
1738          *
1739          * @return void
1740          */
1741         public function testApiStatusesUserTimeline()
1742         {
1743                 $_REQUEST['user_id']         = 42;
1744                 $_REQUEST['max_id']          = 10;
1745                 $_REQUEST['exclude_replies'] = true;
1746                 $_REQUEST['conversation_id'] = 7;
1747
1748                 $result = api_statuses_user_timeline('json');
1749                 self::assertNotEmpty($result['status']);
1750                 foreach ($result['status'] as $status) {
1751                         self::assertStatus($status);
1752                 }
1753         }
1754
1755         /**
1756          * Test the api_statuses_user_timeline() function with a negative page parameter.
1757          *
1758          * @return void
1759          */
1760         public function testApiStatusesUserTimelineWithNegativePage()
1761         {
1762                 $_REQUEST['user_id'] = 42;
1763                 $_REQUEST['page']    = -2;
1764
1765                 $result = api_statuses_user_timeline('json');
1766                 self::assertNotEmpty($result['status']);
1767                 foreach ($result['status'] as $status) {
1768                         self::assertStatus($status);
1769                 }
1770         }
1771
1772         /**
1773          * Test the api_statuses_user_timeline() function with an RSS result.
1774          *
1775          * @return void
1776          */
1777         public function testApiStatusesUserTimelineWithRss()
1778         {
1779                 $result = api_statuses_user_timeline('rss');
1780                 self::assertXml($result, 'statuses');
1781         }
1782
1783         /**
1784          * Test the api_statuses_user_timeline() function with an unallowed user.
1785          *
1786          * @return void
1787          */
1788         public function testApiStatusesUserTimelineWithUnallowedUser()
1789         {
1790                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1791                 BasicAuth::setCurrentUserID();
1792                 api_statuses_user_timeline('json');
1793         }
1794
1795         /**
1796          * Test the api_favorites_create_destroy() function.
1797          *
1798          * @return void
1799          */
1800         public function testApiFavoritesCreateDestroy()
1801         {
1802                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1803                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
1804                 api_favorites_create_destroy('json');
1805         }
1806
1807         /**
1808          * Test the api_favorites_create_destroy() function with an invalid ID.
1809          *
1810          * @return void
1811          */
1812         public function testApiFavoritesCreateDestroyWithInvalidId()
1813         {
1814                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1815                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
1816                 api_favorites_create_destroy('json');
1817         }
1818
1819         /**
1820          * Test the api_favorites_create_destroy() function with an invalid action.
1821          *
1822          * @return void
1823          */
1824         public function testApiFavoritesCreateDestroyWithInvalidAction()
1825         {
1826                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
1827                 DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
1828                 $_REQUEST['id'] = 1;
1829                 api_favorites_create_destroy('json');
1830         }
1831
1832         /**
1833          * Test the api_favorites_create_destroy() function with the create action.
1834          *
1835          * @return void
1836          */
1837         public function testApiFavoritesCreateDestroyWithCreateAction()
1838         {
1839                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1840                 $_REQUEST['id'] = 3;
1841                 $result         = api_favorites_create_destroy('json');
1842                 self::assertStatus($result['status']);
1843         }
1844
1845         /**
1846          * Test the api_favorites_create_destroy() function with the create action and an RSS result.
1847          *
1848          * @return void
1849          */
1850         public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
1851         {
1852                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
1853                 $_REQUEST['id'] = 3;
1854                 $result         = api_favorites_create_destroy('rss');
1855                 self::assertXml($result, 'status');
1856         }
1857
1858         /**
1859          * Test the api_favorites_create_destroy() function with the destroy action.
1860          *
1861          * @return void
1862          */
1863         public function testApiFavoritesCreateDestroyWithDestroyAction()
1864         {
1865                 DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
1866                 $_REQUEST['id'] = 3;
1867                 $result         = api_favorites_create_destroy('json');
1868                 self::assertStatus($result['status']);
1869         }
1870
1871         /**
1872          * Test the api_favorites_create_destroy() function without an authenticated user.
1873          *
1874          * @return void
1875          */
1876         public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
1877         {
1878                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1879                 DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
1880                 BasicAuth::setCurrentUserID();
1881                 $_SESSION['authenticated'] = false;
1882                 api_favorites_create_destroy('json');
1883         }
1884
1885         /**
1886          * Test the api_favorites() function.
1887          *
1888          * @return void
1889          */
1890         public function testApiFavorites()
1891         {
1892                 $_REQUEST['page']   = -1;
1893                 $_REQUEST['max_id'] = 10;
1894                 $result             = api_favorites('json');
1895                 foreach ($result['status'] as $status) {
1896                         self::assertStatus($status);
1897                 }
1898         }
1899
1900         /**
1901          * Test the api_favorites() function with an RSS result.
1902          *
1903          * @return void
1904          */
1905         public function testApiFavoritesWithRss()
1906         {
1907                 $result = api_favorites('rss');
1908                 self::assertXml($result, 'statuses');
1909         }
1910
1911         /**
1912          * Test the api_favorites() function with an unallowed user.
1913          *
1914          * @return void
1915          */
1916         public function testApiFavoritesWithUnallowedUser()
1917         {
1918                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
1919                 BasicAuth::setCurrentUserID();
1920                 api_favorites('json');
1921         }
1922
1923         /**
1924          * Test the api_format_messages() function.
1925          *
1926          * @return void
1927          */
1928         public function testApiFormatMessages()
1929         {
1930                 $result = api_format_messages(
1931                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1932                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1933                         ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
1934                 );
1935                 self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
1936                 self::assertEquals(1, $result['id']);
1937                 self::assertEquals(2, $result['recipient_id']);
1938                 self::assertEquals(3, $result['sender_id']);
1939                 self::assertEquals('recipient_name', $result['recipient_screen_name']);
1940                 self::assertEquals('sender_name', $result['sender_screen_name']);
1941         }
1942
1943         /**
1944          * Test the api_format_messages() function with HTML.
1945          *
1946          * @return void
1947          */
1948         public function testApiFormatMessagesWithHtmlText()
1949         {
1950                 $_GET['getText'] = 'html';
1951                 $result          = api_format_messages(
1952                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1953                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1954                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1955                 );
1956                 self::assertEquals('item_title', $result['title']);
1957                 self::assertEquals('<strong>item_body</strong>', $result['text']);
1958         }
1959
1960         /**
1961          * Test the api_format_messages() function with plain text.
1962          *
1963          * @return void
1964          */
1965         public function testApiFormatMessagesWithPlainText()
1966         {
1967                 $_GET['getText'] = 'plain';
1968                 $result          = api_format_messages(
1969                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1970                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1971                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1972                 );
1973                 self::assertEquals('item_title', $result['title']);
1974                 self::assertEquals('item_body', $result['text']);
1975         }
1976
1977         /**
1978          * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
1979          *
1980          * @return void
1981          */
1982         public function testApiFormatMessagesWithoutUserObjects()
1983         {
1984                 $_GET['getUserObjects'] = 'false';
1985                 $result                 = api_format_messages(
1986                         ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
1987                         ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
1988                         ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
1989                 );
1990                 self::assertTrue(!isset($result['sender']));
1991                 self::assertTrue(!isset($result['recipient']));
1992         }
1993
1994         /**
1995          * Test the api_convert_item() function.
1996          *
1997          * @return void
1998          */
1999         public function testApiConvertItem()
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          * Test the api_convert_item() function with an empty item body.
2039          *
2040          * @return void
2041          */
2042         public function testApiConvertItemWithoutBody()
2043         {
2044                 $result = api_convert_item(
2045                         [
2046                                 'network' => 'feed',
2047                                 'title'   => 'item_title',
2048                                 'uri-id'  => -1,
2049                                 'body'    => '',
2050                                 'plink'   => 'item_plink'
2051                         ]
2052                 );
2053                 self::assertEquals("item_title", $result['text']);
2054                 self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
2055         }
2056
2057         /**
2058          * Test the api_convert_item() function with the title in the body.
2059          *
2060          * @return void
2061          */
2062         public function testApiConvertItemWithTitleInBody()
2063         {
2064                 $result = api_convert_item(
2065                         [
2066                                 'title'  => 'item_title',
2067                                 'body'   => 'item_title item_body',
2068                                 'uri-id' => 1,
2069                         ]
2070                 );
2071                 self::assertEquals('item_title item_body', $result['text']);
2072                 self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
2073         }
2074
2075         /**
2076          * Test the api_get_attachments() function.
2077          *
2078          * @return void
2079          */
2080         public function testApiGetAttachments()
2081         {
2082                 $body = 'body';
2083                 self::assertEmpty(api_get_attachments($body, 0));
2084         }
2085
2086         /**
2087          * Test the api_get_attachments() function with an img tag.
2088          *
2089          * @return void
2090          */
2091         public function testApiGetAttachmentsWithImage()
2092         {
2093                 $body = '[img]http://via.placeholder.com/1x1.png[/img]';
2094                 self::assertIsArray(api_get_attachments($body, 0));
2095         }
2096
2097         /**
2098          * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
2099          *
2100          * @return void
2101          */
2102         public function testApiGetAttachmentsWithImageAndAndStatus()
2103         {
2104                 $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
2105                 $body                       = '[img]http://via.placeholder.com/1x1.png[/img]';
2106                 self::assertIsArray(api_get_attachments($body, 0));
2107         }
2108
2109         /**
2110          * Test the api_get_entitities() function.
2111          *
2112          * @return void
2113          */
2114         public function testApiGetEntitities()
2115         {
2116                 $text = 'text';
2117                 self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
2118         }
2119
2120         /**
2121          * Test the api_get_entitities() function with the include_entities parameter.
2122          *
2123          * @return void
2124          */
2125         public function testApiGetEntititiesWithIncludeEntities()
2126         {
2127                 $_REQUEST['include_entities'] = 'true';
2128                 $text                         = 'text';
2129                 $result                       = api_get_entitities($text, 'bbcode', 0);
2130                 self::assertIsArray($result['hashtags']);
2131                 self::assertIsArray($result['symbols']);
2132                 self::assertIsArray($result['urls']);
2133                 self::assertIsArray($result['user_mentions']);
2134         }
2135
2136         /**
2137          * Test the api_format_items_embeded_images() function.
2138          *
2139          * @return void
2140          */
2141         public function testApiFormatItemsEmbededImages()
2142         {
2143                 self::assertEquals(
2144                         'text ' . DI::baseUrl() . '/display/item_guid',
2145                         api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
2146                 );
2147         }
2148
2149         /**
2150          * Test the api_contactlink_to_array() function.
2151          *
2152          * @return void
2153          */
2154         public function testApiContactlinkToArray()
2155         {
2156                 self::assertEquals(
2157                         [
2158                                 'name' => 'text',
2159                                 'url'  => '',
2160                         ],
2161                         api_contactlink_to_array('text')
2162                 );
2163         }
2164
2165         /**
2166          * Test the api_contactlink_to_array() function with an URL.
2167          *
2168          * @return void
2169          */
2170         public function testApiContactlinkToArrayWithUrl()
2171         {
2172                 self::assertEquals(
2173                         [
2174                                 'name' => ['link_text'],
2175                                 'url'  => ['url'],
2176                         ],
2177                         api_contactlink_to_array('text <a href="url">link_text</a>')
2178                 );
2179         }
2180
2181         /**
2182          * Test the api_format_items_activities() function.
2183          *
2184          * @return void
2185          */
2186         public function testApiFormatItemsActivities()
2187         {
2188                 $item   = ['uid' => 0, 'uri' => ''];
2189                 $result = api_format_items_activities($item);
2190                 self::assertArrayHasKey('like', $result);
2191                 self::assertArrayHasKey('dislike', $result);
2192                 self::assertArrayHasKey('attendyes', $result);
2193                 self::assertArrayHasKey('attendno', $result);
2194                 self::assertArrayHasKey('attendmaybe', $result);
2195         }
2196
2197         /**
2198          * Test the api_format_items_activities() function with an XML result.
2199          *
2200          * @return void
2201          */
2202         public function testApiFormatItemsActivitiesWithXml()
2203         {
2204                 $item   = ['uid' => 0, 'uri' => ''];
2205                 $result = api_format_items_activities($item, 'xml');
2206                 self::assertArrayHasKey('friendica:like', $result);
2207                 self::assertArrayHasKey('friendica:dislike', $result);
2208                 self::assertArrayHasKey('friendica:attendyes', $result);
2209                 self::assertArrayHasKey('friendica:attendno', $result);
2210                 self::assertArrayHasKey('friendica:attendmaybe', $result);
2211         }
2212
2213         /**
2214          * Test the api_format_items() function.
2215          * @doesNotPerformAssertions
2216          */
2217         public function testApiFormatItems()
2218         {
2219                 $items = Post::selectToArray([], ['uid' => 42]);
2220                 foreach ($items as $item) {
2221                         $status = api_format_item($item);
2222                         self::assertStatus($status);
2223                 }
2224         }
2225
2226         /**
2227          * Test the api_format_items() function with an XML result.
2228          * @doesNotPerformAssertions
2229          */
2230         public function testApiFormatItemsWithXml()
2231         {
2232                 $items = Post::selectToArray([], ['uid' => 42]);
2233                 foreach ($items as $item) {
2234                         $status = api_format_item($item, 'xml');
2235                         self::assertStatus($status);
2236                 }
2237         }
2238
2239         /**
2240          * Test the api_lists_list() function.
2241          *
2242          * @return void
2243          */
2244         public function testApiListsList()
2245         {
2246                 $result = api_lists_list('json');
2247                 self::assertEquals(['lists_list' => []], $result);
2248         }
2249
2250         /**
2251          * Test the api_lists_ownerships() function.
2252          *
2253          * @return void
2254          */
2255         public function testApiListsOwnerships()
2256         {
2257                 $result = api_lists_ownerships('json');
2258                 foreach ($result['lists']['lists'] as $list) {
2259                         self::assertList($list);
2260                 }
2261         }
2262
2263         /**
2264          * Test the api_lists_ownerships() function without an authenticated user.
2265          *
2266          * @return void
2267          */
2268         public function testApiListsOwnershipsWithoutAuthenticatedUser()
2269         {
2270                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2271                 BasicAuth::setCurrentUserID();
2272                 $_SESSION['authenticated'] = false;
2273                 api_lists_ownerships('json');
2274         }
2275
2276         /**
2277          * Test the api_lists_statuses() function.
2278          *
2279          * @return void
2280          */
2281         public function testApiListsStatuses()
2282         {
2283                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2284                 api_lists_statuses('json');
2285         }
2286
2287         /**
2288          * Test the api_lists_statuses() function with a list ID.
2289          * @doesNotPerformAssertions
2290          */
2291         public function testApiListsStatusesWithListId()
2292         {
2293                 $_REQUEST['list_id'] = 1;
2294                 $_REQUEST['page']    = -1;
2295                 $_REQUEST['max_id']  = 10;
2296                 $result              = api_lists_statuses('json');
2297                 foreach ($result['status'] as $status) {
2298                         self::assertStatus($status);
2299                 }
2300         }
2301
2302         /**
2303          * Test the api_lists_statuses() function with a list ID and a RSS result.
2304          *
2305          * @return void
2306          */
2307         public function testApiListsStatusesWithListIdAndRss()
2308         {
2309                 $_REQUEST['list_id'] = 1;
2310                 $result              = api_lists_statuses('rss');
2311                 self::assertXml($result, 'statuses');
2312         }
2313
2314         /**
2315          * Test the api_lists_statuses() function with an unallowed user.
2316          *
2317          * @return void
2318          */
2319         public function testApiListsStatusesWithUnallowedUser()
2320         {
2321                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2322                 BasicAuth::setCurrentUserID();
2323                 api_lists_statuses('json');
2324         }
2325
2326         /**
2327          * Test the api_statuses_f() function.
2328          *
2329          * @return void
2330          */
2331         public function testApiStatusesFWithFriends()
2332         {
2333                 $_GET['page'] = -1;
2334                 $result       = api_statuses_f('friends');
2335                 self::assertArrayHasKey('user', $result);
2336         }
2337
2338         /**
2339          * Test the api_statuses_f() function.
2340          *
2341          * @return void
2342          */
2343         public function testApiStatusesFWithFollowers()
2344         {
2345                 $result = api_statuses_f('followers');
2346                 self::assertArrayHasKey('user', $result);
2347         }
2348
2349         /**
2350          * Test the api_statuses_f() function.
2351          *
2352          * @return void
2353          */
2354         public function testApiStatusesFWithBlocks()
2355         {
2356                 $result = api_statuses_f('blocks');
2357                 self::assertArrayHasKey('user', $result);
2358         }
2359
2360         /**
2361          * Test the api_statuses_f() function.
2362          *
2363          * @return void
2364          */
2365         public function testApiStatusesFWithIncoming()
2366         {
2367                 $result = api_statuses_f('incoming');
2368                 self::assertArrayHasKey('user', $result);
2369         }
2370
2371         /**
2372          * Test the api_statuses_f() function an undefined cursor GET variable.
2373          *
2374          * @return void
2375          */
2376         public function testApiStatusesFWithUndefinedCursor()
2377         {
2378                 $_GET['cursor'] = 'undefined';
2379                 self::assertFalse(api_statuses_f('friends'));
2380         }
2381
2382         /**
2383          * Test the api_statuses_friends() function.
2384          *
2385          * @return void
2386          */
2387         public function testApiStatusesFriends()
2388         {
2389                 $result = api_statuses_friends('json');
2390                 self::assertArrayHasKey('user', $result);
2391         }
2392
2393         /**
2394          * Test the api_statuses_friends() function an undefined cursor GET variable.
2395          *
2396          * @return void
2397          */
2398         public function testApiStatusesFriendsWithUndefinedCursor()
2399         {
2400                 $_GET['cursor'] = 'undefined';
2401                 self::assertFalse(api_statuses_friends('json'));
2402         }
2403
2404         /**
2405          * Test the api_statuses_followers() function.
2406          *
2407          * @return void
2408          */
2409         public function testApiStatusesFollowers()
2410         {
2411                 $result = api_statuses_followers('json');
2412                 self::assertArrayHasKey('user', $result);
2413         }
2414
2415         /**
2416          * Test the api_statuses_followers() function an undefined cursor GET variable.
2417          *
2418          * @return void
2419          */
2420         public function testApiStatusesFollowersWithUndefinedCursor()
2421         {
2422                 $_GET['cursor'] = 'undefined';
2423                 self::assertFalse(api_statuses_followers('json'));
2424         }
2425
2426         /**
2427          * Test the api_blocks_list() function.
2428          *
2429          * @return void
2430          */
2431         public function testApiBlocksList()
2432         {
2433                 $result = api_blocks_list('json');
2434                 self::assertArrayHasKey('user', $result);
2435         }
2436
2437         /**
2438          * Test the api_blocks_list() function an undefined cursor GET variable.
2439          *
2440          * @return void
2441          */
2442         public function testApiBlocksListWithUndefinedCursor()
2443         {
2444                 $_GET['cursor'] = 'undefined';
2445                 self::assertFalse(api_blocks_list('json'));
2446         }
2447
2448         /**
2449          * Test the api_friendships_incoming() function.
2450          *
2451          * @return void
2452          */
2453         public function testApiFriendshipsIncoming()
2454         {
2455                 $result = api_friendships_incoming('json');
2456                 self::assertArrayHasKey('id', $result);
2457         }
2458
2459         /**
2460          * Test the api_friendships_incoming() function an undefined cursor GET variable.
2461          *
2462          * @return void
2463          */
2464         public function testApiFriendshipsIncomingWithUndefinedCursor()
2465         {
2466                 $_GET['cursor'] = 'undefined';
2467                 self::assertFalse(api_friendships_incoming('json'));
2468         }
2469
2470         /**
2471          * Test the api_statusnet_config() function.
2472          *
2473          * @return void
2474          */
2475         public function testApiStatusnetConfig()
2476         {
2477                 /*
2478                 $result = api_statusnet_config('json');
2479                 self::assertEquals('localhost', $result['config']['site']['server']);
2480                 self::assertEquals('default', $result['config']['site']['theme']);
2481                 self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
2482                 self::assertTrue($result['config']['site']['fancy']);
2483                 self::assertEquals('en', $result['config']['site']['language']);
2484                 self::assertEquals('UTC', $result['config']['site']['timezone']);
2485                 self::assertEquals(200000, $result['config']['site']['textlimit']);
2486                 self::assertEquals('false', $result['config']['site']['private']);
2487                 self::assertEquals('false', $result['config']['site']['ssl']);
2488                 self::assertEquals(30, $result['config']['site']['shorturllength']);
2489                 */
2490         }
2491
2492         /**
2493          * Test the api_direct_messages_new() function.
2494          *
2495          * @return void
2496          */
2497         public function testApiDirectMessagesNew()
2498         {
2499                 $result = api_direct_messages_new('json');
2500                 self::assertNull($result);
2501         }
2502
2503         /**
2504          * Test the api_direct_messages_new() function without an authenticated user.
2505          *
2506          * @return void
2507          */
2508         public function testApiDirectMessagesNewWithoutAuthenticatedUser()
2509         {
2510                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2511                 BasicAuth::setCurrentUserID();
2512                 $_SESSION['authenticated'] = false;
2513                 api_direct_messages_new('json');
2514         }
2515
2516         /**
2517          * Test the api_direct_messages_new() function with an user ID.
2518          *
2519          * @return void
2520          */
2521         public function testApiDirectMessagesNewWithUserId()
2522         {
2523                 $_POST['text']    = 'message_text';
2524                 $_POST['user_id'] = $this->otherUser['id'];
2525                 $result           = api_direct_messages_new('json');
2526                 self::assertEquals(['direct_message' => ['error' => -1]], $result);
2527         }
2528
2529         /**
2530          * Test the api_direct_messages_new() function with a screen name.
2531          *
2532          * @return void
2533          */
2534         public function testApiDirectMessagesNewWithScreenName()
2535         {
2536                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2537                 $_POST['text']    = 'message_text';
2538                 $_POST['user_id'] = $this->friendUser['id'];
2539                 $result           = api_direct_messages_new('json');
2540                 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2541                 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2542                 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2543         }
2544
2545         /**
2546          * Test the api_direct_messages_new() function with a title.
2547          *
2548          * @return void
2549          */
2550         public function testApiDirectMessagesNewWithTitle()
2551         {
2552                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2553                 $_POST['text']     = 'message_text';
2554                 $_POST['user_id']  = $this->friendUser['id'];
2555                 $_REQUEST['title'] = 'message_title';
2556                 $result            = api_direct_messages_new('json');
2557                 self::assertStringContainsString('message_text', $result['direct_message']['text']);
2558                 self::assertStringContainsString('message_title', $result['direct_message']['text']);
2559                 self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
2560                 self::assertEquals(1, $result['direct_message']['friendica_seen']);
2561         }
2562
2563         /**
2564          * Test the api_direct_messages_new() function with an RSS result.
2565          *
2566          * @return void
2567          */
2568         public function testApiDirectMessagesNewWithRss()
2569         {
2570                 $this->app->setLoggedInUserNickname($this->selfUser['nick']);
2571                 $_POST['text']    = 'message_text';
2572                 $_POST['user_id'] = $this->friendUser['id'];
2573                 $result           = api_direct_messages_new('rss');
2574                 self::assertXml($result, 'direct-messages');
2575         }
2576
2577         /**
2578          * Test the api_direct_messages_destroy() function.
2579          *
2580          * @return void
2581          */
2582         public function testApiDirectMessagesDestroy()
2583         {
2584                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2585                 api_direct_messages_destroy('json');
2586         }
2587
2588         /**
2589          * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
2590          *
2591          * @return void
2592          */
2593         public function testApiDirectMessagesDestroyWithVerbose()
2594         {
2595                 $_GET['friendica_verbose'] = 'true';
2596                 $result                    = api_direct_messages_destroy('json');
2597                 self::assertEquals(
2598                         [
2599                                 '$result' => [
2600                                         'result'  => 'error',
2601                                         'message' => 'message id or parenturi not specified'
2602                                 ]
2603                         ],
2604                         $result
2605                 );
2606         }
2607
2608         /**
2609          * Test the api_direct_messages_destroy() function without an authenticated user.
2610          *
2611          * @return void
2612          */
2613         public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
2614         {
2615                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2616                 BasicAuth::setCurrentUserID();
2617                 $_SESSION['authenticated'] = false;
2618                 api_direct_messages_destroy('json');
2619         }
2620
2621         /**
2622          * Test the api_direct_messages_destroy() function with a non-zero ID.
2623          *
2624          * @return void
2625          */
2626         public function testApiDirectMessagesDestroyWithId()
2627         {
2628                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2629                 $_REQUEST['id'] = 1;
2630                 api_direct_messages_destroy('json');
2631         }
2632
2633         /**
2634          * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
2635          *
2636          * @return void
2637          */
2638         public function testApiDirectMessagesDestroyWithIdAndVerbose()
2639         {
2640                 $_REQUEST['id']                  = 1;
2641                 $_REQUEST['friendica_parenturi'] = 'parent_uri';
2642                 $_GET['friendica_verbose']       = 'true';
2643                 $result                          = api_direct_messages_destroy('json');
2644                 self::assertEquals(
2645                         [
2646                                 '$result' => [
2647                                         'result'  => 'error',
2648                                         'message' => 'message id not in database'
2649                                 ]
2650                         ],
2651                         $result
2652                 );
2653         }
2654
2655         /**
2656          * Test the api_direct_messages_destroy() function with a non-zero ID.
2657          *
2658          * @return void
2659          */
2660         public function testApiDirectMessagesDestroyWithCorrectId()
2661         {
2662                 $this->markTestIncomplete('We need to add a dataset for this.');
2663         }
2664
2665         /**
2666          * Test the api_direct_messages_box() function.
2667          *
2668          * @return void
2669          */
2670         public function testApiDirectMessagesBoxWithSentbox()
2671         {
2672                 $_REQUEST['page']   = -1;
2673                 $_REQUEST['max_id'] = 10;
2674                 $result             = api_direct_messages_box('json', 'sentbox', 'false');
2675                 self::assertArrayHasKey('direct_message', $result);
2676         }
2677
2678         /**
2679          * Test the api_direct_messages_box() function.
2680          *
2681          * @return void
2682          */
2683         public function testApiDirectMessagesBoxWithConversation()
2684         {
2685                 $result = api_direct_messages_box('json', 'conversation', 'false');
2686                 self::assertArrayHasKey('direct_message', $result);
2687         }
2688
2689         /**
2690          * Test the api_direct_messages_box() function.
2691          *
2692          * @return void
2693          */
2694         public function testApiDirectMessagesBoxWithAll()
2695         {
2696                 $result = api_direct_messages_box('json', 'all', 'false');
2697                 self::assertArrayHasKey('direct_message', $result);
2698         }
2699
2700         /**
2701          * Test the api_direct_messages_box() function.
2702          *
2703          * @return void
2704          */
2705         public function testApiDirectMessagesBoxWithInbox()
2706         {
2707                 $result = api_direct_messages_box('json', 'inbox', 'false');
2708                 self::assertArrayHasKey('direct_message', $result);
2709         }
2710
2711         /**
2712          * Test the api_direct_messages_box() function.
2713          *
2714          * @return void
2715          */
2716         public function testApiDirectMessagesBoxWithVerbose()
2717         {
2718                 $result = api_direct_messages_box('json', 'sentbox', 'true');
2719                 self::assertEquals(
2720                         [
2721                                 '$result' => [
2722                                         'result'  => 'error',
2723                                         'message' => 'no mails available'
2724                                 ]
2725                         ],
2726                         $result
2727                 );
2728         }
2729
2730         /**
2731          * Test the api_direct_messages_box() function with a RSS result.
2732          *
2733          * @return void
2734          */
2735         public function testApiDirectMessagesBoxWithRss()
2736         {
2737                 $result = api_direct_messages_box('rss', 'sentbox', 'false');
2738                 self::assertXml($result, 'direct-messages');
2739         }
2740
2741         /**
2742          * Test the api_direct_messages_box() function without an authenticated user.
2743          *
2744          * @return void
2745          */
2746         public function testApiDirectMessagesBoxWithUnallowedUser()
2747         {
2748                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2749                 BasicAuth::setCurrentUserID();
2750                 api_direct_messages_box('json', 'sentbox', 'false');
2751         }
2752
2753         /**
2754          * Test the api_direct_messages_sentbox() function.
2755          *
2756          * @return void
2757          */
2758         public function testApiDirectMessagesSentbox()
2759         {
2760                 $result = api_direct_messages_sentbox('json');
2761                 self::assertArrayHasKey('direct_message', $result);
2762         }
2763
2764         /**
2765          * Test the api_direct_messages_inbox() function.
2766          *
2767          * @return void
2768          */
2769         public function testApiDirectMessagesInbox()
2770         {
2771                 $result = api_direct_messages_inbox('json');
2772                 self::assertArrayHasKey('direct_message', $result);
2773         }
2774
2775         /**
2776          * Test the api_direct_messages_all() function.
2777          *
2778          * @return void
2779          */
2780         public function testApiDirectMessagesAll()
2781         {
2782                 $result = api_direct_messages_all('json');
2783                 self::assertArrayHasKey('direct_message', $result);
2784         }
2785
2786         /**
2787          * Test the api_direct_messages_conversation() function.
2788          *
2789          * @return void
2790          */
2791         public function testApiDirectMessagesConversation()
2792         {
2793                 $result = api_direct_messages_conversation('json');
2794                 self::assertArrayHasKey('direct_message', $result);
2795         }
2796
2797         /**
2798          * Test the api_oauth_request_token() function.
2799          *
2800          * @return void
2801          */
2802         public function testApiOauthRequestToken()
2803         {
2804                 $this->markTestIncomplete('exit() kills phpunit as well');
2805         }
2806
2807         /**
2808          * Test the api_oauth_access_token() function.
2809          *
2810          * @return void
2811          */
2812         public function testApiOauthAccessToken()
2813         {
2814                 $this->markTestIncomplete('exit() kills phpunit as well');
2815         }
2816
2817         /**
2818          * Test the api_fr_photos_list() function.
2819          *
2820          * @return void
2821          */
2822         public function testApiFrPhotosList()
2823         {
2824                 $result = api_fr_photos_list('json');
2825                 self::assertArrayHasKey('photo', $result);
2826         }
2827
2828         /**
2829          * Test the api_fr_photos_list() function without an authenticated user.
2830          *
2831          * @return void
2832          */
2833         public function testApiFrPhotosListWithoutAuthenticatedUser()
2834         {
2835                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2836                 BasicAuth::setCurrentUserID();
2837                 $_SESSION['authenticated'] = false;
2838                 api_fr_photos_list('json');
2839         }
2840
2841         /**
2842          * Test the api_fr_photo_create_update() function.
2843          */
2844         public function testApiFrPhotoCreateUpdate()
2845         {
2846                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2847                 api_fr_photo_create_update('json');
2848         }
2849
2850         /**
2851          * Test the api_fr_photo_create_update() function without an authenticated user.
2852          *
2853          * @return void
2854          */
2855         public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
2856         {
2857                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2858                 BasicAuth::setCurrentUserID();
2859                 $_SESSION['authenticated'] = false;
2860                 api_fr_photo_create_update('json');
2861         }
2862
2863         /**
2864          * Test the api_fr_photo_create_update() function with an album name.
2865          *
2866          * @return void
2867          */
2868         public function testApiFrPhotoCreateUpdateWithAlbum()
2869         {
2870                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2871                 $_REQUEST['album'] = 'album_name';
2872                 api_fr_photo_create_update('json');
2873         }
2874
2875         /**
2876          * Test the api_fr_photo_create_update() function with the update mode.
2877          *
2878          * @return void
2879          */
2880         public function testApiFrPhotoCreateUpdateWithUpdate()
2881         {
2882                 $this->markTestIncomplete('We need to create a dataset for this');
2883         }
2884
2885         /**
2886          * Test the api_fr_photo_create_update() function with an uploaded file.
2887          *
2888          * @return void
2889          */
2890         public function testApiFrPhotoCreateUpdateWithFile()
2891         {
2892                 $this->markTestIncomplete();
2893         }
2894
2895         /**
2896          * Test the api_fr_photo_detail() function.
2897          *
2898          * @return void
2899          */
2900         public function testApiFrPhotoDetail()
2901         {
2902                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2903                 api_fr_photo_detail('json');
2904         }
2905
2906         /**
2907          * Test the api_fr_photo_detail() function without an authenticated user.
2908          *
2909          * @return void
2910          */
2911         public function testApiFrPhotoDetailWithoutAuthenticatedUser()
2912         {
2913                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2914                 BasicAuth::setCurrentUserID();
2915                 $_SESSION['authenticated'] = false;
2916                 api_fr_photo_detail('json');
2917         }
2918
2919         /**
2920          * Test the api_fr_photo_detail() function with a photo ID.
2921          *
2922          * @return void
2923          */
2924         public function testApiFrPhotoDetailWithPhotoId()
2925         {
2926                 $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
2927                 $_REQUEST['photo_id'] = 1;
2928                 api_fr_photo_detail('json');
2929         }
2930
2931         /**
2932          * Test the api_fr_photo_detail() function with a correct photo ID.
2933          *
2934          * @return void
2935          */
2936         public function testApiFrPhotoDetailCorrectPhotoId()
2937         {
2938                 $this->markTestIncomplete('We need to create a dataset for this.');
2939         }
2940
2941         /**
2942          * Test the api_account_update_profile_image() function.
2943          *
2944          * @return void
2945          */
2946         public function testApiAccountUpdateProfileImage()
2947         {
2948                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2949                 api_account_update_profile_image('json');
2950         }
2951
2952         /**
2953          * Test the api_account_update_profile_image() function without an authenticated user.
2954          *
2955          * @return void
2956          */
2957         public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
2958         {
2959                 $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
2960                 BasicAuth::setCurrentUserID();
2961                 $_SESSION['authenticated'] = false;
2962                 api_account_update_profile_image('json');
2963         }
2964
2965         /**
2966          * Test the api_account_update_profile_image() function with an uploaded file.
2967          *
2968          * @return void
2969          */
2970         public function testApiAccountUpdateProfileImageWithUpload()
2971         {
2972                 $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
2973                 $this->markTestIncomplete();
2974         }
2975
2976
2977         /**
2978          * Test the api_account_update_profile() function.
2979          *
2980          * @return void
2981          */
2982         public function testApiAccountUpdateProfile()
2983         {
2984                 $_POST['name']        = 'new_name';
2985                 $_POST['description'] = 'new_description';
2986                 $result               = api_account_update_profile('json');
2987                 // We can't use assertSelfUser() here because the user object is missing some properties.
2988                 self::assertEquals($this->selfUser['id'], $result['user']['cid']);
2989                 self::assertEquals('DFRN', $result['user']['location']);
2990                 self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
2991                 self::assertEquals('new_name', $result['user']['name']);
2992                 self::assertEquals('new_description', $result['user']['description']);
2993         }
2994
2995         /**
2996          * Test the check_acl_input() function.
2997          *
2998          * @return void
2999          */
3000         public function testCheckAclInput()
3001         {
3002                 $result = check_acl_input('<aclstring>', BaseApi::getCurrentUserID());
3003                 // Where does this result come from?
3004                 self::assertEquals(1, $result);
3005         }
3006
3007         /**
3008          * Test the check_acl_input() function with an empty ACL string.
3009          *
3010          * @return void
3011          */
3012         public function testCheckAclInputWithEmptyAclString()
3013         {
3014                 $result = check_acl_input(' ', BaseApi::getCurrentUserID());
3015                 self::assertFalse($result);
3016         }
3017
3018         /**
3019          * Test the save_media_to_database() function.
3020          *
3021          * @return void
3022          */
3023         public function testSaveMediaToDatabase()
3024         {
3025                 $this->markTestIncomplete();
3026         }
3027
3028         /**
3029          * Test the post_photo_item() function.
3030          *
3031          * @return void
3032          */
3033         public function testPostPhotoItem()
3034         {
3035                 $this->markTestIncomplete();
3036         }
3037
3038         /**
3039          * Test the prepare_photo_data() function.
3040          *
3041          * @return void
3042          */
3043         public function testPreparePhotoData()
3044         {
3045                 $this->markTestIncomplete();
3046         }
3047
3048         /**
3049          * Test the api_share_as_retweet() function with a valid item.
3050          *
3051          * @return void
3052          */
3053         public function testApiShareAsRetweetWithValidItem()
3054         {
3055                 $this->markTestIncomplete();
3056         }
3057
3058         /**
3059          * Test the api_in_reply_to() function.
3060          *
3061          * @return void
3062          */
3063         public function testApiInReplyTo()
3064         {
3065                 $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
3066                 self::assertArrayHasKey('status_id', $result);
3067                 self::assertArrayHasKey('user_id', $result);
3068                 self::assertArrayHasKey('status_id_str', $result);
3069                 self::assertArrayHasKey('user_id_str', $result);
3070                 self::assertArrayHasKey('screen_name', $result);
3071         }
3072
3073         /**
3074          * Test the api_in_reply_to() function with a valid item.
3075          *
3076          * @return void
3077          */
3078         public function testApiInReplyToWithValidItem()
3079         {
3080                 $this->markTestIncomplete();
3081         }
3082
3083         /**
3084          * Test the api_clean_plain_items() function.
3085          *
3086          * @return void
3087          */
3088         public function testApiCleanPlainItems()
3089         {
3090                 $_REQUEST['include_entities'] = 'true';
3091                 $result                       = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
3092                 self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
3093         }
3094
3095         /**
3096          * Test the api_best_nickname() function with contacts.
3097          *
3098          * @return void
3099          */
3100         public function testApiBestNicknameWithContacts()
3101         {
3102                 $this->markTestIncomplete();
3103         }
3104
3105         /**
3106          * Test the api_friendica_group_show() function.
3107          *
3108          * @return void
3109          */
3110         public function testApiFriendicaGroupShow()
3111         {
3112                 $this->markTestIncomplete();
3113         }
3114
3115         /**
3116          * Test the api_friendica_group_delete() function.
3117          *
3118          * @return void
3119          */
3120         public function testApiFriendicaGroupDelete()
3121         {
3122                 $this->markTestIncomplete();
3123         }
3124
3125         /**
3126          * Test the api_lists_destroy() function.
3127          *
3128          * @return void
3129          */
3130         public function testApiListsDestroy()
3131         {
3132                 $this->markTestIncomplete();
3133         }
3134
3135         /**
3136          * Test the group_create() function.
3137          *
3138          * @return void
3139          */
3140         public function testGroupCreate()
3141         {
3142                 $this->markTestIncomplete();
3143         }
3144
3145         /**
3146          * Test the api_friendica_group_create() function.
3147          *
3148          * @return void
3149          */
3150         public function testApiFriendicaGroupCreate()
3151         {
3152                 $this->markTestIncomplete();
3153         }
3154
3155         /**
3156          * Test the api_lists_create() function.
3157          *
3158          * @return void
3159          */
3160         public function testApiListsCreate()
3161         {
3162                 $this->markTestIncomplete();
3163         }
3164
3165         /**
3166          * Test the api_friendica_group_update() function.
3167          *
3168          * @return void
3169          */
3170         public function testApiFriendicaGroupUpdate()
3171         {
3172                 $this->markTestIncomplete();
3173         }
3174
3175         /**
3176          * Test the api_lists_update() function.
3177          *
3178          * @return void
3179          */
3180         public function testApiListsUpdate()
3181         {
3182                 $this->markTestIncomplete();
3183         }
3184
3185         /**
3186          * Test the api_friendica_activity() function.
3187          *
3188          * @return void
3189          */
3190         public function testApiFriendicaActivity()
3191         {
3192                 $this->markTestIncomplete();
3193         }
3194
3195         /**
3196          * Test the api_friendica_notification_seen() function.
3197          *
3198          * @return void
3199          */
3200         public function testApiFriendicaNotificationSeen()
3201         {
3202                 $this->markTestIncomplete();
3203         }
3204
3205         /**
3206          * Test the api_friendica_direct_messages_setseen() function.
3207          *
3208          * @return void
3209          */
3210         public function testApiFriendicaDirectMessagesSetseen()
3211         {
3212                 $this->markTestIncomplete();
3213         }
3214
3215         /**
3216          * Test the api_friendica_direct_messages_search() function.
3217          *
3218          * @return void
3219          */
3220         public function testApiFriendicaDirectMessagesSearch()
3221         {
3222                 $this->markTestIncomplete();
3223         }
3224 }