idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
9,000
|
private function processLoaders ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: LOADER_TAG ) ; $ definition = $ container -> getDefinition ( self :: MANAGER_ID ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'addLoader' , array ( $ reference ) ) ; } }
|
Processes all available gherkin loaders .
|
9,001
|
private function createFilterDefinition ( $ type , $ filterString ) { if ( 'role' === $ type ) { return new Definition ( 'Behat\Gherkin\Filter\RoleFilter' , array ( $ filterString ) ) ; } if ( 'name' === $ type ) { return new Definition ( 'Behat\Gherkin\Filter\NameFilter' , array ( $ filterString ) ) ; } if ( 'tags' === $ type ) { return new Definition ( 'Behat\Gherkin\Filter\TagFilter' , array ( $ filterString ) ) ; } if ( 'narrative' === $ type ) { return new Definition ( 'Behat\Gherkin\Filter\NarrativeFilter' , array ( $ filterString ) ) ; } throw new ExtensionException ( sprintf ( '`%s` filter is not supported by the `filters` option of gherkin extension. Supported types are `%s`.' , $ type , implode ( '`, `' , array ( 'narrative' , 'role' , 'name' , 'tags' ) ) ) , 'gherkin' ) ; }
|
Creates filter definition of provided type .
|
9,002
|
private function getSuitePaths ( Suite $ suite ) { if ( ! is_array ( $ suite -> getSetting ( 'paths' ) ) ) { throw new SuiteConfigurationException ( sprintf ( '`paths` setting of the "%s" suite is expected to be an array, %s given.' , $ suite -> getName ( ) , gettype ( $ suite -> getSetting ( 'paths' ) ) ) , $ suite -> getName ( ) ) ; } return $ suite -> getSetting ( 'paths' ) ; }
|
Returns array of feature paths configured for the provided suite .
|
9,003
|
private function findFeatureFiles ( $ path ) { $ absolutePath = $ this -> findAbsolutePath ( $ path ) ; if ( ! $ absolutePath ) { return array ( $ path ) ; } if ( is_file ( $ absolutePath ) ) { return array ( $ absolutePath ) ; } $ iterator = new RegexIterator ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ absolutePath , RecursiveDirectoryIterator :: FOLLOW_SYMLINKS | RecursiveDirectoryIterator :: SKIP_DOTS ) ) , '/^.+\.feature$/i' , RegexIterator :: MATCH ) ; $ paths = array_map ( 'strval' , iterator_to_array ( $ iterator ) ) ; uasort ( $ paths , 'strnatcasecmp' ) ; return $ paths ; }
|
Loads feature files paths from provided path .
|
9,004
|
private function addTranslationResource ( $ path , $ assetsId ) { switch ( $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ) { case 'yml' : $ this -> addTranslatorResource ( 'yaml' , $ path , basename ( $ path , '.' . $ ext ) , $ assetsId ) ; break ; case 'xliff' : $ this -> addTranslatorResource ( 'xliff' , $ path , basename ( $ path , '.' . $ ext ) , $ assetsId ) ; break ; case 'php' : $ this -> addTranslatorResource ( 'php' , $ path , basename ( $ path , '.' . $ ext ) , $ assetsId ) ; break ; default : throw new UnknownTranslationResourceException ( sprintf ( 'Can not read translations from `%s`. File type is not supported.' , $ path ) , $ path ) ; } }
|
Adds translation resource .
|
9,005
|
private function addTranslatorResource ( $ type , $ path , $ language , $ assetsId ) { $ this -> translator -> addResource ( $ type , $ path , $ language , $ assetsId ) ; }
|
Adds resource to translator instance .
|
9,006
|
public function printSnippets ( $ targetName , array $ snippets ) { $ message = $ this -> translator -> trans ( 'snippet_proposal_title' , array ( '%1%' => $ targetName ) , 'output' ) ; $ this -> output -> writeln ( '--- ' . $ message . PHP_EOL ) ; foreach ( $ snippets as $ snippet ) { $ this -> output -> writeln ( sprintf ( '<snippet_undefined>%s</snippet_undefined>' , $ snippet -> getSnippet ( ) ) . PHP_EOL ) ; } }
|
Prints snippets of specific target .
|
9,007
|
public function printUndefinedSteps ( $ suiteName , array $ steps ) { $ message = $ this -> translator -> trans ( 'snippet_missing_title' , array ( '%1%' => $ suiteName ) , 'output' ) ; $ this -> output -> writeln ( '--- ' . $ message . PHP_EOL ) ; foreach ( $ steps as $ step ) { $ this -> output -> writeln ( sprintf ( ' <snippet_undefined>%s %s</snippet_undefined>' , $ step -> getKeyword ( ) , $ step -> getText ( ) ) ) ; } $ this -> output -> writeln ( '' ) ; }
|
Prints undefined steps of specific suite .
|
9,008
|
private function readContextCallees ( ContextEnvironment $ environment , $ contextClass ) { $ callees = array ( ) ; foreach ( $ this -> contextReaders as $ loader ) { $ callees = array_merge ( $ callees , $ loader -> readContextCallees ( $ environment , $ contextClass ) ) ; } return $ callees ; }
|
Reads callees from a specific suite s context .
|
9,009
|
private function printStepOnAfterEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterStepTested ) { return ; } $ this -> stepPrinter -> printStep ( $ formatter , $ this -> scenario , $ event -> getStep ( ) , $ event -> getTestResult ( ) ) ; if ( $ this -> setupPrinter ) { $ this -> setupPrinter -> printTeardown ( $ formatter , $ event -> getTeardown ( ) ) ; } }
|
Prints step on AFTER event .
|
9,010
|
private function getDefinitionPrinter ( $ argument ) { if ( 'l' === $ argument ) { return $ this -> listPrinter ; } if ( 'i' !== $ argument ) { $ this -> infoPrinter -> setSearchCriterion ( $ argument ) ; } return $ this -> infoPrinter ; }
|
Returns definition printer for provided option argument .
|
9,011
|
private function loadRootNodeListener ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Node\EventListener\JUnit\JUnitOutlineStoreListener' , array ( new Reference ( 'output.node.printer.junit.suite' ) ) ) ; $ container -> setDefinition ( 'output.node.listener.junit.outline' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\EventListener\JUnit\JUnitDurationListener' ) ; $ container -> setDefinition ( 'output.node.listener.junit.duration' , $ definition ) ; $ definition = new Definition ( 'Behat\Testwork\Output\Node\EventListener\ChainEventListener' , array ( array ( new Reference ( 'output.node.listener.junit.duration' ) , new Reference ( 'output.node.listener.junit.outline' ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\JUnit\JUnitFeatureElementListener' , array ( new Reference ( 'output.node.printer.junit.feature' ) , new Reference ( 'output.node.printer.junit.scenario' ) , new Reference ( 'output.node.printer.junit.step' ) , new Reference ( 'output.node.printer.junit.setup' ) , ) ) , ) , ) ) ; $ container -> setDefinition ( self :: ROOT_LISTENER_ID , $ definition ) ; }
|
Loads the node listeners required for JUnit printers to work .
|
9,012
|
private function loadFormatter ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Statistics\PhaseStatistics' ) ; $ container -> setDefinition ( 'output.junit.statistics' , $ definition ) ; $ definition = new Definition ( 'Behat\Testwork\Output\NodeEventListeningFormatter' , array ( 'junit' , 'Outputs the failures in JUnit compatible files.' , array ( 'timer' => true , ) , $ this -> createOutputPrinterDefinition ( ) , new Definition ( 'Behat\Testwork\Output\Node\EventListener\ChainEventListener' , array ( array ( new Reference ( self :: ROOT_LISTENER_ID ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\Statistics\ScenarioStatsListener' , array ( new Reference ( 'output.junit.statistics' ) ) ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\Statistics\StepStatsListener' , array ( new Reference ( 'output.junit.statistics' ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) ) ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\Statistics\HookStatsListener' , array ( new Reference ( 'output.junit.statistics' ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) ) ) , ) , ) ) , ) ) ; $ definition -> addTag ( OutputExtension :: FORMATTER_TAG , array ( 'priority' => 100 ) ) ; $ container -> setDefinition ( OutputExtension :: FORMATTER_TAG . '.junit' , $ definition ) ; }
|
Loads formatter itself .
|
9,013
|
private function getNormalizedContextSettings ( Suite $ suite ) { return array_map ( function ( $ context ) { $ class = $ context ; $ arguments = array ( ) ; if ( is_array ( $ context ) ) { $ class = current ( array_keys ( $ context ) ) ; $ arguments = $ context [ $ class ] ; } return array ( $ class , $ arguments ) ; } , $ this -> getSuiteContexts ( $ suite ) ) ; }
|
Returns normalized suite context settings .
|
9,014
|
private function captureCurrentFeaturePathOnBeforeFeatureEvent ( Event $ event ) { if ( ! $ event instanceof BeforeFeatureTested ) { return ; } $ this -> currentFeaturePath = $ event -> getFeature ( ) -> getFile ( ) ; }
|
Captures current feature file path to the ivar on feature BEFORE event .
|
9,015
|
private function captureScenarioOrExampleStatsOnAfterEvent ( Event $ event ) { if ( ! $ event instanceof AfterScenarioTested ) { return ; } $ scenario = $ event -> getScenario ( ) ; $ title = $ scenario -> getTitle ( ) ; $ path = sprintf ( '%s:%d' , $ this -> currentFeaturePath , $ scenario -> getLine ( ) ) ; $ resultCode = $ event -> getTestResult ( ) -> getResultCode ( ) ; $ stat = new ScenarioStat ( $ title , $ path , $ resultCode ) ; $ this -> statistics -> registerScenarioStat ( $ stat ) ; }
|
Captures scenario or example stats on their AFTER event .
|
9,016
|
protected function loadStopOnFailureController ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\EventDispatcher\Cli\StopOnFailureController' , array ( new Reference ( EventDispatcherExtension :: DISPATCHER_ID ) ) ) ; $ definition -> addTag ( CliExtension :: CONTROLLER_TAG , array ( 'priority' => 100 ) ) ; $ container -> setDefinition ( CliExtension :: CONTROLLER_TAG . '.stop_on_failure' , $ definition ) ; }
|
Loads stop on failure controller .
|
9,017
|
private function createContainer ( $ settings ) { if ( is_string ( $ settings ) ) { return $ this -> createContainerFromString ( $ settings ) ; } if ( is_array ( $ settings ) ) { return $ this -> createContainerFromArray ( $ settings ) ; } throw new WrongServicesConfigurationException ( sprintf ( '`services` must be either string or an array, but `%s` given.' , gettype ( $ settings ) ) ) ; }
|
Creates container from the setting passed .
|
9,018
|
private function loadContainerFromContainer ( $ name ) { $ services = $ this -> container -> findTaggedServiceIds ( HelperContainerExtension :: HELPER_CONTAINER_TAG ) ; if ( ! array_key_exists ( $ name , $ services ) ) { throw new WrongServicesConfigurationException ( sprintf ( 'Service container `@%s` was not found.' , $ name ) ) ; } return $ this -> container -> get ( $ name ) ; }
|
Loads container from string .
|
9,019
|
private function createContainerFromClassSpec ( $ classSpec ) { $ constructor = explode ( '::' , $ classSpec ) ; if ( 2 === count ( $ constructor ) ) { return call_user_func ( $ constructor ) ; } return new $ constructor [ 0 ] ; }
|
Creates container from string - based class spec .
|
9,020
|
private function createResolvers ( $ container , $ autowire ) { if ( ! $ container instanceof ContainerInterface ) { throw new WrongContainerClassException ( sprintf ( 'Service container is expected to implement `Psr\Container\ContainerInterface`, but `%s` does not.' , get_class ( $ container ) ) , get_class ( $ container ) ) ; } if ( $ autowire ) { return array ( new ServicesResolver ( $ container ) , new AutowiringResolver ( $ container ) ) ; } return array ( new ServicesResolver ( $ container ) ) ; }
|
Checks if container implements the correct interface and creates resolver using it .
|
9,021
|
protected function isMatchTagFilter ( FeatureNode $ feature , ScenarioInterface $ scenario , $ filterString ) { $ filter = new TagFilter ( $ filterString ) ; if ( $ filter -> isFeatureMatch ( $ feature ) ) { return true ; } return $ filter -> isScenarioMatch ( $ feature , $ scenario ) ; }
|
Checks if node match tag filter .
|
9,022
|
protected function isMatchNameFilter ( ScenarioInterface $ scenario , $ filterString ) { $ filter = new NameFilter ( $ filterString ) ; return $ filter -> isScenarioMatch ( $ scenario ) ; }
|
Checks if scenario matches name filter .
|
9,023
|
private function isMatchTagFilter ( FeatureNode $ feature , $ filterString ) { $ filter = new TagFilter ( $ filterString ) ; return $ filter -> isFeatureMatch ( $ feature ) ; }
|
Checks if feature matches tag filter .
|
9,024
|
private function isMatchNameFilter ( FeatureNode $ feature , $ filterString ) { $ filter = new NameFilter ( $ filterString ) ; return $ filter -> isFeatureMatch ( $ feature ) ; }
|
Checks if feature matches name filter .
|
9,025
|
private function isEventDelayedUntilFirstBackgroundPrinted ( Event $ event ) { if ( ! $ event instanceof ScenarioTested && ! $ event instanceof OutlineTested && ! $ event instanceof ExampleTested ) { return false ; } return ! $ this -> firstBackgroundEnded && $ event -> getFeature ( ) -> hasBackground ( ) ; }
|
Checks if provided event should be postponed until background is printed .
|
9,026
|
private function fireDelayedEventsOnAfterBackground ( Formatter $ formatter , $ eventName ) { if ( BackgroundTested :: AFTER !== $ eventName ) { return ; } foreach ( $ this -> delayedUntilBackgroundEnd as $ eventInfo ) { list ( $ event , $ eventName ) = $ eventInfo ; $ this -> descendant -> listenEvent ( $ formatter , $ event , $ eventName ) ; } $ this -> delayedUntilBackgroundEnd = array ( ) ; }
|
Fires delayed events on AFTER background event .
|
9,027
|
private function printAndCaptureOutlineHeaderOnBeforeEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof BeforeOutlineTested ) { return ; } $ this -> outlinePrinter -> printHeader ( $ formatter , $ event -> getFeature ( ) , $ event -> getOutline ( ) ) ; }
|
Prints outline header and captures outline into ivar on BEFORE event .
|
9,028
|
private function printAndForgetOutlineFooterOnAfterEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterOutlineTested ) { return ; } $ this -> outlinePrinter -> printFooter ( $ formatter , $ event -> getTestResult ( ) ) ; }
|
Prints outline footer and removes outline from ivar on AFTER event .
|
9,029
|
private function printExampleHeaderOnBeforeExampleEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterScenarioSetup ) { return ; } $ this -> example = $ event -> getScenario ( ) ; $ this -> exampleSetupPrinter -> printSetup ( $ formatter , $ event -> getSetup ( ) ) ; $ this -> examplePrinter -> printHeader ( $ formatter , $ event -> getFeature ( ) , $ this -> example ) ; }
|
Prints example header on example BEFORE event .
|
9,030
|
private function printExampleFooterOnAfterExampleEvent ( Formatter $ formatter , Event $ event , $ eventName ) { if ( ! $ event instanceof AfterScenarioTested || ExampleTested :: AFTER !== $ eventName ) { return ; } $ this -> examplePrinter -> printFooter ( $ formatter , $ event -> getTestResult ( ) ) ; $ this -> exampleSetupPrinter -> printTeardown ( $ formatter , $ event -> getTeardown ( ) ) ; $ this -> example = null ; }
|
Prints example footer on example AFTER event .
|
9,031
|
private function printStepSetupOnBeforeStepEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterStepSetup ) { return ; } $ this -> stepSetupPrinter -> printSetup ( $ formatter , $ event -> getSetup ( ) ) ; }
|
Prints step setup on step BEFORE event .
|
9,032
|
private function printStepOnAfterStepEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterStepTested ) { return ; } $ this -> stepPrinter -> printStep ( $ formatter , $ this -> example , $ event -> getStep ( ) , $ event -> getTestResult ( ) ) ; $ this -> stepSetupPrinter -> printTeardown ( $ formatter , $ event -> getTeardown ( ) ) ; }
|
Prints example step on step AFTER event .
|
9,033
|
public function supportsDefinitionAndArgument ( RegexGenerator $ regexGenerator , DefinitionCall $ definitionCall , $ argumentValue ) { $ regex = $ regexGenerator -> generateRegex ( $ definitionCall -> getEnvironment ( ) -> getSuite ( ) -> getName ( ) , $ this -> pattern , $ definitionCall -> getFeature ( ) -> getLanguage ( ) ) ; return $ this -> match ( $ regex , $ argumentValue , $ match ) ; }
|
Checks if transformer supports argument .
|
9,034
|
public function transformArgument ( RegexGenerator $ regexGenerator , CallCenter $ callCenter , DefinitionCall $ definitionCall , $ argumentValue ) { $ regex = $ regexGenerator -> generateRegex ( $ definitionCall -> getEnvironment ( ) -> getSuite ( ) -> getName ( ) , $ this -> pattern , $ definitionCall -> getFeature ( ) -> getLanguage ( ) ) ; $ this -> match ( $ regex , $ argumentValue , $ arguments ) ; $ call = new TransformationCall ( $ definitionCall -> getEnvironment ( ) , $ definitionCall -> getCallee ( ) , $ this , $ arguments ) ; $ result = $ callCenter -> makeCall ( $ call ) ; if ( $ result -> hasException ( ) ) { throw $ result -> getException ( ) ; } return $ result -> getReturn ( ) ; }
|
Transforms argument value using transformation and returns a new one .
|
9,035
|
public function registerUndefinedStep ( Environment $ environment , StepNode $ step ) { $ this -> undefinedSteps [ ] = new UndefinedStep ( $ environment , $ step ) ; $ this -> snippetsGenerated = false ; }
|
Generates and registers snippet .
|
9,036
|
private function generateSnippets ( ) { if ( $ this -> snippetsGenerated ) { return null ; } $ snippetsSet = array ( ) ; foreach ( $ this -> undefinedSteps as $ i => $ undefinedStep ) { $ snippet = $ this -> generateSnippet ( $ undefinedStep -> getEnvironment ( ) , $ undefinedStep -> getStep ( ) ) ; if ( ! $ snippet ) { continue ; } if ( ! isset ( $ snippetsSet [ $ snippet -> getHash ( ) ] ) ) { $ snippetsSet [ $ snippet -> getHash ( ) ] = array ( ) ; } $ snippetsSet [ $ snippet -> getHash ( ) ] [ ] = $ snippet ; unset ( $ this -> undefinedSteps [ $ i ] ) ; } $ this -> snippets = array_values ( array_map ( function ( array $ snippets ) { return new AggregateSnippet ( $ snippets ) ; } , $ snippetsSet ) ) ; $ this -> undefinedSteps = array_values ( $ this -> undefinedSteps ) ; $ this -> snippetsGenerated = true ; }
|
Generates snippets for undefined steps .
|
9,037
|
private function captureScenarioOnBeforeFeatureEvent ( Event $ event ) { if ( ! $ event instanceof BeforeScenarioTested ) { return ; } $ this -> scenarioTitle = sprintf ( '%s: %s' , $ event -> getScenario ( ) -> getKeyword ( ) , $ event -> getScenario ( ) -> getTitle ( ) ) ; $ this -> scenarioPath = sprintf ( '%s:%s' , $ this -> currentFeaturePath , $ event -> getScenario ( ) -> getLine ( ) ) ; }
|
Captures current scenario title and path on scenario BEFORE event .
|
9,038
|
private function captureStepStatsOnAfterEvent ( Event $ event ) { if ( ! $ event instanceof AfterStepTested ) { return ; } $ result = $ event -> getTestResult ( ) ; $ step = $ event -> getStep ( ) ; $ text = sprintf ( '%s %s' , $ step -> getKeyword ( ) , $ step -> getText ( ) ) ; $ exception = $ this -> getStepException ( $ result ) ; $ path = $ this -> getStepPath ( $ event , $ exception ) ; $ error = $ exception ? $ this -> exceptionPresenter -> presentException ( $ exception ) : null ; $ stdOut = $ result instanceof ExecutedStepResult ? $ result -> getCallResult ( ) -> getStdOut ( ) : null ; $ resultCode = $ result -> getResultCode ( ) ; $ stat = new StepStatV2 ( $ this -> scenarioTitle , $ this -> scenarioPath , $ text , $ path , $ resultCode , $ error , $ stdOut ) ; $ this -> statistics -> registerStepStat ( $ stat ) ; }
|
Captures step stats on step AFTER event .
|
9,039
|
private function getStepPath ( AfterStepTested $ event , Exception $ exception = null ) { $ path = sprintf ( '%s:%d' , $ this -> currentFeaturePath , $ event -> getStep ( ) -> getLine ( ) ) ; if ( $ exception && $ exception instanceof PendingException ) { $ path = $ event -> getTestResult ( ) -> getStepDefinition ( ) -> getPath ( ) ; } return $ path ; }
|
Gets step path from the AFTER test event and exception .
|
9,040
|
public function autowireArguments ( ReflectionFunctionAbstract $ reflection , array $ arguments ) { $ newArguments = $ arguments ; foreach ( $ reflection -> getParameters ( ) as $ index => $ parameter ) { if ( $ this -> isArgumentWireable ( $ newArguments , $ index , $ parameter ) ) { $ newArguments [ $ index ] = $ this -> container -> get ( $ parameter -> getClass ( ) -> getName ( ) ) ; } } return $ newArguments ; }
|
Autowires given arguments using provided container .
|
9,041
|
private function isArgumentWireable ( array $ arguments , $ index , ReflectionParameter $ parameter ) { if ( isset ( $ arguments [ $ index ] ) || array_key_exists ( $ index , $ arguments ) ) { return false ; } if ( isset ( $ arguments [ $ parameter -> getName ( ) ] ) || array_key_exists ( $ parameter -> getName ( ) , $ arguments ) ) { return false ; } try { return ( bool ) $ parameter -> getClass ( ) ; } catch ( ReflectionException $ e ) { return false ; } }
|
Checks if given argument is wireable .
|
9,042
|
private function resultCallHasOutput ( ) { if ( ! $ this -> result instanceof ExecutedStepResult ) { return false ; } return $ this -> result -> getCallResult ( ) -> hasStdOut ( ) || $ this -> result -> getCallResult ( ) -> hasException ( ) ; }
|
Checks if result is executed and call result has produced exception or stdOut .
|
9,043
|
private function loadFinder ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\DefinitionFinder' ) ; $ container -> setDefinition ( self :: FINDER_ID , $ definition ) ; }
|
Loads definition finder .
|
9,044
|
private function loadWriter ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\DefinitionWriter' , array ( new Reference ( EnvironmentExtension :: MANAGER_ID ) , new Reference ( self :: REPOSITORY_ID ) ) ) ; $ container -> setDefinition ( self :: WRITER_ID , $ definition ) ; }
|
Loads definition writer .
|
9,045
|
private function loadPatternTransformer ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Pattern\PatternTransformer' ) ; $ container -> setDefinition ( self :: PATTERN_TRANSFORMER_ID , $ definition ) ; }
|
Loads definition pattern transformer .
|
9,046
|
private function loadDefinitionTranslator ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Translator\DefinitionTranslator' , array ( new Reference ( TranslatorExtension :: TRANSLATOR_ID ) ) ) ; $ container -> setDefinition ( self :: DEFINITION_TRANSLATOR_ID , $ definition ) ; }
|
Loads definition translator .
|
9,047
|
private function loadDefaultSearchEngines ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Search\RepositorySearchEngine' , array ( new Reference ( self :: REPOSITORY_ID ) , new Reference ( self :: PATTERN_TRANSFORMER_ID ) , new Reference ( self :: DEFINITION_TRANSLATOR_ID ) , new Reference ( ArgumentExtension :: PREG_MATCH_ARGUMENT_ORGANISER_ID ) ) ) ; $ definition -> addTag ( self :: SEARCH_ENGINE_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: SEARCH_ENGINE_TAG . '.repository' , $ definition ) ; }
|
Loads default search engines .
|
9,048
|
private function loadDefaultPatternPolicies ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Pattern\Policy\TurnipPatternPolicy' ) ; $ definition -> addTag ( self :: PATTERN_POLICY_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: PATTERN_POLICY_TAG . '.turnip' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Definition\Pattern\Policy\RegexPatternPolicy' ) ; $ definition -> addTag ( self :: PATTERN_POLICY_TAG , array ( 'priority' => 60 ) ) ; $ container -> setDefinition ( self :: PATTERN_POLICY_TAG . '.regex' , $ definition ) ; }
|
Loads default pattern policies .
|
9,049
|
private function loadDefinitionPrinters ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Printer\ConsoleDefinitionInformationPrinter' , array ( new Reference ( CliExtension :: OUTPUT_ID ) , new Reference ( self :: PATTERN_TRANSFORMER_ID ) , new Reference ( self :: DEFINITION_TRANSLATOR_ID ) , new Reference ( GherkinExtension :: KEYWORDS_ID ) ) ) ; $ container -> setDefinition ( $ this -> getInformationPrinterId ( ) , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Definition\Printer\ConsoleDefinitionListPrinter' , array ( new Reference ( CliExtension :: OUTPUT_ID ) , new Reference ( self :: PATTERN_TRANSFORMER_ID ) , new Reference ( self :: DEFINITION_TRANSLATOR_ID ) , new Reference ( GherkinExtension :: KEYWORDS_ID ) ) ) ; $ container -> setDefinition ( $ this -> getListPrinterId ( ) , $ definition ) ; }
|
Loads definition printers .
|
9,050
|
private function loadController ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Definition\Cli\AvailableDefinitionsController' , array ( new Reference ( SuiteExtension :: REGISTRY_ID ) , new Reference ( self :: WRITER_ID ) , new Reference ( $ this -> getListPrinterId ( ) ) , new Reference ( $ this -> getInformationPrinterId ( ) ) ) ) ; $ definition -> addTag ( CliExtension :: CONTROLLER_TAG , array ( 'priority' => 500 ) ) ; $ container -> setDefinition ( CliExtension :: CONTROLLER_TAG . '.available_definitions' , $ definition ) ; }
|
Loads definition controller .
|
9,051
|
private function processPatternPolicies ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: PATTERN_POLICY_TAG ) ; $ definition = $ container -> getDefinition ( self :: PATTERN_TRANSFORMER_ID ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerPatternPolicy' , array ( $ reference ) ) ; } }
|
Processes all pattern policies .
|
9,052
|
private function match ( Definition $ definition , $ stepText , array $ multiline ) { $ regex = $ this -> patternTransformer -> transformPatternToRegex ( $ definition -> getPattern ( ) ) ; if ( ! preg_match ( $ regex , $ stepText , $ match ) ) { return null ; } $ function = $ definition -> getReflection ( ) ; $ match = array_merge ( $ match , array_values ( $ multiline ) ) ; $ arguments = $ this -> argumentOrganiser -> organiseArguments ( $ function , $ match ) ; return new SearchResult ( $ definition , $ stepText , $ arguments ) ; }
|
Attempts to match provided definition against a step text .
|
9,053
|
public function exitOnFailure ( AfterScenarioTested $ event ) { if ( ! $ this -> resultInterpretation -> isFailure ( $ event -> getTestResult ( ) ) ) { return ; } $ this -> eventDispatcher -> dispatch ( SuiteTested :: AFTER , new AfterSuiteAborted ( $ event -> getEnvironment ( ) ) ) ; $ this -> eventDispatcher -> dispatch ( ExerciseCompleted :: AFTER , new AfterExerciseAborted ( ) ) ; exit ( 1 ) ; }
|
Exits if scenario is a failure and if stopper is enabled .
|
9,054
|
public function printStep ( Formatter $ formatter , Scenario $ scenario , StepNode $ step , StepResult $ result ) { $ outputPrinter = $ formatter -> getOutputPrinter ( ) ; $ message = $ step -> getKeyword ( ) . ' ' . $ step -> getText ( ) ; if ( $ result instanceof ExceptionResult && $ result -> hasException ( ) ) { $ message .= ': ' . $ this -> exceptionPresenter -> presentException ( $ result -> getException ( ) ) ; } $ attributes = array ( 'message' => $ message ) ; switch ( $ result -> getResultCode ( ) ) { case TestResult :: FAILED : $ outputPrinter -> addTestcaseChild ( 'failure' , $ attributes ) ; break ; case TestResult :: PENDING : $ attributes [ 'type' ] = 'pending' ; $ outputPrinter -> addTestcaseChild ( 'error' , $ attributes ) ; break ; case StepResult :: UNDEFINED : $ attributes [ 'type' ] = 'undefined' ; $ outputPrinter -> addTestcaseChild ( 'error' , $ attributes ) ; break ; } }
|
Prints step using provided printer .
|
9,055
|
private function createInstance ( $ id ) { $ schema = $ this -> getAndValidateServiceSchema ( $ id ) ; $ reflection = new ReflectionClass ( $ schema [ 'class' ] ) ; $ arguments = $ schema [ 'arguments' ] ; if ( $ factoryMethod = $ this -> getAndValidateFactoryMethod ( $ reflection , $ schema ) ) { return $ factoryMethod -> invokeArgs ( null , $ arguments ) ; } return $ reflection -> newInstanceArgs ( $ arguments ) ; }
|
Creates an instance of given service .
|
9,056
|
private function getAndValidateServiceSchema ( $ id ) { $ schema = $ this -> schema [ $ id ] ; if ( null === $ schema ) { $ schema = array ( 'class' => $ id ) ; } if ( is_string ( $ schema ) ) { $ schema = array ( 'class' => $ schema ) ; } $ schema [ 'class' ] = $ this -> getAndValidateClass ( $ id , $ schema ) ; $ schema [ 'arguments' ] = $ this -> getAndValidateArguments ( $ schema ) ; return $ schema ; }
|
Gets and validates a service configuration for a service with given ID .
|
9,057
|
private function getAndValidateFactoryMethod ( ReflectionClass $ reflection , array $ schema ) { if ( ! isset ( $ schema [ 'factory_method' ] ) ) { return null ; } $ factoryMethod = $ schema [ 'factory_method' ] ; $ this -> assertFactoryMethodExists ( $ reflection , $ factoryMethod ) ; $ method = $ reflection -> getMethod ( $ factoryMethod ) ; $ this -> assertFactoryMethodIsStatic ( $ method ) ; return $ method ; }
|
Gets and validates a factory method .
|
9,058
|
private function assertFactoryMethodIsStatic ( ReflectionMethod $ method ) { if ( ! $ method -> isStatic ( ) ) { throw new WrongServicesConfigurationException ( sprintf ( 'Service factory methods must be static, but `%s::%s` is not.' , $ method -> getDeclaringClass ( ) -> getName ( ) , $ method -> getName ( ) ) ) ; } }
|
Checks if factory method is static .
|
9,059
|
private function captureHookStatsOnEvent ( Event $ event ) { if ( $ event instanceof AfterSetup && $ event -> getSetup ( ) instanceof HookedSetup ) { $ this -> captureBeforeHookStats ( $ event -> getSetup ( ) ) ; } if ( $ event instanceof AfterTested && $ event -> getTeardown ( ) instanceof HookedTeardown ) { $ this -> captureAfterHookStats ( $ event -> getTeardown ( ) ) ; } }
|
Captures hook stats on hooked event .
|
9,060
|
private function captureHookStat ( CallResult $ hookCallResult ) { $ callee = $ hookCallResult -> getCall ( ) -> getCallee ( ) ; $ hook = ( string ) $ callee ; $ path = $ callee -> getPath ( ) ; $ stdOut = $ hookCallResult -> getStdOut ( ) ; $ error = $ hookCallResult -> getException ( ) ? $ this -> exceptionPresenter -> presentException ( $ hookCallResult -> getException ( ) ) : null ; $ stat = new HookStat ( $ hook , $ path , $ error , $ stdOut ) ; $ this -> statistics -> registerHookStat ( $ stat ) ; }
|
Captures hook call result .
|
9,061
|
private function simpleTransformations ( ) { $ transformations = array ( ) ; $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\RowBasedTableTransformation' ; $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\ColumnBasedTableTransformation' ; $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\TableRowTransformation' ; if ( PHP_VERSION_ID >= 70000 ) { $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\TokenNameAndReturnTypeTransformation' ; $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\ReturnTypeTransformation' ; } $ transformations [ ] = 'Behat\Behat\Transformation\Transformation\TokenNameTransformation' ; return $ transformations ; }
|
Returns list of default transformations .
|
9,062
|
private function printTags ( OutputPrinter $ printer , array $ tags ) { if ( ! count ( $ tags ) ) { return ; } $ tags = array_map ( array ( $ this , 'prependTagWithTagSign' ) , $ tags ) ; $ printer -> writeln ( sprintf ( '%s{+tag}%s{-tag}' , $ this -> indentText , implode ( ' ' , $ tags ) ) ) ; }
|
Prints feature tags .
|
9,063
|
private function printTitle ( OutputPrinter $ printer , FeatureNode $ feature ) { $ printer -> write ( sprintf ( '%s{+keyword}%s:{-keyword}' , $ this -> indentText , $ feature -> getKeyword ( ) ) ) ; if ( $ title = $ feature -> getTitle ( ) ) { $ printer -> write ( sprintf ( ' %s' , $ title ) ) ; } $ printer -> writeln ( ) ; }
|
Prints feature title using provided printer .
|
9,064
|
private function printDescription ( OutputPrinter $ printer , FeatureNode $ feature ) { if ( ! $ feature -> getDescription ( ) ) { $ printer -> writeln ( ) ; return ; } foreach ( explode ( "\n" , $ feature -> getDescription ( ) ) as $ descriptionLine ) { $ printer -> writeln ( sprintf ( '%s%s' , $ this -> subIndentText , $ descriptionLine ) ) ; } $ printer -> writeln ( ) ; }
|
Prints feature description using provided printer .
|
9,065
|
public function registerUndefinedStep ( AfterStepTested $ event ) { if ( StepResult :: UNDEFINED === $ event -> getTestResult ( ) -> getResultCode ( ) ) { $ this -> registry -> registerUndefinedStep ( $ event -> getEnvironment ( ) , $ event -> getStep ( ) ) ; } }
|
Registers undefined step .
|
9,066
|
public function appendAllSnippets ( ) { $ snippets = $ this -> registry -> getSnippets ( ) ; count ( $ snippets ) && $ this -> output -> writeln ( '' ) ; $ this -> writer -> appendSnippets ( $ snippets ) ; }
|
Appends all snippets to corresponding targets .
|
9,067
|
public function printAllSnippets ( ) { $ snippets = $ this -> registry -> getSnippets ( ) ; count ( $ snippets ) && $ this -> output -> writeln ( '' ) ; $ this -> writer -> printSnippets ( $ this -> printer , $ snippets ) ; }
|
Prints all snippets .
|
9,068
|
public function printUndefinedSteps ( ) { $ undefined = $ this -> registry -> getUndefinedSteps ( ) ; count ( $ undefined ) && $ this -> output -> writeln ( '' ) ; $ this -> writer -> printUndefinedSteps ( $ this -> printer , $ undefined ) ; }
|
Prints all undefined steps .
|
9,069
|
private function askQuestion ( $ message , $ choices , $ default ) { $ this -> output -> writeln ( '' ) ; $ helper = new QuestionHelper ( ) ; $ question = new ChoiceQuestion ( ' ' . $ message . "\n" , $ choices , $ default ) ; return $ helper -> ask ( $ this -> input , $ this -> output , $ question ) ; }
|
Asks user question .
|
9,070
|
public function getSteps ( ) { return array_unique ( array_map ( function ( Snippet $ snippet ) { return $ snippet -> getStep ( ) ; } , $ this -> snippets ) , SORT_REGULAR ) ; }
|
Returns all steps interested in this snippet .
|
9,071
|
public function getUsedClasses ( ) { if ( empty ( $ this -> snippets ) ) { return array ( ) ; } return array_unique ( call_user_func_array ( 'array_merge' , array_map ( function ( Snippet $ snippet ) { if ( ! $ snippet instanceof ContextSnippet ) { return array ( ) ; } return $ snippet -> getUsedClasses ( ) ; } , $ this -> snippets ) ) ) ; }
|
Returns the classes used in the snippet which should be imported .
|
9,072
|
public function registerContextClass ( $ contextClass , array $ arguments = null ) { if ( ! class_exists ( $ contextClass ) ) { throw new ContextNotFoundException ( sprintf ( '`%s` context class not found and can not be used.' , $ contextClass ) , $ contextClass ) ; } $ reflClass = new \ ReflectionClass ( $ contextClass ) ; if ( ! $ reflClass -> implementsInterface ( 'Behat\Behat\Context\Context' ) ) { throw new WrongContextClassException ( sprintf ( 'Every context class must implement Behat Context interface, but `%s` does not.' , $ contextClass ) , $ contextClass ) ; } $ this -> contextClasses [ $ contextClass ] = $ arguments ? : array ( ) ; }
|
Registers context class .
|
9,073
|
private function getWrapperClosure ( OutlineNode $ outline , ExampleNode $ example , array $ stepEvents ) { $ resultConverter = $ this -> resultConverter ; return function ( $ value , $ column ) use ( $ outline , $ example , $ stepEvents , $ resultConverter ) { $ results = array ( ) ; foreach ( $ stepEvents as $ event ) { $ index = array_search ( $ event -> getStep ( ) , $ example -> getSteps ( ) ) ; $ header = $ outline -> getExampleTable ( ) -> getRow ( 0 ) ; $ steps = $ outline -> getSteps ( ) ; $ outlineStepText = $ steps [ $ index ] -> getText ( ) ; if ( false !== strpos ( $ outlineStepText , '<' . $ header [ $ column ] . '>' ) ) { $ results [ ] = $ event -> getTestResult ( ) ; } } $ result = new TestResults ( $ results ) ; $ style = $ resultConverter -> convertResultToString ( $ result ) ; return sprintf ( '{+%s}%s{-%s}' , $ style , $ value , $ style ) ; } ; }
|
Creates wrapper - closure for the example table .
|
9,074
|
private function getMethodName ( $ contextClass , $ canonicalText , $ pattern ) { $ methodName = $ this -> deduceMethodName ( $ canonicalText ) ; $ methodName = $ this -> getUniqueMethodName ( $ contextClass , $ pattern , $ methodName ) ; return $ methodName ; }
|
Generates method name using step text and regex .
|
9,075
|
private function getMethodArguments ( StepNode $ step , $ tokenCount ) { $ args = array ( ) ; for ( $ i = 0 ; $ i < $ tokenCount ; $ i ++ ) { $ args [ ] = '$arg' . ( $ i + 1 ) ; } foreach ( $ step -> getArguments ( ) as $ argument ) { $ args [ ] = $ this -> getMethodArgument ( $ argument ) ; } return $ args ; }
|
Returns an array of method argument names from step and token count .
|
9,076
|
private function getUsedClasses ( StepNode $ step ) { $ usedClasses = array ( 'Behat\Behat\Tester\Exception\PendingException' ) ; foreach ( $ step -> getArguments ( ) as $ argument ) { if ( $ argument instanceof TableNode ) { $ usedClasses [ ] = 'Behat\Gherkin\Node\TableNode' ; } elseif ( $ argument instanceof PyStringNode ) { $ usedClasses [ ] = 'Behat\Gherkin\Node\PyStringNode' ; } } return $ usedClasses ; }
|
Returns an array of classes used by the snippet template
|
9,077
|
private function getSnippetTemplate ( $ pattern , $ methodName , array $ methodArguments ) { return sprintf ( self :: $ templateTemplate , str_replace ( '%' , '%%' , $ pattern ) , $ methodName , implode ( ', ' , $ methodArguments ) ) ; }
|
Generates snippet template using regex method name and arguments .
|
9,078
|
private function getUniqueMethodName ( $ contextClass , $ stepPattern , $ name ) { $ reflection = new ReflectionClass ( $ contextClass ) ; $ number = $ this -> getMethodNumberFromTheMethodName ( $ name ) ; list ( $ name , $ number ) = $ this -> getMethodNameNotExistentInContext ( $ reflection , $ name , $ number ) ; $ name = $ this -> getMethodNameNotProposedEarlier ( $ contextClass , $ stepPattern , $ name , $ number ) ; return $ name ; }
|
Ensures uniqueness of the method name in the context .
|
9,079
|
private function getMethodNumberFromTheMethodName ( $ methodName ) { $ methodNumber = 2 ; if ( preg_match ( '/(\d+)$/' , $ methodName , $ matches ) ) { $ methodNumber = intval ( $ matches [ 1 ] ) ; } return $ methodNumber ; }
|
Tries to deduct method number from the provided method name .
|
9,080
|
private function getMethodNameNotExistentInContext ( ReflectionClass $ reflection , $ methodName , $ methodNumber ) { while ( $ reflection -> hasMethod ( $ methodName ) ) { $ methodName = preg_replace ( '/\d+$/' , '' , $ methodName ) ; $ methodName .= $ methodNumber ++ ; } return array ( $ methodName , $ methodNumber ) ; }
|
Tries to guess method name that is not yet defined in the context class .
|
9,081
|
private function getMethodNameNotProposedEarlier ( $ contextClass , $ stepPattern , $ name , $ number ) { foreach ( $ this -> getAlreadyProposedMethods ( $ contextClass ) as $ proposedPattern => $ proposedMethod ) { if ( $ proposedPattern === $ stepPattern ) { continue ; } while ( $ proposedMethod === $ name ) { $ name = preg_replace ( '/\d+$/' , '' , $ name ) ; $ name .= $ number ++ ; } } $ this -> markMethodAsAlreadyProposed ( $ contextClass , $ stepPattern , $ name ) ; return $ name ; }
|
Tries to guess method name that is not yet proposed to the context class .
|
9,082
|
private function getMethodArgument ( $ argument ) { $ arg = '__unknown__' ; if ( $ argument instanceof PyStringNode ) { $ arg = 'PyStringNode $string' ; } elseif ( $ argument instanceof TableNode ) { $ arg = 'TableNode $table' ; } return $ arg ; }
|
Returns method argument .
|
9,083
|
private function printHeaderOnBeforeEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterFeatureSetup ) { return ; } $ this -> setupPrinter -> printSetup ( $ formatter , $ event -> getSetup ( ) ) ; $ this -> featurePrinter -> printHeader ( $ formatter , $ event -> getFeature ( ) ) ; }
|
Prints feature header on BEFORE event .
|
9,084
|
private function printFooterOnAfterEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterFeatureTested ) { return ; } $ this -> setupPrinter -> printTeardown ( $ formatter , $ event -> getTeardown ( ) ) ; $ this -> featurePrinter -> printFooter ( $ formatter , $ event -> getTestResult ( ) ) ; }
|
Prints feature footer on AFTER event .
|
9,085
|
public function findDefinition ( Environment $ environment , FeatureNode $ feature , StepNode $ step ) { foreach ( $ this -> engines as $ engine ) { $ result = $ engine -> searchDefinition ( $ environment , $ feature , $ step ) ; if ( null !== $ result && $ result -> hasMatch ( ) ) { return $ result ; } } return new SearchResult ( ) ; }
|
Searches definition for a provided step in a provided environment .
|
9,086
|
public function printScenariosList ( OutputPrinter $ printer , $ intro , $ resultCode , array $ scenarioStats ) { if ( ! count ( $ scenarioStats ) ) { return ; } $ style = $ this -> resultConverter -> convertResultCodeToString ( $ resultCode ) ; $ intro = $ this -> translator -> trans ( $ intro , array ( ) , 'output' ) ; $ printer -> writeln ( sprintf ( '--- {+%s}%s{-%s}' . PHP_EOL , $ style , $ intro , $ style ) ) ; foreach ( $ scenarioStats as $ stat ) { $ path = $ this -> relativizePaths ( ( string ) $ stat ) ; $ printer -> writeln ( sprintf ( ' {+%s}%s{-%s}' , $ style , $ path , $ style ) ) ; } $ printer -> writeln ( ) ; }
|
Prints scenarios list .
|
9,087
|
public function printStepList ( OutputPrinter $ printer , $ intro , $ resultCode , array $ stepStats ) { if ( ! count ( $ stepStats ) ) { return ; } $ style = $ this -> resultConverter -> convertResultCodeToString ( $ resultCode ) ; $ intro = $ this -> translator -> trans ( $ intro , array ( ) , 'output' ) ; $ printer -> writeln ( sprintf ( '--- {+%s}%s{-%s}' . PHP_EOL , $ style , $ intro , $ style ) ) ; foreach ( $ stepStats as $ num => $ stepStat ) { if ( $ stepStat instanceof StepStatV2 ) { $ this -> printStepStat ( $ printer , $ num + 1 , $ stepStat , $ style ) ; } elseif ( $ stepStat instanceof StepStat ) { $ this -> printStat ( $ printer , $ stepStat -> getText ( ) , $ stepStat -> getPath ( ) , $ style , $ stepStat -> getStdOut ( ) , $ stepStat -> getError ( ) ) ; } } }
|
Prints step list .
|
9,088
|
public function printFailedHooksList ( OutputPrinter $ printer , $ intro , array $ failedHookStats ) { if ( ! count ( $ failedHookStats ) ) { return ; } $ style = $ this -> resultConverter -> convertResultCodeToString ( TestResult :: FAILED ) ; $ intro = $ this -> translator -> trans ( $ intro , array ( ) , 'output' ) ; $ printer -> writeln ( sprintf ( '--- {+%s}%s{-%s}' . PHP_EOL , $ style , $ intro , $ style ) ) ; foreach ( $ failedHookStats as $ hookStat ) { $ this -> printHookStat ( $ printer , $ hookStat , $ style ) ; } }
|
Prints failed hooks list .
|
9,089
|
private function printStatisticsOnAfterExerciseEvent ( Formatter $ formatter , $ eventName ) { if ( ExerciseCompleted :: AFTER !== $ eventName ) { return ; } $ this -> statistics -> stopTimer ( ) ; $ this -> printer -> printStatistics ( $ formatter , $ this -> statistics ) ; }
|
Prints statistics on after exercise event .
|
9,090
|
private function printKeyword ( OutputPrinter $ printer , $ keyword ) { $ printer -> write ( sprintf ( '%s{+keyword}%s:{-keyword}' , $ this -> indentText , $ keyword ) ) ; }
|
Prints scenario keyword .
|
9,091
|
private function transformArgument ( DefinitionCall $ definitionCall , $ index , $ value ) { foreach ( $ this -> argumentTransformers as $ transformer ) { if ( ! $ transformer -> supportsDefinitionAndArgument ( $ definitionCall , $ index , $ value ) ) { continue ; } return $ transformer -> transformArgument ( $ definitionCall , $ index , $ value ) ; } return $ value ; }
|
Transforms call argument using registered transformers .
|
9,092
|
private function captureScenarioEvent ( ScenarioTested $ event ) { if ( $ event instanceof AfterScenarioTested ) { $ this -> afterScenarioTestedEvents [ $ event -> getScenario ( ) -> getLine ( ) ] = array ( 'event' => $ event , 'step_events' => $ this -> afterStepTestedEvents , 'step_setup_events' => $ this -> afterStepSetupEvents , ) ; $ this -> afterStepTestedEvents = array ( ) ; $ this -> afterStepSetupEvents = array ( ) ; } }
|
Captures scenario tested event .
|
9,093
|
public function printFeatureOnAfterEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterFeatureTested ) { return ; } $ this -> featurePrinter -> printHeader ( $ formatter , $ this -> beforeFeatureTestedEvent ) ; foreach ( $ this -> afterScenarioTestedEvents as $ afterScenario ) { $ afterScenarioTested = $ afterScenario [ 'event' ] ; $ this -> scenarioPrinter -> printOpenTag ( $ formatter , $ afterScenarioTested -> getFeature ( ) , $ afterScenarioTested -> getScenario ( ) , $ afterScenarioTested -> getTestResult ( ) ) ; foreach ( $ afterScenario [ 'step_setup_events' ] as $ afterStepSetup ) { $ this -> setupPrinter -> printSetup ( $ formatter , $ afterStepSetup -> getSetup ( ) ) ; } foreach ( $ afterScenario [ 'step_events' ] as $ afterStepTested ) { $ this -> stepPrinter -> printStep ( $ formatter , $ afterScenarioTested -> getScenario ( ) , $ afterStepTested -> getStep ( ) , $ afterStepTested -> getTestResult ( ) ) ; $ this -> setupPrinter -> printTeardown ( $ formatter , $ afterStepTested -> getTeardown ( ) ) ; } } $ this -> featurePrinter -> printFooter ( $ formatter , $ event -> getTestResult ( ) ) ; $ this -> afterScenarioTestedEvents = array ( ) ; }
|
Prints the feature on AFTER event .
|
9,094
|
private function getNormalizedContextClasses ( Suite $ suite ) { return array_map ( function ( $ context ) { return is_array ( $ context ) ? current ( array_keys ( $ context ) ) : $ context ; } , $ this -> getSuiteContexts ( $ suite ) ) ; }
|
Returns normalized context classes .
|
9,095
|
private function getSuiteContexts ( Suite $ suite ) { $ contexts = $ suite -> getSetting ( 'contexts' ) ; if ( ! is_array ( $ contexts ) ) { throw new SuiteConfigurationException ( sprintf ( '`contexts` setting of the "%s" suite is expected to be an array, `%s` given.' , $ suite -> getName ( ) , gettype ( $ contexts ) ) , $ suite -> getName ( ) ) ; } return $ contexts ; }
|
Returns array of context classes configured for the provided suite .
|
9,096
|
private function createContextDirectory ( $ path ) { mkdir ( $ path , 0777 , true ) ; if ( $ this -> logger ) { $ this -> logger -> directoryCreated ( $ path , 'place your context classes here' ) ; } }
|
Creates context directory in the filesystem .
|
9,097
|
private function createContextFile ( $ path , $ content ) { file_put_contents ( $ path , $ content ) ; if ( $ this -> logger ) { $ this -> logger -> fileCreated ( $ path , 'place your definitions, transformations and hooks here' ) ; } }
|
Creates context class file in the filesystem .
|
9,098
|
private function findClassFile ( $ class ) { list ( $ classpath , $ classname ) = $ this -> findClasspathAndClass ( $ class ) ; $ classpath .= str_replace ( '_' , DIRECTORY_SEPARATOR , $ classname ) . '.php' ; foreach ( $ this -> autoloader -> getPrefixes ( ) as $ prefix => $ dirs ) { if ( 0 === strpos ( $ class , $ prefix ) ) { return current ( $ dirs ) . DIRECTORY_SEPARATOR . $ classpath ; } } if ( $ dirs = $ this -> autoloader -> getFallbackDirs ( ) ) { return current ( $ dirs ) . DIRECTORY_SEPARATOR . $ classpath ; } throw new ContextNotFoundException ( sprintf ( 'Could not find where to put "%s" class. Have you configured autoloader properly?' , $ class ) , $ class ) ; }
|
Finds file to store a class .
|
9,099
|
private function generateClass ( Suite $ suite , $ class ) { $ content = null ; foreach ( $ this -> classGenerators as $ generator ) { if ( $ generator -> supportsSuiteAndClass ( $ suite , $ class ) ) { $ content = $ generator -> generateClass ( $ suite , $ class ) ; } } return $ content ; }
|
Generates class using registered class generators .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.