Refactor ConfigMockTrait to mocked ConfigCache

This commit is contained in:
Philipp Holzer 2019-02-07 20:44:03 +01:00
parent 38ac615ba0
commit cb791024e4
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
27 changed files with 244 additions and 193 deletions

View file

@ -5,7 +5,6 @@
namespace Friendica\Test;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Test\Util\AppMockTrait;
use Friendica\Test\Util\VFSTrait;
@ -13,8 +12,6 @@ use PHPUnit\Framework\TestCase;
/**
* Tests for the BaseObject class.
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class BaseObjectTest extends TestCase
{
@ -27,46 +24,29 @@ class BaseObjectTest extends TestCase
private $baseObject;
/**
* Create variables used in tests.
*/
protected function setUp()
{
$this->baseObject = new BaseObject();
}
/**
* Test the getApp() function.
* Test the setApp() and getApp() function.
* @return void
*/
public function testGetApp()
public function testGetSetApp()
{
$baseObject = new BaseObject();
$this->setUpVfsDir();
$configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
$this->mockApp($this->root, $configMock);
$this->assertInstanceOf(App::class, $this->baseObject->getApp());
}
/**
* Test the setApp() function.
* @return void
*/
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());
$this->assertNull($baseObject->setApp($this->app));
$this->assertEquals($this->app, $baseObject->getApp());
}
/**
* Test the getApp() function without App
* @expectedException Friendica\Network\HTTPException\InternalServerErrorException
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGetAppFailed()
{
BaseObject::getApp();
$baseObject = new BaseObject();
$baseObject->getApp();
}
}