]> git.mxchange.org Git - friendica.git/blobdiff - tests/ApiTest.php
Merge pull request #5862 from nupplaphil/rename_App_Methods
[friendica.git] / tests / ApiTest.php
index a56290198398bb665de93caf9248a26881165488..11c61f9fbb40a46990838ddbd6534d58ad4e1b6b 100644 (file)
@@ -5,11 +5,12 @@
 
 namespace Friendica\Test;
 
+use Friendica\BaseObject;
 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.
@@ -23,10 +24,12 @@ class ApiTest extends DatabaseTest
        /**
         * Create variables used by tests.
         */
-       protected function setUp()
+       public function setUp()
        {
                parent::setUp();
 
+               require_once __DIR__.'/../include/api.php';
+
                // User data that the test database is populated with
                $this->selfUser = [
                        'id' => 42,
@@ -56,6 +59,24 @@ class ApiTest extends DatabaseTest
                        'authenticated' => true,
                        'uid' => $this->selfUser['id']
                ];
+
+               // Default config
+               Config::set('config', 'hostname', 'localhost');
+               Config::set('system', 'throttle_limit_day', 100);
+               Config::set('system', 'throttle_limit_week', 100);
+               Config::set('system', 'throttle_limit_month', 100);
+               Config::set('system', 'theme', 'system_theme');
+       }
+
+       /**
+        * Cleanup variables used by tests.
+        */
+       protected function tearDown()
+       {
+               parent::tearDown();
+
+               $this->app->argc = 1;
+               $this->app->argv = ['home'];
        }
 
        /**
@@ -706,10 +727,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']);
@@ -1192,7 +1213,8 @@ class ApiTest extends DatabaseTest
        {
                $_FILES = [
                        'media' => [
-                               'id' => 666
+                               'id' => 666,
+                               'tmp_name' => 'tmp_name'
                        ]
                ];
                api_media_upload();
@@ -2151,7 +2173,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')
                );
        }
@@ -2325,7 +2347,7 @@ class ApiTest extends DatabaseTest
                                'body' => '',
                                'verb' => '',
                                'author-id' => 43,
-                               'author-network' => \Friendica\Core\Protocol::DFRN,
+                               'author-network' => Protocol::DFRN,
                                'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
@@ -2348,7 +2370,7 @@ class ApiTest extends DatabaseTest
                                'body' => '',
                                'verb' => '',
                                'author-id' => 43,
-                               'author-network' => \Friendica\Core\Protocol::DFRN,
+                               'author-network' => Protocol::DFRN,
                                'author-link' => 'http://localhost/profile/othercontact',
                                'plink' => '',
                        ]
@@ -2622,7 +2644,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']);
@@ -3364,7 +3386,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiShareAsRetweet()
        {
-               $item = ['body' => ''];
+               $item = ['body' => '', 'author-id' => 1, 'owner-id' => 1];
                $result = api_share_as_retweet($item);
                $this->assertFalse($result);
        }