Permalink
Browse files

Merge branch 'release/2.2.2'

  • Loading branch information...
2 parents c36d5a6 + cfb15e7 commit f022aaf731625b904136638c2f766fd626c63827 @everzet everzet committed Jul 1, 2012
Showing with 567 additions and 152 deletions.
  1. +7 −0 CHANGES.md
  2. +1 −1 bin/release
  3. +1 −1 bin/update_i18n
  4. +18 −3 i18n.php
  5. +3 −3 src/Behat/Gherkin/Cache/CacheInterface.php
  6. +8 −3 src/Behat/Gherkin/Dumper/GherkinDumper.php
  7. +9 −2 src/Behat/Gherkin/Filter/FilterInterface.php
  8. +44 −2 src/Behat/Gherkin/Filter/LineFilter.php
  9. +49 −3 src/Behat/Gherkin/Filter/LineRangeFilter.php
  10. +2 −2 src/Behat/Gherkin/Filter/NameFilter.php
  11. +38 −0 src/Behat/Gherkin/Filter/SimpleFilter.php
  12. +4 −2 src/Behat/Gherkin/Filter/TagFilter.php
  13. +7 −13 src/Behat/Gherkin/Gherkin.php
  14. +1 −1 src/Behat/Gherkin/Keywords/KeywordsDumper.php
  15. +12 −12 src/Behat/Gherkin/Keywords/KeywordsInterface.php
  16. +2 −2 src/Behat/Gherkin/Loader/ArrayLoader.php
  17. +1 −1 src/Behat/Gherkin/Loader/DirectoryLoader.php
  18. +1 −1 src/Behat/Gherkin/Loader/FileLoaderInterface.php
  19. +0 −2 src/Behat/Gherkin/Loader/GherkinFileLoader.php
  20. +2 −2 src/Behat/Gherkin/Loader/LoaderInterface.php
  21. +2 −0 src/Behat/Gherkin/Node/AbstractNode.php
  22. +8 −0 src/Behat/Gherkin/Node/AbstractScenarioNode.php
  23. +4 −1 src/Behat/Gherkin/Node/ExampleTableNode.php
  24. +18 −0 src/Behat/Gherkin/Node/FeatureNode.php
  25. +1 −1 src/Behat/Gherkin/Node/NodeVisitorInterface.php
  26. +2 −0 src/Behat/Gherkin/Node/OutlineNode.php
  27. +2 −0 src/Behat/Gherkin/Node/PyStringNode.php
  28. +4 −0 src/Behat/Gherkin/Node/ScenarioNode.php
  29. +3 −1 src/Behat/Gherkin/Node/StepArgumentNodeInterface.php
  30. +12 −0 src/Behat/Gherkin/Node/StepNode.php
  31. +55 −20 src/Behat/Gherkin/Node/TableNode.php
  32. +2 −2 src/Behat/Gherkin/Parser.php
  33. +64 −0 tests/Behat/Gherkin/Filter/FilterTest.php
  34. +56 −1 tests/Behat/Gherkin/Filter/LineFilterTest.php
  35. +38 −1 tests/Behat/Gherkin/Filter/LineRangeFilterTest.php
  36. +8 −8 tests/Behat/Gherkin/Fixtures/etalons/fibonacci.yml
  37. +1 −1 tests/Behat/Gherkin/Fixtures/etalons/issue_13.yml
  38. +4 −4 tests/Behat/Gherkin/Fixtures/etalons/multiline_name.yml
  39. +6 −6 tests/Behat/Gherkin/Fixtures/etalons/multiline_name_with_newlines.yml
  40. +9 −9 tests/Behat/Gherkin/Fixtures/etalons/outline_with_spaces.yml
  41. +7 −7 tests/Behat/Gherkin/Fixtures/etalons/outline_with_step_table.yml
  42. +4 −4 tests/Behat/Gherkin/Fixtures/etalons/ru_division.yml
  43. +8 −8 tests/Behat/Gherkin/Fixtures/etalons/tables.yml
  44. +2 −2 tests/Behat/Gherkin/Fixtures/etalons/tags_sample.yml
  45. +2 −2 tests/Behat/Gherkin/Fixtures/etalons/undefined_multiline_args.yml
  46. +25 −8 tests/Behat/Gherkin/GherkinTest.php
  47. +1 −0 tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php
  48. +5 −6 tests/Behat/Gherkin/Keywords/KeywordsTest.php
  49. +4 −4 tests/Behat/Gherkin/Keywords/SymfonyTranslationKeywordsTest.php
View
@@ -1,3 +1,10 @@
+2.2.2 / 2012-07-01
+==================
+
+ * Added ability to filter outline scenarios by line and range filters
+ * Synced Gherkin i18n
+ * Refactored table parser to read row line numbers too
+
2.2.1 / 2012-05-04
==================
View
@@ -17,7 +17,7 @@
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-require_once __DIR__.'/../vendor/.composer/autoload.php';
+require_once __DIR__.'/../vendor/autoload.php';
if (!isset($argv[1])) {
throw new Exception('You must provide version.');
View
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
-require_once __DIR__.'/../vendor/.composer/autoload.php';
+require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
View
@@ -3,7 +3,7 @@
array (
'name' => 'English',
'native' => 'English',
- 'feature' => 'Feature',
+ 'feature' => 'Feature|Business Need|Ability',
'background' => 'Background',
'scenario' => 'Scenario',
'scenario_outline' => 'Scenario Outline|Scenario Template',
@@ -29,6 +29,21 @@
'and' => 'و',
'but' => 'لكن',
),
+ 'bm' =>
+ array (
+ 'name' => 'Malay',
+ 'native' => 'Bahasa Melayu',
+ 'feature' => 'Fungsi',
+ 'background' => 'Latar Belakang',
+ 'scenario' => 'Senario',
+ 'scenario_outline' => 'Menggariskan Senario',
+ 'examples' => 'Contoh',
+ 'given' => 'Bagi',
+ 'when' => 'Apabila',
+ 'then' => 'Kemudian',
+ 'and' => 'Dan',
+ 'but' => 'Tetapi',
+ ),
'bg' =>
array (
'name' => 'Bulgarian',
@@ -468,13 +483,13 @@
array (
'name' => 'Polish',
'native' => 'polski',
- 'feature' => 'Właściwość',
+ 'feature' => 'Właściwość|Funkcja|Aspekt|Potrzeba biznesowa',
'background' => 'Założenia',
'scenario' => 'Scenariusz',
'scenario_outline' => 'Szablon scenariusza',
'examples' => 'Przykłady',
'given' => 'Zakładając|Mając',
- 'when' => 'Jeżeli|Jeśli',
+ 'when' => 'Jeżeli|Jeśli|Gdy|Kiedy',
'then' => 'Wtedy',
'and' => 'Oraz|I',
'but' => 'Ale',
@@ -27,7 +27,7 @@
*
* @return Boolean
*/
- function isFresh($path, $timestamp);
+ public function isFresh($path, $timestamp);
/**
* Reads feature cache from path.
@@ -36,13 +36,13 @@ function isFresh($path, $timestamp);
*
* @return FeatureNode
*/
- function read($path);
+ public function read($path);
/**
* Caches feature node.
*
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
- function write($path, FeatureNode $feature);
+ public function write($path, FeatureNode $feature);
}
@@ -115,6 +115,7 @@ public function dumpFeature(FeatureNode $feature)
foreach ($scenarios as $scenario) {
$content .= PHP_EOL . $this->dumpScenario($scenario);
}
+
return $content;
}
@@ -132,6 +133,7 @@ public function dumpKeyword($keyword, $text, $indent = 0)
if (preg_match('!(^.*)\|!', $keyword, $matches)) {
$keyword = $matches[1];
}
+
return $this->dumpIndent($indent) . $keyword . ':'
. ((strlen($text) > 0) ? ' ' . ltrim($this->dumpText($text, $indent + 1)) : '')
;
@@ -166,14 +168,15 @@ public function dumpScenario(ScenarioNode $scenario)
$examples = $scenario->getExamples();
$content .= $this->dumpTableNode($examples, 2);
}
+
return $content;
}
/**
* Dumps table node.
*
- * @param TableNode $tableNode Table node
- * @param integer $indent Indentation
+ * @param TableNode $tableNode Table node
+ * @param integer $indent Indentation
* @return string
*/
public function dumpTableNode(TableNode $tableNode, $indent = 0)
@@ -184,13 +187,14 @@ public function dumpTableNode(TableNode $tableNode, $indent = 0)
$content .= PHP_EOL . $this->dumpIndent($indent)
. $tableNode->getRowAsString($i);
}
+
return $content;
}
/**
* Dumps indentation.
*
- * @param integer $indent Indentation
+ * @param integer $indent Indentation
*
* @return string
*/
@@ -262,6 +266,7 @@ public function dumpTags(array $tags, $indent = 0)
if (empty($tags)) {
return '';
}
+
return $this->dumpIndent($indent) . '@' . ltrim(implode(' @', $tags));
}
@@ -27,7 +27,7 @@
*
* @return Boolean
*/
- function isFeatureMatch(FeatureNode $feature);
+ public function isFeatureMatch(FeatureNode $feature);
/**
* Checks if scenario or outline matches specified filter.
@@ -36,5 +36,12 @@ function isFeatureMatch(FeatureNode $feature);
*
* @return Boolean
*/
- function isScenarioMatch(ScenarioNode $scenario);
+ public function isScenarioMatch(ScenarioNode $scenario);
+
+ /**
+ * Filters feature according to the filter.
+ *
+ * @param FeatureNode $feature
+ */
+ public function filterFeature(FeatureNode $feature);
}
@@ -3,7 +3,8 @@
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode,
- Behat\Gherkin\Node\ScenarioNode;
+ Behat\Gherkin\Node\ScenarioNode,
+ Behat\Gherkin\Node\OutlineNode;
/*
* This file is part of the Behat Gherkin.
@@ -53,6 +54,47 @@ public function isFeatureMatch(FeatureNode $feature)
*/
public function isScenarioMatch(ScenarioNode $scenario)
{
- return $this->filterLine === $scenario->getLine();
+ if ($this->filterLine === $scenario->getLine()) {
+ return true;
+ }
+
+ if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
+ return $this->filterLine === $scenario->getLine()
+ || in_array($this->filterLine, $scenario->getExamples()->getRowLines());
+ }
+
+ return false;
+ }
+
+ /**
+ * Filters feature according to the filter.
+ *
+ * @param FeatureNode $feature
+ */
+ public function filterFeature(FeatureNode $feature)
+ {
+ $scenarios = $feature->getScenarios();
+ foreach ($scenarios as $i => $scenario) {
+ if (!$this->isScenarioMatch($scenario)) {
+ unset($scenarios[$i]);
+ continue;
+ }
+
+ if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
+ $lines = $scenario->getExamples()->getRowLines();
+ $rows = $scenario->getExamples()->getNumeratedRows();
+
+ if (current($lines) <= $this->filterLine && end($lines) >= $this->filterLine) {
+ $scenario->getExamples()->setRows(array());
+ $scenario->getExamples()->addRow($rows[$lines[0]], $lines[0]);
+
+ if ($lines[0] !== $this->filterLine) {
+ $scenario->getExamples()->addRow($rows[$this->filterLine], $this->filterLine);
+ }
+ }
+ }
+ }
+
+ $feature->setScenarios($scenarios);
}
}
@@ -3,7 +3,8 @@
namespace Behat\Gherkin\Filter;
use Behat\Gherkin\Node\FeatureNode,
- Behat\Gherkin\Node\ScenarioNode;
+ Behat\Gherkin\Node\ScenarioNode,
+ Behat\Gherkin\Node\OutlineNode;
/*
* This file is part of the Behat Gherkin.
@@ -60,7 +61,52 @@ public function isFeatureMatch(FeatureNode $feature)
*/
public function isScenarioMatch(ScenarioNode $scenario)
{
- return $this->filterMinLine <= $scenario->getLine()
- && $this->filterMaxLine >= $scenario->getLine();
+ if ($this->filterMinLine <= $scenario->getLine()
+ && $this->filterMaxLine >= $scenario->getLine()) {
+ return true;
+ }
+
+ if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
+ foreach ($scenario->getExamples()->getRowLines() as $line) {
+ if ($line >= $this->filterMinLine && $line <= $this->filterMaxLine) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Filters feature according to the filter.
+ *
+ * @param FeatureNode $feature
+ */
+ public function filterFeature(FeatureNode $feature)
+ {
+ $scenarios = $feature->getScenarios();
+ foreach ($scenarios as $i => $scenario) {
+ if (!$this->isScenarioMatch($scenario)) {
+ unset($scenarios[$i]);
+ continue;
+ }
+
+ if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
+ $lines = $scenario->getExamples()->getRowLines();
+ $rows = $scenario->getExamples()->getNumeratedRows();
+
+ $scenario->getExamples()->setRows(array());
+ $scenario->getExamples()->addRow($rows[$lines[0]], $lines[0]);
+ unset($rows[$lines[0]]);
+
+ foreach ($rows as $line => $row) {
+ if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) {
+ $scenario->getExamples()->addRow($row, $line);
+ }
+ }
+ }
+ }
+
+ $feature->setScenarios($scenarios);
}
}
@@ -18,14 +18,14 @@
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class NameFilter implements FilterInterface
+class NameFilter extends SimpleFilter
{
protected $filterString;
/**
* Initializes filter.
*
- * @param string $filterStringString Name filter string
+ * @param string $filterString Name filter string
*/
public function __construct($filterString)
{
@@ -0,0 +1,38 @@
+<?php
+
+namespace Behat\Gherkin\Filter;
+
+use Behat\Gherkin\Node\FeatureNode;
+
+/*
+ * This file is part of the Behat Gherkin.
+ * (c) 2011 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.
+ */
+
+/**
+ * Abstract filter class.
+ *
+ * @author Konstantin Kudryashov <ever.zet@gmail.com>
+ */
+abstract class SimpleFilter implements FilterInterface
+{
+ /**
+ * Filters feature according to the filter.
+ *
+ * @param FeatureNode $feature
+ */
+ public function filterFeature(FeatureNode $feature)
+ {
+ $scenarios = $feature->getScenarios();
+ foreach ($scenarios as $i => $scenario) {
+ if (!$this->isScenarioMatch($scenario)) {
+ unset($scenarios[$i]);
+ }
+ }
+
+ $feature->setScenarios($scenarios);
+ }
+}
@@ -19,14 +19,14 @@
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-class TagFilter implements FilterInterface
+class TagFilter extends SimpleFilter
{
protected $filterString;
/**
* Initializes filter.
*
- * @param string $filterStringString Name filter string
+ * @param string $filterString Name filter string
*/
public function __construct($filterString)
{
@@ -61,6 +61,8 @@ public function isScenarioMatch(ScenarioNode $scenario)
* Checks that node matches condition.
*
* @param AbstractNode $node Node to check
+ *
+ * @return Boolean
*/
protected function matchesCondition(AbstractNode $node)
{
Oops, something went wrong.

0 comments on commit f022aaf

Please sign in to comment.