Skip to content
This repository has been archived by the owner on Aug 12, 2019. It is now read-only.

Commit

Permalink
fix extension registered on production
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikulas committed Feb 15, 2015
1 parent d40535c commit 5411e7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/NetteDI/QueryPanelExtension.php
Expand Up @@ -12,7 +12,7 @@ class QueryPanelExtension extends CompilerExtension

public function loadConfiguration()
{
if (class_exists('Tracy\Debugger') && Debugger::$productionMode === FALSE)
if (!class_exists('Tracy\Debugger') || Debugger::$productionMode === TRUE)
{
return;
}
Expand Down
18 changes: 15 additions & 3 deletions tests/cases/unit/QueryPanelExtension.phpt
Expand Up @@ -9,6 +9,7 @@ use Nextras\TracyQueryPanel\Bridges\NetteDI\QueryPanelExtension;
use Nextras\TracyQueryPanel\QueryPanel;
use Nette;
use Tester\Assert;
use Tracy\Debugger;


require_once __DIR__ . '/../../bootstrap.php';
Expand All @@ -18,22 +19,33 @@ class QueryPanelExtensionTest extends TestCase
{

/**
* @param bool $debugMode
* @return Nette\DI\Container
*/
protected function createContainer()
protected function createContainer($debugMode)
{
$config = new Nette\Configurator();
$config->setTempDirectory(TEMP_DIR);
$config->setDebugMode($debugMode);
Debugger::$productionMode = !$debugMode;
QueryPanelExtension::register($config);
return $config->createContainer();
}

public function testFunctional()
public function testRegisteredOnDebug()
{
$dic = $this->createContainer();
$dic = $this->createContainer(TRUE);
Assert::true($dic->getService('queryPanel.panel') instanceof QueryPanel);
}

public function testSkippedOnDebug()
{
$dic = $this->createContainer(FALSE);
Assert::exception(function() use ($dic) {
$dic->getService('queryPanel.panel');
}, 'Nette\DI\MissingServiceException');
}

}

$test = new QueryPanelExtensionTest();
Expand Down

0 comments on commit 5411e7a

Please sign in to comment.