Permalink
Browse files

Behat\Testwork\Subject moved to Behat\Testwork\Specification

Following previous changes, it makes sense to group all specification-
related functionality under the consistent Specification namespace.
Following this new rule:

- Behat\Testwork\Subject\SubjectFinder became
  Behat\Testwork\Specification\SpecificationFinder

- Behat\Testwork\Subject\Locator\SubjectLocator became
  Behat\Testwork\Specification\Locator\SpecificationLocator

I think new namespace and names do much better job at communicating
their objects intention and clarifying the extension points.
  • Loading branch information...
1 parent 7d0c24e commit 67c8c75a7aed56d1e7fd257663bd3c9e8b97a5da @everzet everzet committed Feb 8, 2014
Showing with 301 additions and 283 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. +4 −4 src/Behat/Behat/Tester/ServiceContainer/TesterExtension.php
  7. +21 −20 ...at/Testwork/{Subject/GroupedSubjectIterator.php → Specification/GroupedSpecificationIterator.php}
  8. +37 −0 src/Behat/Testwork/Specification/Locator/SpecificationLocator.php
  9. +4 −4 src/Behat/Testwork/{Subject/EmptySubjectIterator.php → Specification/NoSpecificationsIterator.php}
  10. +12 −12 ...erviceContainer/SubjectExtension.php → Specification/ServiceContainer/SpecificationExtension.php}
  11. +13 −6 src/Behat/Testwork/{Subject/ArraySubjectIterator.php → Specification/SpecificationArrayIterator.php}
  12. +75 −0 src/Behat/Testwork/Specification/SpecificationFinder.php
  13. +5 −5 src/Behat/Testwork/{Subject/SubjectIterator.php → Specification/SpecificationIterator.php}
  14. +0 −37 src/Behat/Testwork/Subject/Locator/SubjectLocator.php
  15. +0 −75 src/Behat/Testwork/Subject/SubjectFinder.php
  16. +34 −29 src/Behat/Testwork/Tester/Cli/ExerciseController.php
  17. +7 −7 src/Behat/Testwork/Tester/Exercise.php
  18. +3 −3 src/Behat/Testwork/Tester/HookableSuiteTester.php
  19. +3 −3 src/Behat/Testwork/Tester/Result/HookedSuiteTestResult.php
  20. +8 −8 src/Behat/Testwork/Tester/Result/SuiteTestResult.php
  21. +5 −5 src/Behat/Testwork/Tester/ServiceContainer/TesterExtension.php
  22. +15 −15 src/Behat/Testwork/Tester/SuiteTester.php
  23. +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;
@@ -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),
@@ -8,25 +8,25 @@
* file that was distributed with this source code.
*/
-namespace Behat\Testwork\Subject;
+namespace Behat\Testwork\Specification;
use Behat\Testwork\Suite\Suite;
/**
- * Testwork grouped subject iterator.
+ * Testwork grouped specification iterator.
*
- * Iterates over subject iterators grouped by their suite.
+ * Iterates over specification iterators grouped by their suite.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class GroupedSubjectIterator implements SubjectIterator
+class GroupedSpecificationIterator implements SpecificationIterator
{
/**
* @var Suite
*/
private $suite;
/**
- * @var SubjectIterator[]
+ * @var SpecificationIterator[]
*/
private $iterators;
/**
@@ -35,40 +35,41 @@ class GroupedSubjectIterator implements SubjectIterator
private $position = 0;
/**
- * Initializes subjects.
+ * Initializes iterator.
*
- * @param Suite $suite
- * @param SubjectIterator[] $subjectIterators
+ * @param Suite $suite
+ * @param SpecificationIterator[] $specificationIterators
*/
- public function __construct(Suite $suite, array $subjectIterators)
+ public function __construct(Suite $suite, array $specificationIterators)
{
$this->suite = $suite;
- $this->iterators = $subjectIterators;
+ $this->iterators = $specificationIterators;
}
/**
- * Groups subjects by their suite.
+ * Groups specifications by their suite.
*
- * @param SubjectIterator[] $subjectIterators
+ * @param SpecificationIterator[] $specificationIterators
*
- * @return GroupedSubjectIterator[]
+ * @return GroupedSpecificationIterator[]
*/
- public static function group(array $subjectIterators)
+ public static function group(array $specificationIterators)
{
- $groupedSubjects = array();
- foreach ($subjectIterators as $subjectIterator) {
- $groupedSubjects[$subjectIterator->getSuite()->getName()][] = $subjectIterator;
+ $groupedSpecifications = array();
+ foreach ($specificationIterators as $specificationIterator) {
+ $groupedSpecifications[$specificationIterator->getSuite()->getName()][] = $specificationIterator;
}
return array_map(
function ($iterator) {
- return new GroupedSubjectIterator($iterator[0]->getSuite(), $iterator);
- }, $groupedSubjects
+ return new GroupedSpecificationIterator($iterator[0]->getSuite(), $iterator);
+ },
+ $groupedSpecifications
);
}
/**
- * Returns suite that was used to load subjects.
+ * Returns suite that was used to load specifications.
*
* @return Suite
*/
@@ -0,0 +1,37 @@
+<?php
+
+/*
+ * This file is part of the Behat Testwork.
+ * (c) Konstantin Kudryashov <ever.zet@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Behat\Testwork\Specification\Locator;
+
+use Behat\Testwork\Specification\SpecificationFinder;
+use Behat\Testwork\Specification\SpecificationIterator;
+use Behat\Testwork\Suite\Suite;
+
+/**
+ * Testwork test specification locator interface.
+ *
+ * Used by SpecificationFinder.
+ *
+ * @see SpecificationFinder
+ *
+ * @author Konstantin Kudryashov <ever.zet@gmail.com>
+ */
+interface SpecificationLocator
+{
+ /**
+ * Locates specifications and wraps them into iterator.
+ *
+ * @param Suite $suite
+ * @param string $locator
+ *
+ * @return SpecificationIterator
+ */
+ public function locateSpecifications(Suite $suite, $locator);
+}
Oops, something went wrong.

0 comments on commit 67c8c75

Please sign in to comment.