Adding unittest for empty setApp()
This commit is contained in:
parent
b79bd63231
commit
ef16e1a037
|
@ -28,7 +28,7 @@ class BaseObject
|
||||||
public static function getApp()
|
public static function getApp()
|
||||||
{
|
{
|
||||||
if (empty(self::$app)) {
|
if (empty(self::$app)) {
|
||||||
throw new InternalServerErrorException('App isn\' initialized.');
|
throw new InternalServerErrorException('App isn\'t initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$app;
|
return self::$app;
|
||||||
|
|
|
@ -31,10 +31,6 @@ class BaseObjectTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
|
||||||
$configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
|
|
||||||
$this->mockApp($this->root, $configMock);
|
|
||||||
|
|
||||||
$this->baseObject = new BaseObject();
|
$this->baseObject = new BaseObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +40,10 @@ class BaseObjectTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetApp()
|
public function testGetApp()
|
||||||
{
|
{
|
||||||
|
$this->setUpVfsDir();
|
||||||
|
$configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
|
||||||
|
$this->mockApp($this->root, $configMock);
|
||||||
|
|
||||||
$this->assertInstanceOf(App::class, $this->baseObject->getApp());
|
$this->assertInstanceOf(App::class, $this->baseObject->getApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,20 @@ class BaseObjectTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testSetApp()
|
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->assertNull($this->baseObject->setApp($this->app));
|
||||||
$this->assertEquals($this->app, $this->baseObject->getApp());
|
$this->assertEquals($this->app, $this->baseObject->getApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the getApp() function without App
|
||||||
|
* @expectedException Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
*/
|
||||||
|
public function testGetAppFailed()
|
||||||
|
{
|
||||||
|
BaseObject::getApp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user