Skip to content

Commit

Permalink
snippetGenerator property change
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanjfshaw authored Jan 21, 2025
1 parent b2f926a commit fdcca6f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/PHPUnit/Framework/Constraint/HasScenarioPassedConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,22 @@ protected function setupSnippetGenerator() {
$identifier = new \Behat\Behat\Context\Snippet\Generator\FixedContextIdentifier($context);
$this->snippetGenerator->setContextIdentifier($identifier);

// Modify the snippet generator's template so that it no longer
// refers to PendingException().
$templateReflector = new \ReflectionProperty(get_class($this->snippetGenerator), 'templateTemplate');
$templateReflector->setAccessible(true);
$templateReflector->setValue($this->snippetGenerator, $this->snippetTemplate);
}
// Determine the correct property name.
$reflector = new \ReflectionClass(get_class($this->snippetGenerator));
$templateProperty = null;
if ($reflector->hasProperty('snippetTemplate')) {
$templateProperty = 'snippetTemplate';
} elseif ($reflector->hasProperty('templateTemplate')) {
$templateProperty = 'templateTemplate';
}

if ($templateProperty !== null) {
// Modify the snippet generator's template to remove reference to pending exception.
$templateReflector = new \ReflectionProperty(get_class($this->snippetGenerator), $templateProperty);
$templateReflector->setAccessible(true);
$templateReflector->setValue($this->snippetGenerator, $this->snippetTemplate);
}
}

protected function generateSnippet($step) {
if (!is_null($this->snippetGenerator) && !is_null($this->environment)) {
Expand Down

0 comments on commit fdcca6f

Please sign in to comment.