mirror of
https://github.com/friendica/friendica
synced 2025-04-27 05:50:10 +00:00
Remove BasePath dependency from App\Mode
This commit is contained in:
parent
dd6d96d048
commit
a6fb683bcd
3 changed files with 13 additions and 27 deletions
|
@ -57,7 +57,6 @@ class ModeTest extends MockedTest
|
|||
|
||||
$this->setUpVfsDir();
|
||||
|
||||
$this->basePathMock = Mockery::mock(BasePath::class);
|
||||
$this->databaseMock = Mockery::mock(Database::class);
|
||||
$this->configCacheMock = Mockery::mock(Cache::class);
|
||||
}
|
||||
|
@ -71,15 +70,13 @@ class ModeTest extends MockedTest
|
|||
|
||||
public function testWithoutConfig()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
self::assertTrue($this->root->hasChild('config/local.config.php'));
|
||||
|
||||
$this->delConfigFile('local.config.php');
|
||||
|
||||
self::assertFalse($this->root->hasChild('config/local.config.php'));
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$mode = (new Mode())->determine($this->root->url(), $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertTrue($mode->isInstall());
|
||||
self::assertFalse($mode->isNormal());
|
||||
|
@ -89,11 +86,9 @@ class ModeTest extends MockedTest
|
|||
|
||||
public function testWithoutDatabase()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(false)->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$mode = (new Mode())->determine($this->root->url(), $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertFalse($mode->isNormal());
|
||||
self::assertTrue($mode->isInstall());
|
||||
|
@ -104,13 +99,11 @@ class ModeTest extends MockedTest
|
|||
|
||||
public function testWithMaintenanceMode()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(true)->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$mode = (new Mode())->determine($this->root->url(), $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertFalse($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
@ -120,13 +113,11 @@ class ModeTest extends MockedTest
|
|||
|
||||
public function testNormalMode()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(false)->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$mode = (new Mode())->determine($this->root->url(), $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertTrue($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
@ -139,13 +130,11 @@ class ModeTest extends MockedTest
|
|||
*/
|
||||
public function testDisabledMaintenance()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(false)->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$mode = (new Mode())->determine($this->root->url(), $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertTrue($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
@ -158,11 +147,9 @@ class ModeTest extends MockedTest
|
|||
*/
|
||||
public function testImmutable()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn(null)->once();
|
||||
|
||||
$mode = new Mode();
|
||||
|
||||
$modeNew = $mode->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
$modeNew = $mode->determine('', $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertNotSame($modeNew, $mode);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue