public function testTags() { $this->loader = new \Codeception\Test\Loader\Gherkin(['gherkin' => ['contexts' => ['default' => ['GherkinTestContext'], 'tag' => ['important' => ['TagGherkinContext']]]]]); $this->loader->loadTests(codecept_data_dir('refund.feature')); $test = $this->loader->getTests()[0]; /** @var $test \Codeception\Test\Gherkin * */ $test->getMetadata()->setServices($this->getServices()); $test->test(); $this->assertEquals('aXc', self::$calls); }
public function __construct($settings) { $loader = new Gherkin($settings); $finder = Finder::create()->files()->sortByName()->in($settings['path'])->followLinks()->name($loader->getPattern()); foreach ($finder as $file) { $pathname = str_replace("//", "/", $file->getPathname()); $loader->loadTests($pathname); } $availableSteps = $loader->getSteps(); $allSteps = []; foreach ($availableSteps as $stepGroup) { $allSteps = array_merge($allSteps, $stepGroup); } foreach ($loader->getTests() as $test) { /** @var $test \Codeception\Test\Gherkin **/ $steps = $test->getScenarioNode()->getSteps(); foreach ($steps as $step) { $matched = false; $text = $step->getText(); foreach (array_keys($allSteps) as $pattern) { if (preg_match($pattern, $text)) { $matched = true; break; } } if (!$matched) { $this->addSnippet($step); } } } }
public function __construct($settings, $test = null) { $loader = new Gherkin($settings); $pattern = $loader->getPattern(); $path = $settings['path']; if (!empty($test)) { $path = $settings['path'] . '/' . $test; if (preg_match($pattern, $test)) { $path = dirname($path); $pattern = basename($test); } } $finder = Finder::create()->files()->sortByName()->in($path)->followLinks()->name($pattern); foreach ($finder as $file) { $pathname = str_replace("//", "/", $file->getPathname()); $loader->loadTests($pathname); } $availableSteps = $loader->getSteps(); $allSteps = []; foreach ($availableSteps as $stepGroup) { $allSteps = array_merge($allSteps, $stepGroup); } foreach ($loader->getTests() as $test) { /** @var $test \Codeception\Test\Gherkin **/ $steps = $test->getScenarioNode()->getSteps(); if ($test->getFeatureNode()->hasBackground()) { $steps = array_merge($steps, $test->getFeatureNode()->getBackground()->getSteps()); } foreach ($steps as $step) { $matched = false; $text = $step->getText(); foreach (array_keys($allSteps) as $pattern) { if (preg_match($pattern, $text)) { $matched = true; break; } } if (!$matched) { $this->addSnippet($step); $file = str_ireplace($settings['path'], '', $test->getFeatureNode()->getFile()); if (!in_array($file, $this->features)) { $this->features[] = $file; } } } } }