]> git.mxchange.org Git - friendica.git/commitdiff
Adding unittest for empty setApp()
authorPhilipp Holzer <admin@philipp.info>
Tue, 5 Feb 2019 21:56:57 +0000 (22:56 +0100)
committerPhilipp Holzer <admin@philipp.info>
Tue, 5 Feb 2019 21:56:57 +0000 (22:56 +0100)
src/BaseObject.php
tests/src/BaseObjectTest.php

index 1a23408ba1e4a4ce24028363966cbb57ea89ee8e..4a6fa12d24b03ad18f4542114f1302d8a9e3573e 100644 (file)
@@ -28,7 +28,7 @@ class BaseObject
        public static function getApp()
        {
                if (empty(self::$app)) {
-                       throw new InternalServerErrorException('App isn\' initialized.');
+                       throw new InternalServerErrorException('App isn\'t initialized.');
                }
 
                return self::$app;
index 2dbf5580f61ffc7106afe6af302394ceb95d0bba..b2c73780a4499247544524f0f515636a1979f298 100644 (file)
@@ -31,10 +31,6 @@ class BaseObjectTest extends TestCase
         */
        protected function setUp()
        {
-               $this->setUpVfsDir();
-               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
-               $this->mockApp($this->root, $configMock);
-
                $this->baseObject = new BaseObject();
        }
 
@@ -44,6 +40,10 @@ class BaseObjectTest extends TestCase
         */
        public function testGetApp()
        {
+               $this->setUpVfsDir();
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
+
                $this->assertInstanceOf(App::class, $this->baseObject->getApp());
        }
 
@@ -53,7 +53,20 @@ class BaseObjectTest extends TestCase
         */
        public function testSetApp()
        {
+               $this->setUpVfsDir();
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
+
                $this->assertNull($this->baseObject->setApp($this->app));
                $this->assertEquals($this->app, $this->baseObject->getApp());
        }
+
+       /**
+        * Test the getApp() function without App
+        * @expectedException Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       public function testGetAppFailed()
+       {
+               BaseObject::getApp();
+       }
 }