Skip to content

Commit 31fba08

Browse files
committed
Don't collect unexpected extra commands in spec tests
1 parent ebc4a99 commit 31fba08

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/SpecTests/CommandExpectations.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function fromTransactions(array $expectedEvents)
9191
*/
9292
public function commandFailed(CommandFailedEvent $event)
9393
{
94-
if ($this->ignoreCommandFailed) {
94+
if ($this->ignoreCommandFailed || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
9595
return;
9696
}
9797

@@ -105,7 +105,7 @@ public function commandFailed(CommandFailedEvent $event)
105105
*/
106106
public function commandStarted(CommandStartedEvent $event)
107107
{
108-
if ($this->ignoreCommandStarted) {
108+
if ($this->ignoreCommandStarted || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
109109
return;
110110
}
111111

@@ -119,7 +119,7 @@ public function commandStarted(CommandStartedEvent $event)
119119
*/
120120
public function commandSucceeded(CommandSucceededEvent $event)
121121
{
122-
if ($this->ignoreCommandSucceeded) {
122+
if ($this->ignoreCommandSucceeded || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
123123
return;
124124
}
125125

@@ -150,15 +150,11 @@ public function stopMonitoring()
150150
*/
151151
public function assert(FunctionalTestCase $test, Context $context)
152152
{
153-
$actualEvents = $this->ignoreExtraEvents
154-
? array_slice($this->actualEvents, 0, count($this->expectedEvents))
155-
: $this->actualEvents;
156-
157-
$test->assertCount(count($this->expectedEvents), $actualEvents);
153+
$test->assertCount(count($this->expectedEvents), $this->actualEvents);
158154

159155
$mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY);
160156
$mi->attachIterator(new ArrayIterator($this->expectedEvents));
161-
$mi->attachIterator(new ArrayIterator($actualEvents));
157+
$mi->attachIterator(new ArrayIterator($this->actualEvents));
162158

163159
foreach ($mi as $events) {
164160
list($expectedEventAndClass, $actualEvent) = $events;

0 commit comments

Comments
 (0)