]> git.mxchange.org Git - friendica.git/blobdiff - tests/ApiTest.php
Bugfixings
[friendica.git] / tests / ApiTest.php
index 4e272901955b6197f388aec13d14b4906a302c85..c509c7d2a4233b3ea69ab5b7a6d823246ae357da 100644 (file)
@@ -5,12 +5,15 @@
 
 namespace Friendica\Test;
 
+use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Network\HTTPException;
 
+require_once __DIR__ . '/../include/api.php';
+
 /**
  * Tests for the API functions.
  *
@@ -19,16 +22,14 @@ use Friendica\Network\HTTPException;
  */
 class ApiTest extends DatabaseTest
 {
-
        /**
         * Create variables used by tests.
         */
-       protected function setUp()
+       public function setUp()
        {
                parent::setUp();
 
-               // Reusable App object
-               $this->app = \Friendica\BaseObject::getApp();
+               $this->app = BaseObject::getApp();
 
                // User data that the test database is populated with
                $this->selfUser = [
@@ -60,6 +61,10 @@ class ApiTest extends DatabaseTest
                        'uid' => $this->selfUser['id']
                ];
 
+               Config::set('system', 'url', 'http://localhost');
+               Config::set('system', 'hostname', 'localhost');
+               Config::set('system', 'worker_dont_fork', true);
+
                // Default config
                Config::set('config', 'hostname', 'localhost');
                Config::set('system', 'throttle_limit_day', 100);
@@ -68,6 +73,17 @@ class ApiTest extends DatabaseTest
                Config::set('system', 'theme', 'system_theme');
        }
 
+       /**
+        * Cleanup variables used by tests.
+        */
+       protected function tearDown()
+       {
+               parent::tearDown();
+
+               $this->app->argc = 1;
+               $this->app->argv = ['home'];
+       }
+
        /**
         * Assert that an user array contains expected keys.
         * @param array $user User array
@@ -3363,7 +3379,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiFriendicaRemoteauthWithCorrectUrl()
        {
-               $this->markTestIncomplete("We can't use an assertion here because of goaway().");
+               $this->markTestIncomplete("We can't use an assertion here because of App->redirect().");
                $_GET['url'] = 'url';
                $_GET['c_url'] = $this->selfUser['nurl'];
                api_friendica_remoteauth();
@@ -3375,7 +3391,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);
        }