/** * Finds and loads available subcontext classes. */ private function findSubContextClasses() { $class_names = array(); // Initialize any available sub-contexts. if (isset($this->parameters['subcontexts'])) { $paths = array(); // Drivers may specify paths to subcontexts. if ($this->parameters['subcontexts']['autoload']) { foreach ($this->drupal->getDrivers() as $name => $driver) { if ($driver instanceof DrupalSubContextFinderInterface) { $paths += $driver->getSubContextPaths(); } } } // Additional subcontext locations may be specified manually in behat.yml. if (isset($this->parameters['subcontexts']['paths'])) { $paths = array_merge($paths, $this->parameters['subcontexts']['paths']); } // Load each class. foreach ($paths as $path) { if ($subcontexts = $this->findAvailableSubContexts($path)) { $this->loadSubContexts($subcontexts); } } // Find all subcontexts. $classes = get_declared_classes(); foreach ($classes as $class) { $reflect = new \ReflectionClass($class); if ($reflect->implementsInterface('Drupal\\DrupalExtension\\Context\\DrupalSubContextInterface')) { $class_names[] = $class; } } } return $class_names; }
/** * Configures default Drupal driver to use before each scenario or outline. * * `@api` tagged scenarios will get the `api_driver` as the default driver. * * Other scenarios get the `default_driver` as the default driver. * * @param ScenarioEvent|OutlineEvent $event */ public function prepareDefaultDrupalDriver($event) { $feature = $event->getFeature(); $scenario = $event instanceof ScenarioLikeTested ? $event->getScenario() : $event->getOutline(); // Get the default driver. $driver = $this->parameters['default_driver']; foreach (array_merge($feature->getTags(), $scenario->getTags()) as $tag) { if (!empty($this->parameters[$tag . '_driver'])) { $driver = $this->parameters[$tag . '_driver']; } } // Set the default driver. $this->drupal->setDefaultDriverName($driver); // Set the environment. $environment = $event->getEnvironment(); $this->drupal->setEnvironment($environment); }