From cd89c2a65ae70b528b1c614f268c8ec8906828ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20S=CC=8Ctekl?= Date: Thu, 5 Mar 2015 22:09:24 +0100 Subject: [PATCH] Fixed CronnerExtension tests --- Cronner/DI/CronnerExtension.php | 6 -- tests/CronnerTests/DI/CronnerExtension.phpt | 93 +++++++-------------- 2 files changed, 29 insertions(+), 70 deletions(-) diff --git a/Cronner/DI/CronnerExtension.php b/Cronner/DI/CronnerExtension.php index efab144..e4001ca 100644 --- a/Cronner/DI/CronnerExtension.php +++ b/Cronner/DI/CronnerExtension.php @@ -9,12 +9,6 @@ use Nette\Utils\Json; use Nette\Utils\Validators; -if (!class_exists('Nette\DI\CompilerExtension')) { - class_alias('Nette\Config\CompilerExtension', 'Nette\DI\CompilerExtension'); - class_alias('Nette\Config\Configurator', 'Nette\Configurator'); - class_alias('Nette\Config\Compiler', 'Nette\DI\Compiler'); -} - /** diff --git a/tests/CronnerTests/DI/CronnerExtension.phpt b/tests/CronnerTests/DI/CronnerExtension.phpt index fd406a9..06490c5 100644 --- a/tests/CronnerTests/DI/CronnerExtension.phpt +++ b/tests/CronnerTests/DI/CronnerExtension.phpt @@ -22,14 +22,34 @@ require_once(__DIR__ . "/../bootstrap.php"); class CronnerExtensionTest extends \TestCase { - public function testDefaultConfiguration() + /** + * @var Nette\DI\Compiler + */ + private $compiler; + + + + protected function setUp() { - $compiler = new CompilerMock(); - $compiler->addExtension('cronner', $cronner = new CronnerExtension()); + parent::setUp(); + $builder = new Nette\DI\ContainerBuilder(); + $builder->parameters = array( + 'appDir' => __DIR__ . '/../..', + 'wwwDir' => __DIR__ . '/../..', + 'tempDir' => TEMP_DIR, + 'debugMode' => FALSE, + 'productionMode' => TRUE, + ); + $this->compiler = new Nette\DI\Compiler($builder); + $this->compiler->addExtension('cronner', new CronnerExtension()); + } + - $compiler->config = array(); - $cronner->loadConfiguration(); + public function testDefaultConfiguration() + { + $compiler = $this->compiler; + $compiler->compile(array()); $timestampStorage = $compiler->getContainerBuilder()->getDefinition('cronner.timestampStorage'); $criticalSection = $compiler->getContainerBuilder()->getDefinition('cronner.criticalSection'); @@ -44,18 +64,14 @@ class CronnerExtensionTest extends \TestCase public function testCompleteConfiguration() { - $compiler = new CompilerMock(); - $compiler->addExtension('cronner', $cronner = new CronnerExtension()); - - $compiler->config = array( + $compiler = $this->compiler; + $compiler->compile(array( 'cronner' => array( - 'timestampStorage' => new Nette\DI\Statement('stekycz\Cronner\TimestampStorage\DummyStorage', array(TEMP_DIR . '/cronner')), + 'timestampStorage' => new Nette\DI\Statement('stekycz\Cronner\TimestampStorage\DummyStorage'), 'maxExecutionTime' => 120, 'criticalSectionTempDir' => '%tempDir%/cronner', ) - ); - - $cronner->loadConfiguration(); + )); $timestampStorage = $compiler->getContainerBuilder()->getDefinition('cronner.timestampStorage'); $criticalSection = $compiler->getContainerBuilder()->getDefinition('cronner.criticalSection'); @@ -70,55 +86,4 @@ class CronnerExtensionTest extends \TestCase -class CompilerMock extends Nette\DI\Compiler -{ - - /** - * @var Nette\DI\ContainerBuilder - */ - public $containerBuilder; - - /** - * @var array - */ - public $config = array(); - - - - public function __construct() - { - $this->containerBuilder = new Nette\DI\ContainerBuilder(); - $this->containerBuilder->parameters = array( - 'appDir' => __DIR__ . '/../..', - 'wwwDir' => __DIR__ . '/../..', - 'tempDir' => TEMP_DIR, - 'debugMode' => FALSE, - 'productionMode' => TRUE, - ); - } - - - - /** - * @return array - */ - public function getConfig() - { - return $this->config; - } - - - - /** - * @return Nette\DI\ContainerBuilder - */ - public function getContainerBuilder() - { - return $this->containerBuilder; - } - -} - - - run(new CronnerExtensionTest());