X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fsrc%2FBaseObjectTest.php;h=cb980b47e90698639f71a1381ba7c19b046e2db5;hb=0115329dc6a21366905fca494874c77269b507d5;hp=7b9ff3aa15875caf2c583dc5151498f81b47792a;hpb=6150c2fa9cbb15efbdd1432a295ece64086959ac;p=friendica.git diff --git a/tests/src/BaseObjectTest.php b/tests/src/BaseObjectTest.php index 7b9ff3aa15..cb980b47e9 100644 --- a/tests/src/BaseObjectTest.php +++ b/tests/src/BaseObjectTest.php @@ -3,11 +3,11 @@ * BaseObjectTest class. */ -namespace Friendica\Test; +namespace Friendica\Test\src; -use Friendica\App; use Friendica\BaseObject; -use Friendica\Util\LoggerFactory; +use Friendica\Test\Util\AppMockTrait; +use Friendica\Test\Util\VFSTrait; use PHPUnit\Framework\TestCase; /** @@ -15,34 +15,36 @@ use PHPUnit\Framework\TestCase; */ class BaseObjectTest extends TestCase { + use VFSTrait; + use AppMockTrait; /** - * Create variables used in tests. + * @var BaseObject */ - protected function setUp() - { - $this->baseObject = new BaseObject(); - } + private $baseObject; /** - * Test the getApp() function. + * Test the setApp() and getApp() function. * @return void */ - public function testGetApp() + public function testGetSetApp() { - $this->assertInstanceOf(App::class, $this->baseObject->getApp()); + $baseObject = new BaseObject(); + $this->setUpVfsDir(); + $this->mockApp($this->root); + + $baseObject->setApp($this->app); + $this->assertEquals($this->app, $baseObject->getApp()); } /** - * Test the setApp() function. - * @return void + * Test the getApp() function without App + * @expectedException Friendica\Network\HTTPException\InternalServerErrorException + * @runInSeparateProcess + * @preserveGlobalState disabled */ - public function testSetApp() + public function testGetAppFailed() { - $logger = $logger = LoggerFactory::create('test'); - $app = new App(__DIR__ . '/../../', $logger); - LoggerFactory::enableTest($logger); - $this->assertNull($this->baseObject->setApp($app)); - $this->assertEquals($app, $this->baseObject->getApp()); + BaseObject::getApp(); } }