]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
Add App\Router dependency injection to App
[friendica.git] / tests / include / ApiTest.php
index 2f8becc18cb8195b8beaf10808014e46b0c636d0..ecfe3e962153756ec9c70c30e3a972e699ffe8b8 100644 (file)
@@ -7,13 +7,13 @@ namespace Friendica\Test;
 
 use Friendica\App;
 use Friendica\Core\Config;
-use Friendica\Core\Config\Cache;
 use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Factory;
 use Friendica\Network\HTTPException;
 use Friendica\Util\BasePath;
+use Friendica\Util\Config\ConfigFileLoader;
 use Monolog\Handler\TestHandler;
 
 require_once __DIR__ . '/../../include/api.php';
@@ -31,20 +31,34 @@ class ApiTest extends DatabaseTest
         */
        protected $logOutput;
 
+       /** @var App */
+       protected $app;
+
+       /** @var array */
+       protected $selfUser;
+       /** @var array */
+       protected $friendUser;
+       /** @var array */
+       protected $otherUser;
+
+       protected $wrongUserId;
+
        /**
         * Create variables used by tests.
         */
        public function setUp()
        {
                $basePath = BasePath::create(dirname(__DIR__) . '/../');
-               $configLoader = new Cache\ConfigCacheLoader($basePath);
+               $mode = new App\Mode($basePath);
+               $router = new App\Router();
+               $configLoader = new ConfigFileLoader($basePath, $mode);
                $configCache = Factory\ConfigFactory::createCache($configLoader);
                $profiler = Factory\ProfilerFactory::create($configCache);
                Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
                $config = Factory\ConfigFactory::createConfig($configCache);
                Factory\ConfigFactory::createPConfig($configCache);
-               $logger = Factory\LoggerFactory::create('test', $config);
-               $this->app = new App($basePath, $config, $logger, $profiler, false);
+               $logger = Factory\LoggerFactory::create('test', $config, $profiler);
+               $this->app = new App($config, $mode, $router, $logger, $profiler, false);
 
                parent::setUp();
 
@@ -1271,31 +1285,30 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_status_show() function.
-        * @return void
         */
-       public function testApiStatusShow()
+       public function testApiStatusShowWithJson()
        {
-               $result = api_status_show('json');
+               $result = api_status_show('json', 1);
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_status_show() function with an XML result.
-        * @return void
         */
        public function testApiStatusShowWithXml()
        {
-               $result = api_status_show('xml');
+               $result = api_status_show('xml', 1);
                $this->assertXml($result, 'statuses');
        }
 
        /**
-        * Test the api_status_show() function with a raw result.
-        * @return void
+        * Test the api_get_last_status() function
         */
-       public function testApiStatusShowWithRaw()
+       public function testApiGetLastStatus()
        {
-               $this->assertStatus(api_status_show('raw'));
+               $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
+
+               $this->assertNotNull($item);
        }
 
        /**