Skip to content

Commit

Permalink
Merge pull request neos#5362 from neos/bugfix/reset-lastCommandExcept…
Browse files Browse the repository at this point in the history
…ion-once-asserted-in-behat-tests

BUGFIX: Behat: Reset `lastCommandException` once asserted
  • Loading branch information
kitsunet authored Nov 13, 2024
2 parents 80d8750 + 7b73bf7 commit b1fc4e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Feature: Constraint checks on node aggregate disabling
| nodeAggregateId | "i-do-not-exist" |
| nodeVariantSelectionStrategy | "allVariants" |
| tag | "disabled" |
Then the last command should have thrown an exception of type "NodeAggregateCurrentlyDoesNotExist"

Scenario: Try to disable an already disabled node aggregate
Given the command DisableNodeAggregate is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public function theLastCommandShouldHaveThrown(string $shortExceptionName, ?int
$this->lastCommandException->getMessage()
));
}
$this->lastCommandException = null;
}

/**
Expand All @@ -343,6 +344,23 @@ public function theLastCommandShouldHaveThrownTheWorkspaceRebaseFailedWith(Table
}

Assert::assertSame($payloadTable->getHash(), $actualComparableHash);
$this->lastCommandException = null;
}

/**
* @AfterScenario
*/
public function ensureNoUnhandledCommandExceptions(\Behat\Behat\Hook\Scope\AfterScenarioScope $event): void
{
if ($this->lastCommandException !== null) {
Assert::fail(sprintf(
'Last command did throw with exception which was not asserted: %s: "%s" in %s:%s',
$this->lastCommandException::class,
$this->lastCommandException->getMessage(),
$event->getFeature()->getFile(),
$event->getScenario()->getLine(),
));
}
}

/**
Expand Down

0 comments on commit b1fc4e6

Please sign in to comment.