Skip to content

Commit

Permalink
isConsole check
Browse files Browse the repository at this point in the history
  • Loading branch information
hummer2k committed Jun 20, 2015
1 parent 2705ad9 commit 5b79dee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ConVarnish/Module.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace ConVarnish;

use Zend\Console\Console;
use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent;

Expand Down Expand Up @@ -34,6 +35,9 @@ public function getServiceConfig()
*/
public function onBootstrap(MvcEvent $e)
{
if (Console::isConsole()) {
return;
}
/* @var $application Application */
$application = $e->getApplication();
$serviceManager = $application->getServiceManager();
Expand Down
5 changes: 5 additions & 0 deletions tests/ConVarnishTest/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ConVarnishTest;

use ConVarnish\Module;
use Zend\Console\Console;
use Zend\EventManager\EventManager;
use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent;
Expand Down Expand Up @@ -34,7 +35,11 @@ public function testOnBootstrap()
$em = new EventManager();
$application->setEventManager($em);
$event->setApplication($application);

$isConsole = Console::isConsole();
Console::overrideIsConsole(false);
$this->module->onBootstrap($event);
Console::overrideIsConsole($isConsole);

$this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH));
$this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER));
Expand Down

0 comments on commit 5b79dee

Please sign in to comment.