]> git.mxchange.org Git - friendica.git/blobdiff - tests/ApiTest.php
Replace global $a with BaseObject::getApp()
[friendica.git] / tests / ApiTest.php
index 10b7849eb6314c38c06f5b338323f74e605c6f84..1854c996b0ffbd258e369775744431efca10912b 100644 (file)
@@ -5,12 +5,11 @@
 
 namespace Friendica\Test;
 
-use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
-use Friendica\Network\BadRequestException;
+use Friendica\Core\Protocol;
+use Friendica\Core\System;
 use Friendica\Network\HTTPException;
-use Friendica\Render\FriendicaSmarty;
 
 /**
  * Tests for the API functions.
@@ -26,31 +25,29 @@ class ApiTest extends DatabaseTest
         */
        protected function setUp()
        {
-               global $a;
                parent::setUp();
 
                // Reusable App object
-               $this->app = new App(__DIR__.'/../');
-               $a = $this->app;
+               $this->app = \Friendica\BaseObject::getApp();
 
                // User data that the test database is populated with
                $this->selfUser = [
                        'id' => 42,
                        'name' => 'Self contact',
                        'nick' => 'selfcontact',
-                       'nurl' => \Friendica\Core\System::baseUrl() . '/profile/selfcontact'
+                       'nurl' => 'http://localhost/profile/selfcontact'
                ];
                $this->friendUser = [
                        'id' => 44,
                        'name' => 'Friend contact',
                        'nick' => 'friendcontact',
-                       'nurl' => \Friendica\Core\System::baseUrl() . '/profile/friendcontact'
+                       'nurl' => 'http://localhost/profile/friendcontact'
                ];
                $this->otherUser = [
                        'id' => 43,
                        'name' => 'othercontact',
                        'nick' => 'othercontact',
-                       'nurl' => \Friendica\Core\System::baseUrl() . '/profile/othercontact'
+                       'nurl' => 'http://localhost/profile/othercontact'
                ];
 
                // User ID that we know is not in the database
@@ -635,7 +632,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiRssExtra()
        {
-               $user_info = ['url' => 'user_url', 'language' => 'en'];
+               $user_info = ['url' => 'user_url', 'lang' => 'en'];
                $result = api_rss_extra($this->app, [], $user_info);
                $this->assertEquals($user_info, $result['$user']);
                $this->assertEquals($user_info['url'], $result['$rss']['alternate']);
@@ -719,10 +716,10 @@ class ApiTest extends DatabaseTest
         */
        public function testApiGetUserWithCustomFrioSchema()
        {
-               PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
-               PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
-               PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456');
-               PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456');
+               $ret1 = PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
+               $ret2 = PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
+               $ret3 = PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456');
+               $ret4 = PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456');
                $user = api_get_user($this->app);
                $this->assertSelfUser($user);
                $this->assertEquals('123456', $user['profile_sidebar_fill_color']);
@@ -2164,7 +2161,7 @@ class ApiTest extends DatabaseTest
        public function testApiFormatItemsEmbededImages()
        {
                $this->assertEquals(
-                       'text ' . \Friendica\Core\System::baseUrl() . '/display/item_guid',
+                       'text ' . System::baseUrl() . '/display/item_guid',
                        api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
                );
        }
@@ -2337,7 +2334,9 @@ class ApiTest extends DatabaseTest
                                'coord' => '5 7',
                                'body' => '',
                                'verb' => '',
-                               'author-id' => 42,
+                               'author-id' => 43,
+                               'author-network' => Protocol::DFRN,
+                               'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
                ];
@@ -2358,7 +2357,9 @@ class ApiTest extends DatabaseTest
                                'coord' => '5 7',
                                'body' => '',
                                'verb' => '',
-                               'author-id' => 42,
+                               'author-id' => 43,
+                               'author-network' => Protocol::DFRN,
+                               'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
                ];
@@ -2631,7 +2632,7 @@ class ApiTest extends DatabaseTest
                $result = api_statusnet_config('json');
                $this->assertEquals('localhost', $result['config']['site']['server']);
                $this->assertEquals('default', $result['config']['site']['theme']);
-               $this->assertEquals(\Friendica\Core\System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+               $this->assertEquals(System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
                $this->assertTrue($result['config']['site']['fancy']);
                $this->assertEquals('en', $result['config']['site']['language']);
                $this->assertEquals('UTC', $result['config']['site']['timezone']);
@@ -3373,7 +3374,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiShareAsRetweet()
        {
-               $item = [];
+               $item = ['body' => ''];
                $result = api_share_as_retweet($item);
                $this->assertFalse($result);
        }
@@ -3413,7 +3414,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiInReplyTo()
        {
-               $result = api_in_reply_to([]);
+               $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
                $this->assertArrayHasKey('status_id', $result);
                $this->assertArrayHasKey('user_id', $result);
                $this->assertArrayHasKey('status_id_str', $result);