Don't collect unexpected extra commands in spec tests

parent ebc4a992
...@@ -91,7 +91,7 @@ class CommandExpectations implements CommandSubscriber ...@@ -91,7 +91,7 @@ class CommandExpectations implements CommandSubscriber
*/ */
public function commandFailed(CommandFailedEvent $event) public function commandFailed(CommandFailedEvent $event)
{ {
if ($this->ignoreCommandFailed) { if ($this->ignoreCommandFailed || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
return; return;
} }
...@@ -105,7 +105,7 @@ class CommandExpectations implements CommandSubscriber ...@@ -105,7 +105,7 @@ class CommandExpectations implements CommandSubscriber
*/ */
public function commandStarted(CommandStartedEvent $event) public function commandStarted(CommandStartedEvent $event)
{ {
if ($this->ignoreCommandStarted) { if ($this->ignoreCommandStarted || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
return; return;
} }
...@@ -119,7 +119,7 @@ class CommandExpectations implements CommandSubscriber ...@@ -119,7 +119,7 @@ class CommandExpectations implements CommandSubscriber
*/ */
public function commandSucceeded(CommandSucceededEvent $event) public function commandSucceeded(CommandSucceededEvent $event)
{ {
if ($this->ignoreCommandSucceeded) { if ($this->ignoreCommandSucceeded || ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))) {
return; return;
} }
...@@ -150,15 +150,11 @@ class CommandExpectations implements CommandSubscriber ...@@ -150,15 +150,11 @@ class CommandExpectations implements CommandSubscriber
*/ */
public function assert(FunctionalTestCase $test, Context $context) public function assert(FunctionalTestCase $test, Context $context)
{ {
$actualEvents = $this->ignoreExtraEvents $test->assertCount(count($this->expectedEvents), $this->actualEvents);
? array_slice($this->actualEvents, 0, count($this->expectedEvents))
: $this->actualEvents;
$test->assertCount(count($this->expectedEvents), $actualEvents);
$mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY); $mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY);
$mi->attachIterator(new ArrayIterator($this->expectedEvents)); $mi->attachIterator(new ArrayIterator($this->expectedEvents));
$mi->attachIterator(new ArrayIterator($actualEvents)); $mi->attachIterator(new ArrayIterator($this->actualEvents));
foreach ($mi as $events) { foreach ($mi as $events) {
list($expectedEventAndClass, $actualEvent) = $events; list($expectedEventAndClass, $actualEvent) = $events;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment