-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from stekycz/improvement/tests
Improvement/tests
- Loading branch information
Showing
22 changed files
with
149 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
tests export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
/** | ||
* Test: stekycz\Cronner\DI\CronnerExtension | ||
* | ||
* @testCase stekycz\Cronner\tests\DI\CronnerExtensionTest | ||
*/ | ||
|
||
namespace stekycz\Cronner\tests\DI; | ||
|
||
use Nette; | ||
use stekycz\Cronner\DI\CronnerExtension; | ||
use Tester\Assert; | ||
|
||
|
||
|
||
require_once(__DIR__ . "/../bootstrap.php"); | ||
|
||
/** | ||
* @author Martin Štekl <[email protected]> | ||
*/ | ||
class CronnerExtensionTest extends \TestCase | ||
{ | ||
|
||
public function testDefaultConfiguration() | ||
{ | ||
$compiler = new CompilerMock(); | ||
$compiler->addExtension('cronner', $cronner = new CronnerExtension()); | ||
|
||
$compiler->config = array(); | ||
|
||
$cronner->loadConfiguration(); | ||
|
||
$timestampStorage = $compiler->getContainerBuilder()->getDefinition('cronner.timestampStorage'); | ||
$criticalSection = $compiler->getContainerBuilder()->getDefinition('cronner.criticalSection'); | ||
$runner = $compiler->getContainerBuilder()->getDefinition('cronner.runner'); | ||
|
||
Assert::same('stekycz\Cronner\TimestampStorage\FileStorage', $timestampStorage->getClass()); | ||
Assert::same('stekycz\Cronner\CriticalSection', $criticalSection->getClass()); | ||
Assert::same('stekycz\Cronner\Cronner', $runner->getClass()); | ||
} | ||
|
||
|
||
|
||
public function testCompleteConfiguration() | ||
{ | ||
$compiler = new CompilerMock(); | ||
$compiler->addExtension('cronner', $cronner = new CronnerExtension()); | ||
|
||
$compiler->config = array( | ||
'cronner' => array( | ||
'timestampStorage' => new Nette\DI\Statement('stekycz\Cronner\TimestampStorage\DummyStorage', array(TEMP_DIR . '/cronner')), | ||
'maxExecutionTime' => 120, | ||
'criticalSectionTempDir' => '%tempDir%/cronner', | ||
) | ||
); | ||
|
||
$cronner->loadConfiguration(); | ||
|
||
$timestampStorage = $compiler->getContainerBuilder()->getDefinition('cronner.timestampStorage'); | ||
$criticalSection = $compiler->getContainerBuilder()->getDefinition('cronner.criticalSection'); | ||
$runner = $compiler->getContainerBuilder()->getDefinition('cronner.runner'); | ||
|
||
Assert::same('stekycz\Cronner\TimestampStorage\DummyStorage', $timestampStorage->getClass()); | ||
Assert::same('stekycz\Cronner\CriticalSection', $criticalSection->getClass()); | ||
Assert::same('stekycz\Cronner\Cronner', $runner->getClass()); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
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()); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.