mirror of
https://github.com/friendica/friendica
synced 2025-04-28 03:50:17 +00:00
Refactor ConfigMockTrait to mocked ConfigCache
This commit is contained in:
parent
38ac615ba0
commit
cb791024e4
27 changed files with 244 additions and 193 deletions
|
@ -3,24 +3,19 @@
|
|||
namespace Friendica\Test\src\App;
|
||||
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\ConfigMockTrait;
|
||||
use Friendica\Test\Util\DBAMockTrait;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class ModeTest extends MockedTest
|
||||
{
|
||||
use VFSTrait;
|
||||
use DBAMockTrait;
|
||||
use ConfigMockTrait;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpVfsDir();
|
||||
}
|
||||
|
@ -50,6 +45,10 @@ class ModeTest extends MockedTest
|
|||
$this->assertFalse($mode->has(Mode::LOCALCONFIGPRESENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testWithoutDatabase()
|
||||
{
|
||||
$this->mockConnected(false, 1);
|
||||
|
@ -64,6 +63,10 @@ class ModeTest extends MockedTest
|
|||
$this->assertFalse($mode->has(Mode::DBAVAILABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testWithoutDatabaseSetup()
|
||||
{
|
||||
$this->mockConnected(true, 1);
|
||||
|
@ -78,11 +81,28 @@ class ModeTest extends MockedTest
|
|||
$this->assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testWithMaintenanceMode()
|
||||
{
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockFetchFirst('SHOW TABLES LIKE \'config\'', true, 1);
|
||||
$this->mockConfigGet('system', 'maintenance', true, 1);
|
||||
|
||||
$config = \Mockery::mock('Friendica\Core\Config\ConfigCache');
|
||||
$config
|
||||
->shouldReceive('get')
|
||||
->with('system', 'maintenance', null)
|
||||
->andReturn(true)
|
||||
->once();
|
||||
// Initialize empty Config
|
||||
Config::init($config);
|
||||
$configAdapter = \Mockery::mock('Friendica\Core\Config\IConfigAdapter');
|
||||
$configAdapter
|
||||
->shouldReceive('isConnected')
|
||||
->andReturn(false);
|
||||
Config::setAdapter($configAdapter);
|
||||
|
||||
$mode = new Mode($this->root->url());
|
||||
$mode->determine();
|
||||
|
@ -94,11 +114,28 @@ class ModeTest extends MockedTest
|
|||
$this->assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testNormalMode()
|
||||
{
|
||||
$this->mockConnected(true, 1);
|
||||
$this->mockFetchFirst('SHOW TABLES LIKE \'config\'', true, 1);
|
||||
$this->mockConfigGet('system', 'maintenance', false, 1);
|
||||
|
||||
$config = \Mockery::mock('Friendica\Core\Config\ConfigCache');
|
||||
$config
|
||||
->shouldReceive('get')
|
||||
->with('system', 'maintenance', null)
|
||||
->andReturn(false)
|
||||
->once();
|
||||
// Initialize empty Config
|
||||
Config::init($config);
|
||||
$configAdapter = \Mockery::mock('Friendica\Core\Config\IConfigAdapter');
|
||||
$configAdapter
|
||||
->shouldReceive('isConnected')
|
||||
->andReturn(false);
|
||||
Config::setAdapter($configAdapter);
|
||||
|
||||
$mode = new Mode($this->root->url());
|
||||
$mode->determine();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue