Prepare a scenario

@param BeforeScenarioScope $scope
@throws RuntimeException

@BeforeScenario
5141
public function prepareScenario(BeforeScenarioScope $scope) {
        $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-api-extension' . DIRECTORY_SEPARATOR . microtime(true);
        mkdir($dir . '/features/bootstrap', 0777, true);

        // Locate the php binary
        if (($bin = (new PhpExecutableFinder())->find()) === false) {
            throw new RuntimeException('Unable to find the PHP executable.');
        }

        $this->workingDir = $dir;
        $this->phpBin = $bin;
        $this->process = new Process(null);
    }
204345
public function prepare()
    {
        if (empty($this->targetBundle) && empty($this->bundleExtensionDir)) {
            throw new \RuntimeException(sprintf(
                "Runtime Error: Any Bundle was selected for ui generation."
            ));
        }

        // load reader from factory
        $this->reader = $this->readerFactory->load($this->metaFile);
        $elementType = $this->reader->getElement()->getXtype();

        $bundleDir = empty($this->targetBundle)
            ? $this->bundleExtensionDir . DS . $elementType . DS
            : $this->bundleExtensionDir . DS . $this->targetBundle . DS . $elementType . DS;

        if (! file_exists($bundleDir . 'components.genscript') && ! file_exists($bundleDir . 'mapping.php')) {
            $bundleDir = __DIR__ . DS . 'bundle' . DS . $this->targetBundle . DS . $elementType . DS;
            if (! file_exists($bundleDir . 'components.genscript') && ! file_exists($bundleDir . 'mapping.php')) {
                throw new \Exception(sprintf("Error: Bundle '%s' does not exist!.", $this->targetBundle));
            }
        }

        $genscriptFilename = $bundleDir . 'components.genscript';
        $mappingFilename   = $bundleDir . 'mapping.php';

        //verify if the bundle is registered
        if (! file_exists($genscriptFilename)) {
            throw new \Exception(sprintf("Error: genscript file for '%s' bundle is missing.", $this->targetBundle));
        }

        if (! file_exists($genscriptFilename)) {
            throw new \Exception(sprintf("Error: mapping file for '%s' bundle is missing.", $this->targetBundle));
        }

        if (! file_exists($this->metaFile)) {
            throw new \Exception(sprintf("Error: meta file '%s' does not exist.", $this->metaFile));
        }

        $this->parser->setScriptFile($genscriptFilename);
        $this->parser->parse();
        $this->mapping = file_exists($mappingFilename) ? include($mappingFilename) : null;
    }
454469
function setScope($scope)
    {
        $scopes = array_merge($this->getScopes(), array( (string) $scope) );
        $this->setScopes($scopes);
        return $this;
    }
324047
public function setScope($scope)
    {
        if (in_array($scope, $this->scopes) === false) {
            throw Exception\Scope::invalidScope($scope, $this->scopes);
        }

        $this->scope = $scope;

        return $this;
    }
580155
public function setScope($scope)
    {
        $validScopes = ['col', 'row', 'colgroup', 'rowgroup'];

        if (!StringHelper::isOneOf($scope, $validScopes)) {
            throw new \Exception(sprintf('"%s" is not a valid <td> scope. Valid are: %s', $scope, implode(', ', $validScopes)));
        }

        $this->attributes->set('scope', $scope);

        return $this;
    }
387634
public function beforeScenarioSetVariables(BeforeScenarioScope $scope)
    {
        $steps = [];
        if ($scope->getFeature()->hasBackground()) {
            $steps = $scope->getFeature()->getBackground()->getSteps();
        }
        $steps = array_merge($steps, $scope->getScenario()->getSteps());
        foreach ($steps as $step) {
            preg_match_all(static::VARIABLE_REGEX, $step->getText(), $matches);
            $variables_found = $matches[0];
            // Find variables in are TableNodes or PyStringNodes.
            $step_argument = $step->getArguments();
            if (!empty($step_argument) && $step_argument[0] instanceof TableNode) {
                preg_match_all(static::VARIABLE_REGEX, $step_argument[0]->getTableAsString(), $matches);
                $variables_found = array_filter(array_merge($variables_found, $matches[0]));
            }
            foreach ($variables_found as $variable_name) {
                if (!isset($this->values[$variable_name])) {
                    $value = $this->getDriver()->getRandom()->name(10);
                    // Value forced to lowercase to ensure it is machine-readable.
                    $this->values[$variable_name] = strtolower($value);
                }
            }
        }
    }
565352
public function beforeScenario(BeforeScenarioScope $scope)
	{
		$this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
		if(is_null(static::$jobRepo)){
			$this->gatherContexts($scope);
			static::$jobRepo = $this->getJobRepository();
		}
	}
896510
private function validateScopeValue($scope)
    {
        switch ($scope) {
            case self::SCOPE_ACT_AS_USER:
            case self::SCOPE_ADMIN:
            case self::SCOPE_NONE:
            case self::SCOPE_READ:
            case self::SCOPE_WRITE:
            case self::SCOPE_DELETE:
            case self::SCOPE_JIRA_PROJECT_ADMIN:
            case self::SCOPE_CONFLUENCE_SPACE_ADMIN:
                return true;
        }
        throw new \InvalidArgumentException(sprintf("Unknown scope %s", $scope));
    }
798551
public function beforeScenarioNoContactFlood(BeforeScenarioScope $scope) {
    $config = $this->getCore()->getEditableConfig('contact.settings');
    $this->contactSettings = $config->getData();
    $config->set('flood.limit', 100000);
    $config->set('flood.interval', 100000);
    $config->save();
  }
1012000
public static function enterScope($scope)
    {
        if (!is_scalar($scope)) {
            throw new \InvalidArgumentException("Only scalars allowed as scope identifiers");
        }
        array_push(self::$scope, $scope);
        list($call) = debug_backtrace(0);
        array_push(self::$scopeChange, $call);
    }
432395
public function maybeBackupDatabase(BeforeScenarioScope $scope)
    {
        $db = $this->getWordpressParameter('database');
        if (! $db['restore_after_test']) {
            return;
        }

        /*
         * We need the logic of this method to operate only once, and have access to the Context.
         * Otherwise, we would use the (static) BeforeSuiteScope hook.
         */
        $backup_file = $this->getWordpress()->getSetting('database_backup_file');
        if ($backup_file) {
            return;
        }

        // Get the file to use as a backup.
        $file = ! empty($db['backup_path']) ? $db['backup_path'] : '';

        // If the path specified is not a file, use it as the preferred folder to store a new backup.
        if (! $file || ! is_file($file) || ! is_readable($file)) {
            $file = $this->exportDatabase(['path' => $file]);
        }

        // Note: $file may be either an absolute OR relative file path.
        $this->getWordpress()->setSetting('database_backup_file', $file);
    }
1148178
public function runBeforeView($context = null) {
        if($this->_beforeView !== null) {
            foreach($this->_beforeView as $hookProvider) {
                $hookProvider->doBeforeView($context);
            }
        }
    }
1356212
def before_scenario(context, scenario):
    """"""

    # Prepare a new temporary directory.
    context.directory = testfixtures.TempDirectory(create=True)
    context.old_cwd = os.getcwd()
    context.new_cwd = context.directory.path

    # Move into our new working directory.
    os.chdir(context.new_cwd)
987878
public function maybeRestoreDatabase(AfterScenarioScope $scope)
    {
        $db = $this->getWordpressParameter('database');
        if (! $db['restore_after_test']) {
            return;
        }

        $file = $this->getWordpress()->getSetting('database_backup_file');
        if (! $file) {
            return;
        }

        $this->importDatabase(['path' => $file]);
    }
278883
protected function removeScope( Node$scope ):self
	{
		if( $scope!==array_shift($this->scopes) ){
			$this->throw('Scope nesting error');
		};

		return $this;
	}
900735
public function scoped(Scope $scope)
	{
		if($scope instanceof Dependent)
		{
			$this->scope = NULL;
		}
		else
		{
			$this->scope = get_class($scope);
		}
		
		return $this;
	}
623508
protected function addToScopes(TreeScope $scope)
    {
        $this->scopes[] = $scope;
        $this->scopeByName[$scope->getName()] = $scope;
        $this->scopeByModelRootId[$scope->getModelRootId()] = $scope;
        $this->scopeByPathPrefix[$scope->getPathPrefix()] = $scope;
    }