Permalink
Browse files

Merge pull request #447 from Behat/optimization/subject-to-specification

Renamed Subject to Specification
  • Loading branch information...
2 parents 6a4f23f + 67c8c75 commit df94075febd7a6f5259c14e2911893ca9e3d6704 @everzet everzet committed Feb 11, 2014
Showing with 334 additions and 304 deletions.
  1. +2 −3 src/Behat/Behat/ApplicationFactory.php
  2. +19 −18 src/Behat/Behat/Gherkin/ServiceContainer/GherkinExtension.php
  3. +5 −5 src/Behat/Behat/Gherkin/{Subject → Specification}/LazyFeatureIterator.php
  4. +7 −7 src/Behat/Behat/Gherkin/{Subject → Specification}/Locator/FilesystemFeatureLocator.php
  5. +12 −7 src/Behat/Behat/Tester/Cli/ExerciseController.php
  6. +20 −8 src/Behat/Behat/Tester/FeatureTester.php
  7. +5 −5 src/Behat/Behat/Tester/ServiceContainer/TesterExtension.php
  8. +1 −1 src/Behat/Behat/Tester/StepContainerTester.php
  9. +21 −20 ...at/Testwork/{Subject/GroupedSubjectIterator.php → Specification/GroupedSpecificationIterator.php}
  10. +37 −0 src/Behat/Testwork/Specification/Locator/SpecificationLocator.php
  11. +4 −4 src/Behat/Testwork/{Subject/EmptySubjectIterator.php → Specification/NoSpecificationsIterator.php}
  12. +12 −12 ...erviceContainer/SubjectExtension.php → Specification/ServiceContainer/SpecificationExtension.php}
  13. +13 −6 src/Behat/Testwork/{Subject/ArraySubjectIterator.php → Specification/SpecificationArrayIterator.php}
  14. +75 −0 src/Behat/Testwork/Specification/SpecificationFinder.php
  15. +5 −5 src/Behat/Testwork/{Subject/SubjectIterator.php → Specification/SpecificationIterator.php}
  16. +0 −37 src/Behat/Testwork/Subject/Locator/SubjectLocator.php
  17. +0 −75 src/Behat/Testwork/Subject/SubjectFinder.php
  18. +34 −29 src/Behat/Testwork/Tester/Cli/ExerciseController.php
  19. +7 −7 src/Behat/Testwork/Tester/Exercise.php
  20. +3 −3 src/Behat/Testwork/Tester/HookableSuiteTester.php
  21. +3 −3 src/Behat/Testwork/Tester/Result/HookedSuiteTestResult.php
  22. +8 −8 src/Behat/Testwork/Tester/Result/SuiteTestResult.php
  23. +7 −7 src/Behat/Testwork/Tester/ServiceContainer/TesterExtension.php
  24. +3 −3 src/Behat/Testwork/Tester/{SubjectTester.php → SpecificationTester.php}
  25. +21 −21 src/Behat/Testwork/Tester/SuiteTester.php
  26. +10 −10 tests/Behat/Tests/Testwork/Subject/GroupedSubjectIteratorTest.php
@@ -29,7 +29,7 @@
use Behat\Testwork\Filesystem\ServiceContainer\FilesystemExtension;
use Behat\Testwork\ServiceContainer\Extension;
use Behat\Testwork\ServiceContainer\ServiceProcessor;
-use Behat\Testwork\Subject\ServiceContainer\SubjectExtension;
+use Behat\Testwork\Specification\ServiceContainer\SpecificationExtension;
use Behat\Testwork\Suite\ServiceContainer\SuiteExtension;
/**
@@ -76,11 +76,10 @@ protected function getDefaultExtensions()
new CallExtension($processor),
new SuiteExtension($processor),
new EnvironmentExtension($processor),
- new SubjectExtension($processor),
+ new SpecificationExtension($processor),
new EventDispatcherExtension($processor),
new FilesystemExtension($processor),
new ExceptionExtension($processor),
-
// Behat extensions
new AutoloaderExtension($processor),
new TranslatorExtension($processor),
@@ -17,7 +17,7 @@
use Behat\Testwork\ServiceContainer\Extension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Behat\Testwork\ServiceContainer\ServiceProcessor;
-use Behat\Testwork\Subject\ServiceContainer\SubjectExtension;
+use Behat\Testwork\Specification\ServiceContainer\SpecificationExtension;
use Behat\Testwork\Suite\ServiceContainer\SuiteExtension;
use ReflectionClass;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
@@ -83,19 +83,19 @@ public function configure(ArrayNodeDefinition $builder)
$builder
->addDefaultsIfNotSet()
->children()
- ->scalarNode('cache')
- ->defaultValue(
- is_writable(sys_get_temp_dir())
- ? sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'gherkin_cache'
- : null
- )
- ->end()
- ->arrayNode('filters')
- ->defaultValue(array())
- ->useAttributeAsKey('name')
- ->prototype('scalar')
- ->end()
- ->end()
+ ->scalarNode('cache')
+ ->defaultValue(
+ is_writable(sys_get_temp_dir())
+ ? sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'gherkin_cache'
+ : null
+ )
+ ->end()
+ ->arrayNode('filters')
+ ->defaultValue(array())
+ ->useAttributeAsKey('name')
+ ->prototype('scalar')
+ ->end()
+ ->end()
->end();
}
@@ -134,7 +134,8 @@ protected function loadParameters(ContainerBuilder $container)
$container->setParameter('gherkin.paths.lib', $this->getLibPath());
$container->setParameter('gherkin.paths.i18n', '%gherkin.paths.lib%/i18n.php');
$container->setParameter(
- 'suite.generic.default_settings', array(
+ 'suite.generic.default_settings',
+ array(
'paths' => array('%paths.base%/features'),
'contexts' => array('FeatureContext')
)
@@ -290,12 +291,12 @@ protected function loadSuiteWithPathsSetup(ContainerBuilder $container)
*/
protected function loadFilesystemFeatureLocator(ContainerBuilder $container)
{
- $definition = new Definition('Behat\Behat\Gherkin\Subject\Locator\FilesystemFeatureLocator', array(
+ $definition = new Definition('Behat\Behat\Gherkin\Specification\Locator\FilesystemFeatureLocator', array(
new Reference(self::MANAGER_ID),
'%paths.base%'
));
- $definition->addTag(SubjectExtension::LOCATOR_TAG, array('priority' => 50));
- $container->setDefinition(SubjectExtension::LOCATOR_TAG . '.filesystem_feature', $definition);
+ $definition->addTag(SpecificationExtension::LOCATOR_TAG, array('priority' => 50));
+ $container->setDefinition(SpecificationExtension::LOCATOR_TAG . '.filesystem_feature', $definition);
}
/**
@@ -8,20 +8,20 @@
* file that was distributed with this source code.
*/
-namespace Behat\Behat\Gherkin\Subject;
+namespace Behat\Behat\Gherkin\Specification;
use Behat\Gherkin\Filter\FilterInterface;
use Behat\Gherkin\Gherkin;
use Behat\Gherkin\Node\FeatureNode;
-use Behat\Testwork\Subject\SubjectIterator;
+use Behat\Testwork\Specification\SpecificationIterator;
use Behat\Testwork\Suite\Suite;
/**
* Behat lazy feature iterator.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class LazyFeatureIterator implements SubjectIterator
+class LazyFeatureIterator implements SpecificationIterator
{
/**
* @var Suite
@@ -53,7 +53,7 @@ class LazyFeatureIterator implements SubjectIterator
private $currentFeature;
/**
- * Initializes subjects.
+ * Initializes specifications.
*
* @param Suite $suite
* @param Gherkin $gherkin
@@ -69,7 +69,7 @@ public function __construct(Suite $suite, Gherkin $gherkin, array $paths, array
}
/**
- * Returns suite that was used to load subjects.
+ * Returns suite that was used to load specifications.
*
* @return Suite
*/
@@ -8,17 +8,17 @@
* file that was distributed with this source code.
*/
-namespace Behat\Behat\Gherkin\Subject\Locator;
+namespace Behat\Behat\Gherkin\Specification\Locator;
-use Behat\Behat\Gherkin\Subject\LazyFeatureIterator;
+use Behat\Behat\Gherkin\Specification\LazyFeatureIterator;
use Behat\Gherkin\Filter\FilterInterface;
use Behat\Gherkin\Filter\NameFilter;
use Behat\Gherkin\Filter\PathsFilter;
use Behat\Gherkin\Filter\RoleFilter;
use Behat\Gherkin\Filter\TagFilter;
use Behat\Gherkin\Gherkin;
-use Behat\Testwork\Subject\EmptySubjectIterator;
-use Behat\Testwork\Subject\Locator\SubjectLocator;
+use Behat\Testwork\Specification\Locator\SpecificationLocator;
+use Behat\Testwork\Specification\NoSpecificationsIterator;
use Behat\Testwork\Suite\Exception\SuiteConfigurationException;
use Behat\Testwork\Suite\Suite;
use RecursiveDirectoryIterator;
@@ -32,7 +32,7 @@
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class FilesystemFeatureLocator implements SubjectLocator
+class FilesystemFeatureLocator implements SpecificationLocator
{
/**
* @var Gherkin
@@ -63,10 +63,10 @@ public function __construct(Gherkin $gherkin, $basePath)
*
* @return LazyFeatureIterator
*/
- public function locateSubjects(Suite $suite, $locator)
+ public function locateSpecifications(Suite $suite, $locator)
{
if (!$suite->hasSetting('paths')) {
- return new EmptySubjectIterator($suite);
+ return new NoSpecificationsIterator($suite);
}
$suiteLocators = $suite->getSetting('paths');
@@ -10,7 +10,7 @@
namespace Behat\Behat\Tester\Cli;
-use Behat\Testwork\Subject\SubjectIterator;
+use Behat\Testwork\Specification\SpecificationIterator;
use Behat\Testwork\Tester\Cli\ExerciseController as BaseController;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -33,7 +33,8 @@ public function configure(Command $command)
{
$command
->addArgument(
- 'features', InputArgument::OPTIONAL,
+ 'features',
+ InputArgument::OPTIONAL,
"Feature(s) to run. Could be:" . PHP_EOL .
"- a dir <comment>(features/)</comment>" . PHP_EOL .
"- a feature <comment>(*.feature)</comment>" . PHP_EOL .
@@ -42,11 +43,15 @@ public function configure(Command $command)
"- all scenarios at a line within a specific range <comment>(*.feature:10-20)</comment>."
)
->addOption(
- '--strict', null, InputOption::VALUE_NONE,
+ '--strict',
+ null,
+ InputOption::VALUE_NONE,
'Fail if there are any undefined or pending steps.'
)
->addOption(
- '--dry-run', null, InputOption::VALUE_NONE,
+ '--dry-run',
+ null,
+ InputOption::VALUE_NONE,
'Invokes formatters without executing the steps & hooks.'
);
}
@@ -56,13 +61,13 @@ public function configure(Command $command)
*
* @param InputInterface $input
*
- * @return SubjectIterator[]
+ * @return SpecificationIterator[]
*/
- protected function findSubjects(InputInterface $input)
+ protected function findSpecifications(InputInterface $input)
{
$subjects = array();
foreach ($this->getFeatureLocators($input) as $locator) {
- $subjects = array_merge($subjects, $this->findSuitesSubjects($this->getAvailableSuites(), $locator));
+ $subjects = array_merge($subjects, $this->findSuitesSpecifications($this->getAvailableSuites(), $locator));
}
return $subjects;
@@ -20,14 +20,14 @@
use Behat\Testwork\Environment\Environment;
use Behat\Testwork\Tester\Result\TestResult;
use Behat\Testwork\Tester\Result\TestResults;
-use Behat\Testwork\Tester\SubjectTester;
+use Behat\Testwork\Tester\SpecificationTester;
/**
* Feature tester.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class FeatureTester implements SubjectTester
+class FeatureTester implements SpecificationTester
{
/**
* @var StepContainerTester
@@ -95,8 +95,12 @@ protected function testFeature(Environment $environment, FeatureNode $feature, $
*
* @return TestResult
*/
- private function testScenario(Environment $environment, FeatureNode $feature, ScenarioInterface $scenario, $skip = false)
- {
+ private function testScenario(
+ Environment $environment,
+ FeatureNode $feature,
+ ScenarioInterface $scenario,
+ $skip = false
+ ) {
if ($scenario instanceof OutlineNode) {
return $this->testOutlineNode($environment, $feature, $scenario, $skip);
}
@@ -114,8 +118,12 @@ private function testScenario(Environment $environment, FeatureNode $feature, Sc
*
* @return OutlineTestResult
*/
- private function testOutlineNode(Environment $environment, FeatureNode $feature, OutlineNode $scenario, $skip = false)
- {
+ private function testOutlineNode(
+ Environment $environment,
+ FeatureNode $feature,
+ OutlineNode $scenario,
+ $skip = false
+ ) {
return $this->outlineTester->test($environment, $feature, $scenario, $skip);
}
@@ -129,8 +137,12 @@ private function testOutlineNode(Environment $environment, FeatureNode $feature,
*
* @return StepContainerTestResult
*/
- private function testScenarioNode(Environment $environment, FeatureNode $feature, ScenarioNode $scenario, $skip = false)
- {
+ private function testScenarioNode(
+ Environment $environment,
+ FeatureNode $feature,
+ ScenarioNode $scenario,
+ $skip = false
+ ) {
return $this->scenarioTester->test($environment, $feature, $scenario, $skip);
}
}
@@ -16,7 +16,7 @@
use Behat\Testwork\Cli\ServiceContainer\CliExtension;
use Behat\Testwork\Environment\ServiceContainer\EnvironmentExtension;
use Behat\Testwork\EventDispatcher\ServiceContainer\EventDispatcherExtension;
-use Behat\Testwork\Subject\ServiceContainer\SubjectExtension;
+use Behat\Testwork\Specification\ServiceContainer\SpecificationExtension;
use Behat\Testwork\Suite\ServiceContainer\SuiteExtension;
use Behat\Testwork\Tester\ServiceContainer\TesterExtension as BaseExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -63,7 +63,7 @@ protected function loadExerciseController(ContainerBuilder $container, $strict =
{
$definition = new Definition('Behat\Behat\Tester\Cli\ExerciseController', array(
new Reference(SuiteExtension::REGISTRY_ID),
- new Reference(SubjectExtension::FINDER_ID),
+ new Reference(SpecificationExtension::FINDER_ID),
new Reference(self::EXERCISE_ID),
$strict,
$skip
@@ -73,11 +73,11 @@ protected function loadExerciseController(ContainerBuilder $container, $strict =
}
/**
- * Loads subject tester.
+ * Loads specification tester.
*
* @param ContainerBuilder $container
*/
- protected function loadSubjectTester(ContainerBuilder $container)
+ protected function loadSpecificationTester(ContainerBuilder $container)
{
$definition = new Definition('Behat\Behat\Tester\HookableFeatureTester', array(
new Reference(self::SCENARIO_TESTER_ID),
@@ -91,7 +91,7 @@ protected function loadSubjectTester(ContainerBuilder $container)
'setEventDispatcher',
array(new Reference(EventDispatcherExtension::DISPATCHER_ID))
);
- $container->setDefinition(self::SUBJECT_TESTER_ID, $definition);
+ $container->setDefinition(self::SPECIFICATION_TESTER, $definition);
$this->loadScenarioTester($container);
$this->loadOutlineTester($container);
@@ -70,7 +70,7 @@ public function test(
StepContainerInterface $container,
$skip = false
) {
- $environment = $this->environmentManager->isolateEnvironment($environment, $feature);
+ $environment = $this->environmentManager->isolateEnvironment($environment, $container);
$result = $this->testContainer($environment, $feature, $container, $skip);
return new TestResult($result->getResultCode());
Oops, something went wrong.

0 comments on commit df94075

Please sign in to comment.