Author: Konstantin Kudryashov (ever.zet@gmail.com)
Exemplo n.º 1
0
 public function testSetBasePath()
 {
     $gherkin = new Gherkin();
     $gherkin->addLoader($loader1 = $this->getLoaderMock());
     $gherkin->addLoader($loader2 = $this->getLoaderMock());
     $loader1->expects($this->once())->method('setBasePath')->with($basePath = '/base/path')->will($this->returnValue(null));
     $loader2->expects($this->once())->method('setBasePath')->with($basePath = '/base/path')->will($this->returnValue(null));
     $gherkin->setBasePath($basePath);
 }
Exemplo n.º 2
0
 /**
  * Executes controller.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return null|integer
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $filters = array();
     foreach ($input->getOption('name') as $name) {
         $filters[] = new NameFilter($name);
     }
     foreach ($input->getOption('tags') as $tags) {
         $filters[] = new TagFilter($tags);
     }
     if ($role = $input->getOption('role')) {
         $filters[] = new RoleFilter($role);
     }
     if (count($filters)) {
         $this->gherkin->setFilters($filters);
     }
 }
 protected function runFeatures(Gherkin $gherkin)
 {
     $features = array();
     foreach ($this->getFeaturesPaths() as $path) {
         // parse every feature with Gherkin
         $features += $gherkin->load((string) $path);
     }
     $divider = new FeatureDivider($features);
     $divider->setPartsCount($this->countWorkers);
     $features = $divider->getFeaturesForPart($this->workerNumber);
     // and run it in FeatureTester
     foreach ($features as $feature) {
         $tester = $this->getContainer()->get('behat.tester.feature');
         $tester->setSkip($this->isDryRun());
         $feature->accept($tester);
     }
 }
 /**
  * Multiple features folders loader
  *
  * Delegates load execution to parent including filters management
  *
  * @param mixed $resource Resource to load
  * @param array $filters  Additional filters
  * @return array
  */
 public function load($resource, array $filters = array())
 {
     // If a resource is specified don't overwrite the parent behaviour.
     if ($resource != '') {
         return parent::load($resource, $filters);
     }
     if (!is_array($this->moodleConfig)) {
         throw new RuntimeException('There are no Moodle features nor steps definitions');
     }
     // Loads all the features files of each Moodle component.
     $features = array();
     if (!empty($this->moodleConfig['features'])) {
         foreach ($this->moodleConfig['features'] as $path) {
             if (file_exists($path)) {
                 $features = array_merge($features, parent::load($path, $filters));
             }
         }
     }
     return $features;
 }
Exemplo n.º 5
0
 /**
  * Parses and runs provided features.
  *
  * @param Gherkin $gherkin gherkin parser/loader
  */
 protected function runFeatures(Gherkin $gherkin)
 {
     foreach ($this->getFeaturesPaths() as $path) {
         // parse every feature with Gherkin
         $features = $gherkin->load((string) $path);
         // and run it in FeatureTester
         foreach ($features as $feature) {
             $tester = $this->getContainer()->get('behat.tester.feature');
             $tester->setSkip($this->isDryRun());
             $feature->accept($tester);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Parses feature at path.
  *
  * @param string $path
  *
  * @return FeatureNode[]
  */
 private function parseFeature($path)
 {
     return $this->gherkin->load($path, $this->filters);
 }
Exemplo n.º 7
0
 public function setUpTestRun(BeforeSuiteTested $event)
 {
     print "Rails logger initialised to use new suite id\n";
     $this->initRails();
     $suite_id = TestRailApiWrapper::create_new_testsuite(" " . $this->testrun_basename);
     $gerkin = new Gherkin();
     $base_path = $event->getSuite()->getSetting("paths")["features"];
     $gerkin->setBasePath($base_path);
     $i18nPath = dirname(dirname(dirname(dirname(dirname(__DIR__))))) . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'gherkin' . DIRECTORY_SEPARATOR . 'i18n.php';
     $gerkin->addLoader(new GherkinFileLoader(new Parser(new Lexer(new CachedArrayKeywords($i18nPath)))));
     $list = (new FilesystemFeatureLocator($gerkin, $base_path))->locateSpecifications($event->getSuite(), $base_path);
     $list->rewind();
     while ($list->valid()) {
         $suite_section = TestRailApiWrapper::create_new_section($list->current()->getTitle());
         // read scenarious from feaure
         foreach ($list->current()->getScenarios() as $scenario) {
             $test_case_id = TestRailApiWrapper::create_new_testcase($scenario->getTitle(), $suite_section);
             $this->testcases[$test_case_id] = $scenario->getTitle();
         }
         $list->next();
     }
     TestRailApiWrapper::create_new_testrun();
 }