mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
parent
4c8428423e
commit
a844d33735
@ -59,12 +59,14 @@ class Icinga
|
|||||||
/**
|
/**
|
||||||
* Setter for an application environment
|
* Setter for an application environment
|
||||||
*
|
*
|
||||||
* @param ApplicationBootstrap $app
|
* @param ApplicationBootstrap $app
|
||||||
|
* @param bool $overwrite
|
||||||
|
*
|
||||||
* @throws ProgrammingError
|
* @throws ProgrammingError
|
||||||
*/
|
*/
|
||||||
public static function setApp(ApplicationBootstrap $app)
|
public static function setApp(ApplicationBootstrap $app, $overwrite = false)
|
||||||
{
|
{
|
||||||
if (self::$app !== null) {
|
if (self::$app !== null && !$overwrite) {
|
||||||
throw new ProgrammingError('Cannot start Icinga twice');
|
throw new ProgrammingError('Cannot start Icinga twice');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace Icinga\Test {
|
|||||||
use \Mockery;
|
use \Mockery;
|
||||||
use \Zend_Config;
|
use \Zend_Config;
|
||||||
use \Zend_Test_PHPUnit_ControllerTestCase;
|
use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Util\DateTimeFactory;
|
use Icinga\Util\DateTimeFactory;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Data\Db\Connection;
|
use Icinga\Data\Db\Connection;
|
||||||
@ -146,10 +147,7 @@ namespace Icinga\Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup mock object for Icinga\Application\Icinga
|
* Setup mock object for the application's bootstrap
|
||||||
*
|
|
||||||
* Once done, the original class can never be loaded anymore though one should still be able
|
|
||||||
* to access its properties/methods not covered by any expectations by using the mock object.
|
|
||||||
*/
|
*/
|
||||||
protected function setupIcingaMock()
|
protected function setupIcingaMock()
|
||||||
{
|
{
|
||||||
@ -164,8 +162,7 @@ namespace Icinga\Test {
|
|||||||
}
|
}
|
||||||
)->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
|
)->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
|
||||||
|
|
||||||
Mockery::mock('alias:Icinga\Application\Icinga')
|
Icinga::setApp($bootstrapMock, true);
|
||||||
->shouldReceive('app')->andReturnUsing(function () use ($bootstrapMock) { return $bootstrapMock; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user