Do not create alias mock for Icinga\Application\Icinga

refs #4639
This commit is contained in:
Johannes Meyer 2014-04-14 08:31:46 +02:00
parent 4c8428423e
commit a844d33735
2 changed files with 8 additions and 9 deletions

View File

@ -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');
} }

View File

@ -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; });
} }
/** /**