idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
8,900
|
private function countPlaceholders ( $ stepText , $ stepRegex ) { preg_match ( '/^' . $ stepRegex . '$/' , $ stepText , $ matches ) ; return count ( $ matches ) ? count ( $ matches ) - 1 : 0 ; }
|
Counts regex placeholders using provided text .
|
8,901
|
private function getDefaultStyles ( ) { return array ( 'keyword' => new OutputFormatterStyle ( null , null , array ( 'bold' ) ) , 'stdout' => new OutputFormatterStyle ( null , null , array ( ) ) , 'exception' => new OutputFormatterStyle ( 'red' ) , 'undefined' => new OutputFormatterStyle ( 'yellow' ) , 'pending' => new OutputFormatterStyle ( 'yellow' ) , 'pending_param' => new OutputFormatterStyle ( 'yellow' , null , array ( 'bold' ) ) , 'failed' => new OutputFormatterStyle ( 'red' ) , 'failed_param' => new OutputFormatterStyle ( 'red' , null , array ( 'bold' ) ) , 'passed' => new OutputFormatterStyle ( 'green' ) , 'passed_param' => new OutputFormatterStyle ( 'green' , null , array ( 'bold' ) ) , 'skipped' => new OutputFormatterStyle ( 'cyan' ) , 'skipped_param' => new OutputFormatterStyle ( 'cyan' , null , array ( 'bold' ) ) , 'comment' => new OutputFormatterStyle ( 'black' ) , 'tag' => new OutputFormatterStyle ( 'cyan' ) ) ; }
|
Returns default styles .
|
8,902
|
private function printExampleRowOnAfterExampleEvent ( Formatter $ formatter , Event $ event , $ eventName ) { if ( ! $ event instanceof AfterScenarioTested || ExampleTested :: AFTER !== $ eventName ) { return ; } $ example = $ event -> getScenario ( ) ; $ this -> exampleSetupPrinter -> printSetup ( $ formatter , $ this -> exampleSetup ) ; foreach ( $ this -> stepBeforeTestedEvents as $ beforeEvent ) { $ this -> stepSetupPrinter -> printSetup ( $ formatter , $ beforeEvent -> getSetup ( ) ) ; } $ this -> exampleRowPrinter -> printExampleRow ( $ formatter , $ this -> outline , $ example , $ this -> stepAfterTestedEvents ) ; foreach ( $ this -> stepAfterTestedEvents as $ afterEvent ) { $ this -> stepSetupPrinter -> printTeardown ( $ formatter , $ afterEvent -> getTeardown ( ) ) ; } $ this -> exampleSetupPrinter -> printTeardown ( $ formatter , $ event -> getTeardown ( ) ) ; $ this -> exampleSetup = null ; $ this -> stepBeforeTestedEvents = array ( ) ; $ this -> stepAfterTestedEvents = array ( ) ; }
|
Prints example row on example AFTER event .
|
8,903
|
private function printFooterOnAfterEvent ( Formatter $ formatter , Event $ event ) { if ( ! $ event instanceof AfterOutlineTested ) { return ; } $ this -> tablePrinter -> printFooter ( $ formatter , $ event -> getTestResult ( ) ) ; }
|
Prints outline footer on outline AFTER event .
|
8,904
|
public function paintText ( $ text , Definition $ definition , TestResult $ result ) { $ regex = $ this -> patternTransformer -> transformPatternToRegex ( $ definition -> getPattern ( ) ) ; $ style = $ this -> resultConverter -> convertResultToString ( $ result ) ; $ paramStyle = $ style . '_param' ; if ( '/' !== substr ( $ regex , 0 , 1 ) ) { return $ text ; } $ matches = array ( ) ; preg_match ( $ regex , $ text , $ matches , PREG_OFFSET_CAPTURE ) ; array_shift ( $ matches ) ; $ shift = 0 ; $ lastReplacementPosition = 0 ; foreach ( $ matches as $ key => $ match ) { if ( ! is_numeric ( $ key ) || - 1 === $ match [ 1 ] || false !== strpos ( $ match [ 0 ] , '<' ) ) { continue ; } $ offset = $ match [ 1 ] + $ shift ; $ value = $ match [ 0 ] ; if ( $ lastReplacementPosition > $ offset ) { continue ; } $ lastReplacementPosition = $ offset + strlen ( $ value ) ; $ begin = substr ( $ text , 0 , $ offset ) ; $ end = substr ( $ text , $ lastReplacementPosition ) ; $ format = "{-$style}{+$paramStyle}%s{-$paramStyle}{+$style}" ; $ text = sprintf ( "%s{$format}%s" , $ begin , $ value , $ end ) ; $ shift += strlen ( $ format ) - 2 ; $ lastReplacementPosition += strlen ( $ format ) - 2 ; } $ text = preg_replace ( '/(<[^>]+>)/' , "{-$style}{+$paramStyle}\$1{-$paramStyle}{+$style}" , $ text ) ; return $ text ; }
|
Colorizes step text arguments according to definition .
|
8,905
|
private function printExamplesSteps ( Formatter $ formatter , OutlineNode $ outline , array $ steps ) { foreach ( $ steps as $ step ) { $ this -> stepPrinter -> printStep ( $ formatter , $ outline , $ step , new UndefinedStepResult ( ) ) ; } $ formatter -> getOutputPrinter ( ) -> writeln ( ) ; }
|
Prints outline steps .
|
8,906
|
private function printExamplesTableHeader ( OutputPrinter $ printer , ExampleTableNode $ table ) { $ printer -> writeln ( sprintf ( '%s{+keyword}%s:{-keyword}' , $ this -> indentText , $ table -> getKeyword ( ) ) ) ; $ rowNum = 0 ; $ wrapper = $ this -> getWrapperClosure ( ) ; $ row = $ table -> getRowAsStringWithWrappedValues ( $ rowNum , $ wrapper ) ; $ printer -> writeln ( sprintf ( '%s%s' , $ this -> subIndentText , $ row ) ) ; }
|
Prints examples table header .
|
8,907
|
private function getWrapperClosure ( ) { $ style = $ this -> resultConverter -> convertResultCodeToString ( TestResult :: SKIPPED ) ; return function ( $ col ) use ( $ style ) { return sprintf ( '{+%s_param}%s{-%s_param}' , $ style , $ col , $ style ) ; } ; }
|
Creates wrapper - closure for the example header .
|
8,908
|
public function convertResultCodeToString ( $ resultCode ) { switch ( $ resultCode ) { case TestResult :: SKIPPED : return 'skipped' ; case TestResult :: PENDING : return 'pending' ; case TestResult :: FAILED : return 'failed' ; case StepResult :: UNDEFINED : return 'undefined' ; } return 'passed' ; }
|
Converts provided result code to a string .
|
8,909
|
public function calculateScenarioWidth ( Scenario $ scenario , $ indentation , $ subIndentation ) { $ length = $ this -> calculateScenarioHeaderWidth ( $ scenario , $ indentation ) ; foreach ( $ scenario -> getSteps ( ) as $ step ) { $ stepLength = $ this -> calculateStepWidth ( $ step , $ indentation + $ subIndentation ) ; $ length = max ( $ length , $ stepLength ) ; } return $ length ; }
|
Calculates scenario width .
|
8,910
|
public function calculateExampleWidth ( ExampleNode $ example , $ indentation , $ subIndentation ) { $ length = $ this -> calculateScenarioHeaderWidth ( $ example , $ indentation ) ; foreach ( $ example -> getSteps ( ) as $ step ) { $ stepLength = $ this -> calculateStepWidth ( $ step , $ indentation + $ subIndentation ) ; $ length = max ( $ length , $ stepLength ) ; } return $ length ; }
|
Calculates outline examples width .
|
8,911
|
public function calculateScenarioHeaderWidth ( Scenario $ scenario , $ indentation ) { $ indentText = str_repeat ( ' ' , intval ( $ indentation ) ) ; if ( $ scenario instanceof ExampleNode ) { $ header = sprintf ( '%s%s' , $ indentText , $ scenario -> getTitle ( ) ) ; } else { $ title = $ scenario -> getTitle ( ) ; $ lines = explode ( "\n" , $ title ) ; $ header = sprintf ( '%s%s: %s' , $ indentText , $ scenario -> getKeyword ( ) , array_shift ( $ lines ) ) ; } return mb_strlen ( rtrim ( $ header ) , 'utf8' ) ; }
|
Calculates scenario header width .
|
8,912
|
public function calculateStepWidth ( StepNode $ step , $ indentation ) { $ indentText = str_repeat ( ' ' , intval ( $ indentation ) ) ; $ text = sprintf ( '%s%s %s' , $ indentText , $ step -> getKeyword ( ) , $ step -> getText ( ) ) ; return mb_strlen ( $ text , 'utf8' ) ; }
|
Calculates step width .
|
8,913
|
protected function loadDefinitionArgumentsTransformer ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Transformation\Call\Filter\DefinitionArgumentsTransformer' ) ; $ definition -> addTag ( CallExtension :: CALL_FILTER_TAG , array ( 'priority' => 200 ) ) ; $ container -> setDefinition ( $ this -> getDefinitionArgumentTransformerId ( ) , $ definition ) ; }
|
Loads definition arguments transformer .
|
8,914
|
protected function loadDefaultTransformers ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Transformation\Transformer\RepositoryArgumentTransformer' , array ( new Reference ( self :: REPOSITORY_ID ) , new Reference ( CallExtension :: CALL_CENTER_ID ) , new Reference ( DefinitionExtension :: PATTERN_TRANSFORMER_ID ) , new Reference ( TranslatorExtension :: TRANSLATOR_ID ) ) ) ; $ definition -> addTag ( self :: ARGUMENT_TRANSFORMER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: ARGUMENT_TRANSFORMER_TAG . '.repository' , $ definition ) ; }
|
Loads default transformers .
|
8,915
|
protected function loadRepository ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Transformation\TransformationRepository' , array ( new Reference ( EnvironmentExtension :: MANAGER_ID ) ) ) ; $ container -> setDefinition ( self :: REPOSITORY_ID , $ definition ) ; }
|
Loads transformations repository .
|
8,916
|
protected function processArgumentsTransformers ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: ARGUMENT_TRANSFORMER_TAG ) ; $ definition = $ container -> getDefinition ( $ this -> getDefinitionArgumentTransformerId ( ) ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerArgumentTransformer' , array ( $ reference ) ) ; } }
|
Processes all available argument transformers .
|
8,917
|
public function iRunBehatInteractively ( $ answerString , $ argumentsString ) { $ env = $ this -> process -> getEnv ( ) ; $ env [ 'SHELL_INTERACTIVE' ] = true ; $ this -> process -> setEnv ( $ env ) ; $ this -> process -> setInput ( $ answerString ) ; $ this -> options = '--format-settings=\'{"timer": false}\'' ; $ this -> iRunBehat ( $ argumentsString ) ; }
|
Runs behat command with provided parameters in interactive mode
|
8,918
|
public function itShouldPassWith ( $ success , PyStringNode $ text ) { $ this -> itShouldFail ( $ success ) ; $ this -> theOutputShouldContain ( $ text ) ; }
|
Checks whether previously ran command passes|fails with provided output .
|
8,919
|
public function fileXmlShouldBeLike ( $ path , PyStringNode $ text ) { $ path = $ this -> workingDir . '/' . $ path ; Assert :: assertFileExists ( $ path ) ; $ fileContent = trim ( file_get_contents ( $ path ) ) ; $ fileContent = preg_replace ( '/time="(.*)"/' , 'time="-IGNORE-VALUE-"' , $ fileContent ) ; $ dom = new DOMDocument ( ) ; $ dom -> loadXML ( $ text ) ; $ dom -> formatOutput = true ; Assert :: assertEquals ( trim ( $ dom -> saveXML ( null , LIBXML_NOEMPTYTAG ) ) , $ fileContent ) ; }
|
Checks whether specified content and structure of the xml is correct without worrying about layout .
|
8,920
|
public function xmlShouldBeValid ( $ xmlFile , $ schemaPath ) { $ dom = new DomDocument ( ) ; $ dom -> load ( $ this -> workingDir . '/' . $ xmlFile ) ; $ dom -> schemaValidate ( __DIR__ . '/schema/' . $ schemaPath ) ; }
|
Checks whether the file is valid according to an XML schema .
|
8,921
|
private function loadAnnotationReader ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Hook\Context\Annotation\HookAnnotationReader' ) ; $ definition -> addTag ( ContextExtension :: ANNOTATION_READER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( ContextExtension :: ANNOTATION_READER_TAG . '.hook' , $ definition ) ; }
|
Loads hook annotation reader .
|
8,922
|
protected function loadRootNodeListener ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Testwork\Output\Node\EventListener\ChainEventListener' , array ( array ( new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\SuiteListener' , array ( new Reference ( 'output.node.printer.pretty.suite_setup' ) ) ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\FeatureListener' , array ( new Reference ( 'output.node.printer.pretty.feature' ) , new Reference ( 'output.node.printer.pretty.feature_setup' ) ) ) , $ this -> proxySiblingEvents ( BackgroundTested :: BEFORE , BackgroundTested :: AFTER , array ( new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\ScenarioNodeListener' , array ( BackgroundTested :: AFTER_SETUP , BackgroundTested :: AFTER , new Reference ( 'output.node.printer.pretty.scenario' ) ) ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\StepListener' , array ( new Reference ( 'output.node.printer.pretty.step' ) , new Reference ( 'output.node.printer.pretty.step_setup' ) ) ) , ) ) , $ this -> proxySiblingEvents ( ScenarioTested :: BEFORE , ScenarioTested :: AFTER , array ( new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\ScenarioNodeListener' , array ( ScenarioTested :: AFTER_SETUP , ScenarioTested :: AFTER , new Reference ( 'output.node.printer.pretty.scenario' ) , new Reference ( 'output.node.printer.pretty.scenario_setup' ) ) ) , new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\StepListener' , array ( new Reference ( 'output.node.printer.pretty.step' ) , new Reference ( 'output.node.printer.pretty.step_setup' ) ) ) , ) ) , $ this -> proxySiblingEvents ( OutlineTested :: BEFORE , OutlineTested :: AFTER , array ( $ this -> proxyEventsIfParameterIsSet ( 'expand' , false , new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\OutlineTableListener' , array ( new Reference ( 'output.node.printer.pretty.outline_table' ) , new Reference ( 'output.node.printer.pretty.example_row' ) , new Reference ( 'output.node.printer.pretty.example_setup' ) , new Reference ( 'output.node.printer.pretty.example_step_setup' ) ) ) ) , $ this -> proxyEventsIfParameterIsSet ( 'expand' , true , new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\OutlineListener' , array ( new Reference ( 'output.node.printer.pretty.outline' ) , new Reference ( 'output.node.printer.pretty.example' ) , new Reference ( 'output.node.printer.pretty.example_step' ) , new Reference ( 'output.node.printer.pretty.example_setup' ) , new Reference ( 'output.node.printer.pretty.example_step_setup' ) ) ) ) ) ) , ) ) ) ; $ container -> setDefinition ( self :: ROOT_LISTENER_ID , $ definition ) ; }
|
Loads pretty formatter node event listener .
|
8,923
|
protected function loadTableOutlinePrinter ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettyOutlineTablePrinter' , array ( new Reference ( 'output.node.printer.pretty.scenario' ) , new Reference ( 'output.node.printer.pretty.skipped_step' ) , new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.outline_table' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettyExampleRowPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.example_row' , $ definition ) ; }
|
Loads table outline printer .
|
8,924
|
protected function loadHookPrinters ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 0 , true , true ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.suite_setup' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 0 , false , true ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.feature_setup' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 2 ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.scenario_setup' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 4 ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.step_setup' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 8 ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.example_step_setup' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\Pretty\PrettySetupPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( ExceptionExtension :: PRESENTER_ID ) , 6 ) ) ; $ container -> setDefinition ( 'output.node.printer.pretty.example_setup' , $ definition ) ; }
|
Loads hook printers .
|
8,925
|
protected function processListenerWrappers ( ContainerBuilder $ container ) { $ this -> processor -> processWrapperServices ( $ container , self :: ROOT_LISTENER_ID , self :: ROOT_LISTENER_WRAPPER_TAG ) ; }
|
Processes all registered pretty formatter node listener wrappers .
|
8,926
|
public function registerScenarioStat ( ScenarioStat $ stat ) { if ( TestResults :: NO_TESTS === $ stat -> getResultCode ( ) ) { return ; } $ this -> scenarioCounters [ $ stat -> getResultCode ( ) ] ++ ; if ( TestResult :: FAILED === $ stat -> getResultCode ( ) ) { $ this -> failedScenarioStats [ ] = $ stat ; } if ( TestResult :: SKIPPED === $ stat -> getResultCode ( ) ) { $ this -> skippedScenarioStats [ ] = $ stat ; } }
|
Registers scenario stat .
|
8,927
|
public function registerStepStat ( StepStat $ stat ) { $ this -> stepCounters [ $ stat -> getResultCode ( ) ] ++ ; if ( TestResult :: FAILED === $ stat -> getResultCode ( ) ) { $ this -> failedStepStats [ ] = $ stat ; } if ( TestResult :: PENDING === $ stat -> getResultCode ( ) ) { $ this -> pendingStepStats [ ] = $ stat ; } }
|
Registers step stat .
|
8,928
|
private function isDefinitionShared ( Definition $ definition ) { if ( method_exists ( $ definition , 'isShared' ) ) { return $ definition -> isShared ( ) ; } else if ( method_exists ( $ definition , 'getScope' ) ) { return $ definition -> getScope ( ) !== ContainerBuilder :: SCOPE_PROTOTYPE ; } return false ; }
|
Checks if provided definition is shared .
|
8,929
|
private function extractHeader ( Suite $ suite , Definition $ definition ) { $ pattern = $ definition -> getPattern ( ) ; $ lines = array ( ) ; $ lines [ ] = strtr ( '{suite} <def_dimmed>|</def_dimmed> <info>{type}</info> <def_regex>{regex}</def_regex>' , array ( '{suite}' => $ suite -> getName ( ) , '{type}' => $ this -> getDefinitionType ( $ definition ) , '{regex}' => $ pattern , ) ) ; return $ lines ; }
|
Extracts the formatted header from the definition .
|
8,930
|
private function extractDescription ( Suite $ suite , Definition $ definition ) { $ definition = $ this -> translateDefinition ( $ suite , $ definition ) ; $ lines = array ( ) ; if ( $ description = $ definition -> getDescription ( ) ) { foreach ( explode ( "\n" , $ description ) as $ descriptionLine ) { $ lines [ ] = strtr ( '{space}<def_dimmed>|</def_dimmed> {description}' , array ( '{space}' => str_pad ( '' , mb_strlen ( $ suite -> getName ( ) , 'utf8' ) + 1 ) , '{description}' => $ descriptionLine ) ) ; } } return $ lines ; }
|
Extracts the formatted description from the definition .
|
8,931
|
private function extractFooter ( Suite $ suite , Definition $ definition ) { $ lines = array ( ) ; $ lines [ ] = strtr ( '{space}<def_dimmed>|</def_dimmed> at `{path}`' , array ( '{space}' => str_pad ( '' , mb_strlen ( $ suite -> getName ( ) , 'utf8' ) + 1 ) , '{path}' => $ definition -> getPath ( ) ) ) ; if ( $ this -> isVerbose ( ) ) { $ lines [ ] = strtr ( '{space}<def_dimmed>|</def_dimmed> on `{filepath}[{start}:{end}]`' , array ( '{space}' => str_pad ( '' , mb_strlen ( $ suite -> getName ( ) , 'utf8' ) + 1 ) , '{filepath}' => $ definition -> getReflection ( ) -> getFileName ( ) , '{start}' => $ definition -> getReflection ( ) -> getStartLine ( ) , '{end}' => $ definition -> getReflection ( ) -> getEndLine ( ) ) ) ; } return $ lines ; }
|
Extracts the formatted footer from the definition .
|
8,932
|
public function printCounters ( OutputPrinter $ printer , $ intro , array $ stats ) { $ stats = array_filter ( $ stats , function ( $ count ) { return 0 !== $ count ; } ) ; if ( 0 === count ( $ stats ) ) { $ totalCount = 0 ; } else { $ totalCount = array_sum ( $ stats ) ; } $ detailedStats = array ( ) ; foreach ( $ stats as $ resultCode => $ count ) { $ style = $ this -> resultConverter -> convertResultCodeToString ( $ resultCode ) ; $ transId = $ style . '_count' ; $ message = $ this -> translator -> transChoice ( $ transId , $ count , array ( '%1%' => $ count ) , 'output' ) ; $ detailedStats [ ] = sprintf ( '{+%s}%s{-%s}' , $ style , $ message , $ style ) ; } $ message = $ this -> translator -> transChoice ( $ intro , $ totalCount , array ( '%1%' => $ totalCount ) , 'output' ) ; $ printer -> write ( $ message ) ; if ( count ( $ detailedStats ) ) { $ printer -> write ( sprintf ( ' (%s)' , implode ( ', ' , $ detailedStats ) ) ) ; } $ printer -> writeln ( ) ; }
|
Prints scenario and step counters .
|
8,933
|
final protected function translateDefinition ( Suite $ suite , Definition $ definition ) { return $ this -> translator -> translateDefinition ( $ suite , $ definition ) ; }
|
Translates definition using translator .
|
8,934
|
public function printScenarioPath ( Formatter $ formatter , FeatureNode $ feature , Scenario $ scenario , $ indentation ) { $ printer = $ formatter -> getOutputPrinter ( ) ; if ( ! $ formatter -> getParameter ( 'paths' ) ) { $ printer -> writeln ( ) ; return ; } $ fileAndLine = sprintf ( '%s:%s' , $ this -> relativizePaths ( $ feature -> getFile ( ) ) , $ scenario -> getLine ( ) ) ; $ headerWidth = $ this -> widthCalculator -> calculateScenarioHeaderWidth ( $ scenario , $ indentation ) ; $ scenarioWidth = $ this -> widthCalculator -> calculateScenarioWidth ( $ scenario , $ indentation , 2 ) ; $ spacing = str_repeat ( ' ' , max ( 0 , $ scenarioWidth - $ headerWidth ) ) ; $ printer -> writeln ( sprintf ( '%s {+comment}# %s{-comment}' , $ spacing , $ fileAndLine ) ) ; }
|
Prints scenario path comment .
|
8,935
|
public function printStepPath ( Formatter $ formatter , Scenario $ scenario , StepNode $ step , StepResult $ result , $ indentation ) { $ printer = $ formatter -> getOutputPrinter ( ) ; if ( ! $ result instanceof DefinedStepResult || ! $ result -> getStepDefinition ( ) || ! $ formatter -> getParameter ( 'paths' ) ) { $ printer -> writeln ( ) ; return ; } $ textWidth = $ this -> widthCalculator -> calculateStepWidth ( $ step , $ indentation ) ; $ scenarioWidth = $ this -> widthCalculator -> calculateScenarioWidth ( $ scenario , $ indentation - 2 , 2 ) ; $ this -> printDefinedStepPath ( $ printer , $ result , $ scenarioWidth , $ textWidth ) ; }
|
Prints step path comment .
|
8,936
|
private function printDefinedStepPath ( OutputPrinter $ printer , DefinedStepResult $ result , $ scenarioWidth , $ stepWidth ) { $ path = $ result -> getStepDefinition ( ) -> getPath ( ) ; $ spacing = str_repeat ( ' ' , max ( 0 , $ scenarioWidth - $ stepWidth ) ) ; $ printer -> writeln ( sprintf ( '%s {+comment}# %s{-comment}' , $ spacing , $ path ) ) ; }
|
Prints defined step path .
|
8,937
|
private function relativizePaths ( $ path ) { if ( ! $ this -> basePath ) { return $ path ; } return str_replace ( $ this -> basePath . DIRECTORY_SEPARATOR , '' , $ path ) ; }
|
Transforms path to relative .
|
8,938
|
static private function getReturnClass ( ReflectionFunctionAbstract $ reflection ) { $ type = $ reflection -> getReturnType ( ) ; if ( null === $ type || $ type -> isBuiltin ( ) ) { return null ; } return ( string ) $ type ; }
|
Extracts parameters from provided definition call .
|
8,939
|
private function hasIndex ( $ index ) { return is_string ( $ index ) ? $ this -> hasName ( $ index ) : $ this -> hasPosition ( $ index ) ; }
|
Returns appropriate closure for filtering parameter by index .
|
8,940
|
public function translateDefinition ( Suite $ suite , Definition $ definition , $ language = null ) { $ assetsId = $ suite -> getName ( ) ; $ pattern = $ definition -> getPattern ( ) ; $ translatedPattern = $ this -> translator -> trans ( $ pattern , array ( ) , $ assetsId , $ language ) ; if ( $ pattern != $ translatedPattern ) { return new TranslatedDefinition ( $ definition , $ translatedPattern , $ language ) ; } return $ definition ; }
|
Attempts to translate definition using translator and produce translated one on success .
|
8,941
|
private function getArgumentString ( ArgumentInterface $ argument , $ collapse = false ) { if ( $ collapse ) { return '...' ; } if ( $ argument instanceof PyStringNode ) { $ text = '"""' . "\n" . $ argument . "\n" . '"""' ; return $ text ; } return ( string ) $ argument ; }
|
Returns argument string for provided argument .
|
8,942
|
public function createContext ( $ class , array $ arguments = array ( ) , array $ singleUseResolvers = array ( ) ) { $ reflection = new ReflectionClass ( $ class ) ; $ resolvers = array_merge ( $ singleUseResolvers , $ this -> argumentResolvers ) ; $ resolvedArguments = $ this -> resolveArguments ( $ reflection , $ arguments , $ resolvers ) ; $ context = $ this -> createInstance ( $ reflection , $ resolvedArguments ) ; $ this -> initializeInstance ( $ context ) ; return $ context ; }
|
Creates and initializes context class .
|
8,943
|
private function resolveArguments ( ReflectionClass $ reflection , array $ arguments , array $ resolvers ) { $ newArguments = $ arguments ; foreach ( $ resolvers as $ resolver ) { $ newArguments = $ resolver -> resolveArguments ( $ reflection , $ newArguments ) ; } if ( ! $ reflection -> hasMethod ( '__construct' ) ) { return $ newArguments ; } $ constructor = $ reflection -> getConstructor ( ) ; $ newArguments = $ this -> argumentOrganiser -> organiseArguments ( $ constructor , $ newArguments ) ; $ this -> validator -> validateArguments ( $ constructor , $ newArguments ) ; return $ newArguments ; }
|
Resolves arguments for a specific class using registered argument resolvers .
|
8,944
|
private function createInstance ( ReflectionClass $ reflection , array $ arguments ) { if ( count ( $ arguments ) ) { return $ reflection -> newInstanceArgs ( $ arguments ) ; } return $ reflection -> newInstance ( ) ; }
|
Creates context instance .
|
8,945
|
private function initializeInstance ( Context $ context ) { foreach ( $ this -> contextInitializers as $ initializer ) { $ initializer -> initializeContext ( $ context ) ; } }
|
Initializes context class and returns new context instance .
|
8,946
|
private function replaceTokensWithRegexCaptureGroups ( $ regex ) { $ tokenRegex = self :: TOKEN_REGEX ; return preg_replace_callback ( self :: PLACEHOLDER_REGEXP , array ( $ this , 'replaceTokenWithRegexCaptureGroup' ) , $ regex ) ; }
|
Replaces turnip tokens with regex capture groups .
|
8,947
|
private function replaceTurnipAlternativeWordsWithRegex ( $ regex ) { $ regex = preg_replace ( self :: ALTERNATIVE_WORD_REGEXP , '(?:\1|\2)' , $ regex ) ; $ regex = $ this -> removeEscapingOfAlternationSyntax ( $ regex ) ; return $ regex ; }
|
Replaces turnip alternative words with regex non - capturing alternating group .
|
8,948
|
private function printTitle ( OutputPrinter $ printer , ExampleNode $ example ) { $ printer -> write ( sprintf ( '%s%s' , $ this -> indentText , $ example -> getTitle ( ) ) ) ; }
|
Prints example title .
|
8,949
|
public function printSuiteDefinitions ( DefinitionPrinter $ printer , $ suite ) { $ environment = $ this -> environmentManager -> buildEnvironment ( $ suite ) ; $ definitions = $ this -> repository -> getEnvironmentDefinitions ( $ environment ) ; $ printer -> printDefinitions ( $ suite , $ definitions ) ; }
|
Prints definitions for provided suite using printer .
|
8,950
|
private function flushStatesIfBeginningOfTheFeature ( $ eventName ) { if ( FeatureTested :: BEFORE !== $ eventName ) { return ; } $ this -> firstBackgroundEnded = false ; $ this -> inBackground = false ; }
|
Flushes state if the event is the BEFORE feature .
|
8,951
|
private function markBeginningOrEndOfTheBackground ( $ eventName ) { if ( BackgroundTested :: BEFORE === $ eventName ) { $ this -> inBackground = true ; } if ( BackgroundTested :: AFTER === $ eventName ) { $ this -> inBackground = false ; } }
|
Marks beginning or end of the background .
|
8,952
|
private function isSkippableEvent ( Event $ event ) { if ( ! $ this -> firstBackgroundEnded ) { return false ; } return $ event instanceof BackgroundTested || $ this -> isNonFailingConsequentBackgroundStep ( $ event ) ; }
|
Checks if provided event is skippable .
|
8,953
|
private function isBeforeStepEventWithOutput ( Event $ event ) { if ( $ event instanceof AfterStepSetup && $ event -> hasOutput ( ) ) { $ this -> stepSetupHadOutput = true ; return true ; } return false ; }
|
Checks if provided event is a BEFORE step with setup that produced output .
|
8,954
|
private function isAfterStepWithOutput ( Event $ event ) { if ( $ event instanceof AfterStepTested && ( $ this -> stepSetupHadOutput || $ event -> hasOutput ( ) ) ) { $ this -> stepSetupHadOutput = false ; return true ; } return false ; }
|
Checks if provided event is an AFTER step with teardown that produced output .
|
8,955
|
private function readMethodCallees ( $ class , ReflectionMethod $ method ) { $ callees = array ( ) ; try { $ prototype = $ method -> getPrototype ( ) ; if ( $ prototype -> getDeclaringClass ( ) -> getName ( ) !== $ method -> getDeclaringClass ( ) -> getName ( ) ) { $ callees = array_merge ( $ callees , $ this -> readMethodCallees ( $ class , $ prototype ) ) ; } } catch ( ReflectionException $ e ) { } if ( $ docBlock = $ method -> getDocComment ( ) ) { $ callees = array_merge ( $ callees , $ this -> readDocBlockCallees ( $ class , $ method , $ docBlock ) ) ; } return $ callees ; }
|
Loads callees associated with specific method .
|
8,956
|
private function readDocBlockCallees ( $ class , ReflectionMethod $ method , $ docBlock ) { $ callees = array ( ) ; $ description = $ this -> readDescription ( $ docBlock ) ; $ docBlock = $ this -> mergeMultilines ( $ docBlock ) ; foreach ( explode ( "\n" , $ docBlock ) as $ docLine ) { $ docLine = preg_replace ( self :: DOCLINE_TRIMMER_REGEX , '' , $ docLine ) ; if ( $ this -> isEmpty ( $ docLine ) ) { continue ; } if ( $ this -> isNotAnnotation ( $ docLine ) ) { continue ; } if ( $ callee = $ this -> readDocLineCallee ( $ class , $ method , $ docLine , $ description ) ) { $ callees [ ] = $ callee ; } } return $ callees ; }
|
Reads callees from the method doc block .
|
8,957
|
private function readDescription ( $ docBlock ) { $ description = preg_replace ( '/^[\s\t]*/m' , '' , $ docBlock ) ; $ description = preg_replace ( '/^\/\*\*\s*|^\s*\*\s|^\s*\*\/$/m' , '' , $ description ) ; $ description = preg_replace ( '/^@.*$/m' , '' , $ description ) ; if ( preg_match ( '/^--.*$/m' , $ description ) ) { $ descriptionParts = preg_split ( '/^--.*$/m' , $ description ) ; $ description = array_shift ( $ descriptionParts ) ; } $ description = trim ( $ description , "\r\n" ) ; return $ description ; }
|
Extracts a description from the provided docblock with support for multiline descriptions .
|
8,958
|
private function readDocLineCallee ( $ class , ReflectionMethod $ method , $ docLine , $ description = null ) { if ( $ this -> isIgnoredAnnotation ( $ docLine ) ) { return null ; } foreach ( $ this -> readers as $ reader ) { if ( $ callee = $ reader -> readCallee ( $ class , $ method , $ docLine , $ description ) ) { return $ callee ; } } return null ; }
|
Reads callee from provided doc line using registered annotation readers .
|
8,959
|
private function isIgnoredAnnotation ( $ docLine ) { $ lowDocLine = strtolower ( $ docLine ) ; foreach ( self :: $ ignoreAnnotations as $ ignoredAnnotation ) { if ( $ ignoredAnnotation == substr ( $ lowDocLine , 0 , strlen ( $ ignoredAnnotation ) ) ) { return true ; } } return false ; }
|
Checks if provided doc line is one of the ignored annotations .
|
8,960
|
private function loadFactory ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\ContextFactory' , array ( new Reference ( ArgumentExtension :: CONSTRUCTOR_ARGUMENT_ORGANISER_ID ) ) ) ; $ container -> setDefinition ( self :: FACTORY_ID , $ definition ) ; }
|
Loads context factory .
|
8,961
|
private function loadArgumentResolverFactory ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Argument\CompositeArgumentResolverFactory' ) ; $ container -> setDefinition ( self :: AGGREGATE_RESOLVER_FACTORY_ID , $ definition ) ; }
|
Loads argument resolver factory used in the environment handler .
|
8,962
|
private function loadEnvironmentHandler ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Environment\Handler\ContextEnvironmentHandler' , array ( new Reference ( self :: FACTORY_ID ) , new Reference ( self :: AGGREGATE_RESOLVER_FACTORY_ID ) ) ) ; $ definition -> addTag ( EnvironmentExtension :: HANDLER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: getEnvironmentHandlerId ( ) , $ definition ) ; }
|
Loads context environment handlers .
|
8,963
|
private function loadEnvironmentReader ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Environment\Reader\ContextEnvironmentReader' ) ; $ definition -> addTag ( EnvironmentExtension :: READER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: getEnvironmentReaderId ( ) , $ definition ) ; }
|
Loads context environment readers .
|
8,964
|
private function loadSuiteSetup ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Suite\Setup\SuiteWithContextsSetup' , array ( new Reference ( AutoloaderExtension :: CLASS_LOADER_ID ) , new Reference ( FilesystemExtension :: LOGGER_ID ) ) ) ; $ definition -> addTag ( SuiteExtension :: SETUP_TAG , array ( 'priority' => 20 ) ) ; $ container -> setDefinition ( self :: getSuiteSetupId ( ) , $ definition ) ; }
|
Loads context environment setup .
|
8,965
|
private function loadSnippetAppender ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Snippet\Appender\ContextSnippetAppender' , array ( new Reference ( FilesystemExtension :: LOGGER_ID ) ) ) ; $ definition -> addTag ( SnippetExtension :: APPENDER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( SnippetExtension :: APPENDER_TAG . '.context' , $ definition ) ; }
|
Loads context snippet appender .
|
8,966
|
private function loadSnippetGenerators ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Snippet\Generator\ContextSnippetGenerator' , array ( new Reference ( DefinitionExtension :: PATTERN_TRANSFORMER_ID ) ) ) ; $ definition -> addTag ( SnippetExtension :: GENERATOR_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: CONTEXT_SNIPPET_GENERATOR_ID , $ definition ) ; }
|
Loads context snippet generators .
|
8,967
|
private function loadDefaultClassGenerators ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\ContextClass\SimpleClassGenerator' ) ; $ definition -> addTag ( self :: CLASS_GENERATOR_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: CLASS_GENERATOR_TAG . '.simple' , $ definition ) ; }
|
Loads default context class generators .
|
8,968
|
private function loadDefaultContextReaders ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Context\Reader\AnnotatedContextReader' ) ; $ container -> setDefinition ( self :: getAnnotatedContextReaderId ( ) , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Context\Reader\ContextReaderCachedPerContext' , array ( new Reference ( self :: getAnnotatedContextReaderId ( ) ) ) ) ; $ definition -> addTag ( self :: READER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: getAnnotatedContextReaderId ( ) . '.cached' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Context\Reader\TranslatableContextReader' , array ( new Reference ( TranslatorExtension :: TRANSLATOR_ID ) ) ) ; $ container -> setDefinition ( self :: READER_TAG . '.translatable' , $ definition ) ; $ definition = new Definition ( 'Behat\Behat\Context\Reader\ContextReaderCachedPerSuite' , array ( new Reference ( self :: READER_TAG . '.translatable' ) ) ) ; $ definition -> addTag ( self :: READER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( self :: READER_TAG . '.translatable.cached' , $ definition ) ; }
|
Loads default context readers .
|
8,969
|
private function processClassResolvers ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: CLASS_RESOLVER_TAG ) ; $ definition = $ container -> getDefinition ( self :: getEnvironmentHandlerId ( ) ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerClassResolver' , array ( $ reference ) ) ; } }
|
Processes all class resolvers .
|
8,970
|
private function processArgumentResolverFactories ( $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: SUITE_SCOPED_RESOLVER_FACTORY_TAG ) ; $ definition = $ container -> getDefinition ( self :: AGGREGATE_RESOLVER_FACTORY_ID ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerFactory' , array ( $ reference ) ) ; } }
|
Processes all argument resolver factories .
|
8,971
|
private function processArgumentResolvers ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: ARGUMENT_RESOLVER_TAG ) ; $ definition = $ container -> getDefinition ( self :: FACTORY_ID ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerArgumentResolver' , array ( $ reference ) ) ; } }
|
Processes all argument resolvers .
|
8,972
|
private function processContextInitializers ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: INITIALIZER_TAG ) ; $ definition = $ container -> getDefinition ( self :: FACTORY_ID ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerContextInitializer' , array ( $ reference ) ) ; } }
|
Processes all context initializers .
|
8,973
|
private function processContextReaders ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: READER_TAG ) ; $ definition = $ container -> getDefinition ( self :: getEnvironmentReaderId ( ) ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerContextReader' , array ( $ reference ) ) ; } }
|
Processes all context readers .
|
8,974
|
private function processClassGenerators ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: CLASS_GENERATOR_TAG ) ; $ definition = $ container -> getDefinition ( self :: getSuiteSetupId ( ) ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerClassGenerator' , array ( $ reference ) ) ; } }
|
Processes all class generators .
|
8,975
|
private function processAnnotationReaders ( ContainerBuilder $ container ) { $ references = $ this -> processor -> findAndSortTaggedServices ( $ container , self :: ANNOTATION_READER_TAG ) ; $ definition = $ container -> getDefinition ( self :: getAnnotatedContextReaderId ( ) ) ; foreach ( $ references as $ reference ) { $ definition -> addMethodCall ( 'registerAnnotationReader' , array ( $ reference ) ) ; } }
|
Processes all annotation readers .
|
8,976
|
public function generatePattern ( $ type , $ stepText ) { foreach ( $ this -> policies as $ policy ) { if ( $ policy -> supportsPatternType ( $ type ) ) { return $ policy -> generatePattern ( $ stepText ) ; } } throw new UnsupportedPatternTypeException ( sprintf ( 'Can not find policy for a pattern type `%s`.' , $ type ) , $ type ) ; }
|
Generates pattern .
|
8,977
|
public function transformPatternToRegex ( $ pattern ) { if ( ! isset ( $ this -> patternToRegexpCache [ $ pattern ] ) ) { $ this -> patternToRegexpCache [ $ pattern ] = $ this -> transformPatternToRegexWithSupportedPolicy ( $ pattern ) ; } return $ this -> patternToRegexpCache [ $ pattern ] ; }
|
Transforms pattern string to regex .
|
8,978
|
private function createFeatureDirectory ( $ path ) { mkdir ( $ path , 0777 , true ) ; if ( $ this -> logger ) { $ this -> logger -> directoryCreated ( $ path , 'place your *.feature files here' ) ; } }
|
Creates feature directory .
|
8,979
|
private function locatePath ( $ path ) { if ( $ this -> isAbsolutePath ( $ path ) ) { return $ path ; } return $ this -> basePath . DIRECTORY_SEPARATOR . $ path ; }
|
Locates path from a relative one .
|
8,980
|
public function filterCall ( Call $ call ) { if ( $ container = $ this -> getContainer ( $ call ) ) { $ autowirer = new ArgumentAutowirer ( $ container ) ; $ newArguments = $ autowirer -> autowireArguments ( $ call -> getCallee ( ) -> getReflection ( ) , $ call -> getArguments ( ) ) ; return $ this -> repackageCallIfNewArguments ( $ call , $ newArguments ) ; } return $ call ; }
|
Filters a call and returns a new one .
|
8,981
|
private function getContainer ( Call $ call ) { if ( ! $ call instanceof EnvironmentCall ) { throw new UnsupportedCallException ( sprintf ( 'ServicesResolver can not filter `%s` call.' , get_class ( $ call ) ) , $ call ) ; } $ environment = $ call -> getEnvironment ( ) ; if ( ! $ environment instanceof ServiceContainerEnvironment ) { throw new UnsupportedCallException ( sprintf ( 'ServicesResolver can not filter `%s` call.' , get_class ( $ call ) ) , $ call ) ; } return $ environment -> getServiceContainer ( ) ; }
|
Gets container from the call .
|
8,982
|
private function repackageCallIfNewArguments ( Call $ call , array $ arguments ) { if ( $ arguments === $ call -> getArguments ( ) ) { return $ call ; } return $ this -> repackageCallWithNewArguments ( $ call , $ arguments ) ; }
|
Repackages old calls with new arguments but only if two differ .
|
8,983
|
private function repackageCallWithNewArguments ( Call $ call , array $ newArguments ) { if ( $ call instanceof DefinitionCall ) { return $ this -> repackageDefinitionCall ( $ call , $ newArguments ) ; } if ( $ call instanceof TransformationCall ) { return $ this -> repackageTransformationCall ( $ call , $ newArguments ) ; } throw new UnsupportedCallException ( sprintf ( 'ServicesResolver can not filter `%s` call.' , get_class ( $ call ) ) , $ call ) ; }
|
Repackages old calls with new arguments .
|
8,984
|
private function repackageDefinitionCall ( DefinitionCall $ call , array $ newArguments ) { $ definition = $ call -> getCallee ( ) ; if ( ! $ definition instanceof Definition ) { throw new UnsupportedCallException ( sprintf ( 'Something is wrong in callee associated with `%s` call.' , get_class ( $ call ) ) , $ call ) ; } return new DefinitionCall ( $ call -> getEnvironment ( ) , $ call -> getFeature ( ) , $ call -> getStep ( ) , $ definition , $ newArguments , $ call -> getErrorReportingLevel ( ) ) ; }
|
Repackages definition call with new arguments .
|
8,985
|
private function repackageTransformationCall ( TransformationCall $ call , array $ newArguments ) { $ transformation = $ call -> getCallee ( ) ; if ( ! $ transformation instanceof Transformation ) { throw new UnsupportedCallException ( sprintf ( 'Something is wrong in callee associated with `%s` call.' , get_class ( $ call ) ) , $ call ) ; } return new TransformationCall ( $ call -> getEnvironment ( ) , $ call -> getDefinition ( ) , $ transformation , $ newArguments ) ; }
|
Repackages transformation call with new arguments .
|
8,986
|
private function getSuiteFilters ( Suite $ suite ) { if ( ! $ suite -> hasSetting ( 'filters' ) || ! is_array ( $ suite -> getSetting ( 'filters' ) ) ) { return array ( ) ; } $ filters = array ( ) ; foreach ( $ suite -> getSetting ( 'filters' ) as $ type => $ filterString ) { $ filters [ ] = $ this -> createFilter ( $ type , $ filterString , $ suite ) ; } return $ filters ; }
|
Returns list of filters from suite settings .
|
8,987
|
private function createFilter ( $ type , $ filterString , Suite $ suite ) { if ( 'role' === $ type ) { return new RoleFilter ( $ filterString ) ; } if ( 'name' === $ type ) { return new NameFilter ( $ filterString ) ; } if ( 'tags' === $ type ) { return new TagFilter ( $ filterString ) ; } if ( 'narrative' === $ type ) { return new NarrativeFilter ( $ filterString ) ; } throw new SuiteConfigurationException ( sprintf ( '`%s` filter is not supported by the `%s` suite. Supported types are `%s`.' , $ type , $ suite -> getName ( ) , implode ( '`, `' , array ( 'role' , 'name' , 'tags' ) ) ) , $ suite -> getName ( ) ) ; }
|
Creates filter of provided type .
|
8,988
|
private function moveToNextAvailableFeature ( ) { while ( ! count ( $ this -> features ) && $ this -> position < count ( $ this -> paths ) ) { $ this -> features = $ this -> parseFeature ( $ this -> paths [ $ this -> position ] ) ; $ this -> position ++ ; } $ this -> currentFeature = array_shift ( $ this -> features ) ; }
|
Parses paths consequently .
|
8,989
|
private function loadParameters ( ContainerBuilder $ container ) { $ container -> setParameter ( 'gherkin.paths.lib' , $ this -> getLibPath ( ) ) ; $ container -> setParameter ( 'gherkin.paths.i18n' , '%gherkin.paths.lib%/i18n.php' ) ; $ container -> setParameter ( 'suite.generic.default_settings' , array ( 'paths' => array ( '%paths.base%/features' ) , 'contexts' => array ( 'FeatureContext' ) ) ) ; }
|
Loads default container parameters .
|
8,990
|
private function getLibPath ( ) { $ reflection = new ReflectionClass ( 'Behat\Gherkin\Gherkin' ) ; $ libPath = rtrim ( dirname ( $ reflection -> getFilename ( ) ) . '/../../../' , DIRECTORY_SEPARATOR ) ; return $ libPath ; }
|
Returns gherkin library path .
|
8,991
|
private function loadGherkin ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Gherkin\Gherkin' ) ; $ container -> setDefinition ( self :: MANAGER_ID , $ definition ) ; }
|
Loads gherkin service .
|
8,992
|
private function loadKeywords ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Gherkin\Keywords\CachedArrayKeywords' , array ( '%gherkin.paths.i18n%' ) ) ; $ container -> setDefinition ( self :: KEYWORDS_ID , $ definition ) ; $ definition = new Definition ( 'Behat\Gherkin\Keywords\KeywordsDumper' , array ( new Reference ( self :: KEYWORDS_ID ) ) ) ; $ container -> setDefinition ( self :: KEYWORDS_DUMPER_ID , $ definition ) ; }
|
Loads keyword services .
|
8,993
|
private function loadParser ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Gherkin\Parser' , array ( new Reference ( 'gherkin.lexer' ) ) ) ; $ container -> setDefinition ( 'gherkin.parser' , $ definition ) ; $ definition = new Definition ( 'Behat\Gherkin\Lexer' , array ( new Reference ( 'gherkin.keywords' ) ) ) ; $ container -> setDefinition ( 'gherkin.lexer' , $ definition ) ; }
|
Loads gherkin parser .
|
8,994
|
private function loadDefaultLoaders ( ContainerBuilder $ container , $ cachePath ) { $ definition = new Definition ( 'Behat\Gherkin\Loader\GherkinFileLoader' , array ( new Reference ( 'gherkin.parser' ) ) ) ; if ( $ cachePath ) { $ cacheDefinition = new Definition ( 'Behat\Gherkin\Cache\FileCache' , array ( $ cachePath ) ) ; } else { $ cacheDefinition = new Definition ( 'Behat\Gherkin\Cache\MemoryCache' ) ; } $ definition -> addMethodCall ( 'setCache' , array ( $ cacheDefinition ) ) ; $ definition -> addMethodCall ( 'setBasePath' , array ( '%paths.base%' ) ) ; $ definition -> addTag ( self :: LOADER_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( 'gherkin.loader.gherkin_file' , $ definition ) ; }
|
Loads gherkin loaders .
|
8,995
|
private function loadProfileFilters ( ContainerBuilder $ container , array $ filters ) { $ gherkin = $ container -> getDefinition ( self :: MANAGER_ID ) ; foreach ( $ filters as $ type => $ filterString ) { $ filter = $ this -> createFilterDefinition ( $ type , $ filterString ) ; $ gherkin -> addMethodCall ( 'addFilter' , array ( $ filter ) ) ; } }
|
Loads profile - level gherkin filters .
|
8,996
|
private function loadSyntaxController ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Gherkin\Cli\SyntaxController' , array ( new Reference ( self :: KEYWORDS_DUMPER_ID ) , new Reference ( TranslatorExtension :: TRANSLATOR_ID ) ) ) ; $ definition -> addTag ( CliExtension :: CONTROLLER_TAG , array ( 'priority' => 600 ) ) ; $ container -> setDefinition ( CliExtension :: CONTROLLER_TAG . '.gherkin_syntax' , $ definition ) ; }
|
Loads syntax controller .
|
8,997
|
private function loadFilterController ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Gherkin\Cli\FilterController' , array ( new Reference ( self :: MANAGER_ID ) ) ) ; $ definition -> addTag ( CliExtension :: CONTROLLER_TAG , array ( 'priority' => 700 ) ) ; $ container -> setDefinition ( CliExtension :: CONTROLLER_TAG . '.gherkin_filters' , $ definition ) ; }
|
Loads filter controller .
|
8,998
|
private function loadSuiteWithPathsSetup ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Gherkin\Suite\Setup\SuiteWithPathsSetup' , array ( '%paths.base%' , new Reference ( FilesystemExtension :: LOGGER_ID ) ) ) ; $ definition -> addTag ( SuiteExtension :: SETUP_TAG , array ( 'priority' => 50 ) ) ; $ container -> setDefinition ( SuiteExtension :: SETUP_TAG . '.suite_with_paths' , $ definition ) ; }
|
Loads suite with paths setup .
|
8,999
|
private function loadFilesystemFeatureLocator ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Gherkin\Specification\Locator\FilesystemFeatureLocator' , array ( new Reference ( self :: MANAGER_ID ) , '%paths.base%' ) ) ; $ definition -> addTag ( SpecificationExtension :: LOCATOR_TAG , array ( 'priority' => 60 ) ) ; $ container -> setDefinition ( SpecificationExtension :: LOCATOR_TAG . '.filesystem_feature' , $ definition ) ; }
|
Loads filesystem feature locator .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.