PHP Class Behat\Behat\Context\Snippet\Generator\ContextSnippetGenerator

Author: Konstantin Kudryashov ([email protected])
Inheritance: implements Behat\Behat\Snippet\Generator\SnippetGenerator
Datei anzeigen Open project: behat/behat Class Usage Examples

Public Methods

Method Description
__construct ( Behat\Behat\Definition\Pattern\PatternTransformer $patternTransformer ) Initializes snippet generator.
generateSnippet ( Behat\Testwork\Environment\Environment $environment, Behat\Gherkin\Node\StepNode $step )
setContextIdentifier ( Behat\Behat\Context\Snippet\Generator\TargetContextIdentifier $identifier ) Sets target context identifier.
setPatternIdentifier ( Behat\Behat\Context\Snippet\Generator\PatternIdentifier $identifier ) Sets target pattern type identifier.
supportsEnvironmentAndStep ( Behat\Testwork\Environment\Environment $environment, Behat\Gherkin\Node\StepNode $step )

Private Methods

Method Description
deduceMethodName ( string $canonicalText ) : string Generates definition method name based on the step text.
getAlreadyProposedMethods ( string $contextClass ) : string[] Returns already proposed method names.
getMethodArgument ( string $argument ) : string Returns method argument.
getMethodArguments ( Behat\Gherkin\Node\StepNode $step, integer $tokenCount ) : string[] Returns an array of method argument names from step and token count.
getMethodName ( string $contextClass, string $canonicalText, string $pattern ) : string Generates method name using step text and regex.
getMethodNameNotExistentInContext ( ReflectionClass $reflection, string $methodName, integer $methodNumber ) : array Tries to guess method name that is not yet defined in the context class.
getMethodNameNotProposedEarlier ( string $contextClass, string $stepPattern, string $name, integer $number ) : string Tries to guess method name that is not yet proposed to the context class.
getMethodNumberFromTheMethodName ( string $methodName ) : integer Tries to deduct method number from the provided method name.
getSnippetTemplate ( string $pattern, string $methodName, array $methodArguments ) : string Generates snippet template using regex, method name and arguments.
getUniqueMethodName ( string $contextClass, string $stepPattern, string $name ) : string Ensures uniqueness of the method name in the context.
getUsedClasses ( Behat\Gherkin\Node\StepNode $step ) : string[] Returns an array of classes used by the snippet template
markMethodAsAlreadyProposed ( string $contextClass, string $stepPattern, string $methodName ) Marks method as proposed one.

Method Details

__construct() public method

Initializes snippet generator.
public __construct ( Behat\Behat\Definition\Pattern\PatternTransformer $patternTransformer )
$patternTransformer Behat\Behat\Definition\Pattern\PatternTransformer

generateSnippet() public method

public generateSnippet ( Behat\Testwork\Environment\Environment $environment, Behat\Gherkin\Node\StepNode $step )
$environment Behat\Testwork\Environment\Environment
$step Behat\Gherkin\Node\StepNode

setContextIdentifier() public method

Sets target context identifier.
public setContextIdentifier ( Behat\Behat\Context\Snippet\Generator\TargetContextIdentifier $identifier )
$identifier Behat\Behat\Context\Snippet\Generator\TargetContextIdentifier

setPatternIdentifier() public method

Sets target pattern type identifier.
public setPatternIdentifier ( Behat\Behat\Context\Snippet\Generator\PatternIdentifier $identifier )
$identifier Behat\Behat\Context\Snippet\Generator\PatternIdentifier

supportsEnvironmentAndStep() public method

public supportsEnvironmentAndStep ( Behat\Testwork\Environment\Environment $environment, Behat\Gherkin\Node\StepNode $step )
$environment Behat\Testwork\Environment\Environment
$step Behat\Gherkin\Node\StepNode