Skip to content
This repository was archived by the owner on May 25, 2020. It is now read-only.

Commit c15b505

Browse files
committed
Fix lowest tests
1 parent c5fbfa9 commit c15b505

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tests/WorkerTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function testWorkersEventFiring(): void
180180
$worker->start();
181181

182182
foreach ($expected_events as $expected_event) {
183-
$fake_events->assertDispatchedTimes($expected_event, 1);
183+
$this->assertDispatchedTimes($fake_events, $expected_event, 1);
184184
}
185185
}
186186

@@ -238,7 +238,7 @@ public function testWorkerErrorHandling(): void
238238

239239
$worker->start();
240240

241-
$fake_events->assertDispatchedTimes(Events\LoopErrorOccurredEvent::class, 1);
241+
$this->assertDispatchedTimes($fake_events, Events\LoopErrorOccurredEvent::class, 1);
242242

243243
$this->assertSame(
244244
$exception,
@@ -296,7 +296,7 @@ public function testWorkerErrorHandlingWithMaskedException(): void
296296

297297
$worker->start();
298298

299-
$fake_events->assertDispatchedTimes(Events\LoopErrorOccurredEvent::class, 1);
299+
$this->assertDispatchedTimes($fake_events, Events\LoopErrorOccurredEvent::class, 1);
300300

301301
$this->assertSame(
302302
$exception,
@@ -339,7 +339,7 @@ public function testWorkerErrorHandlingAfterRespond(): void
339339

340340
$worker->start();
341341

342-
$fake_events->assertDispatchedTimes(Events\LoopErrorOccurredEvent::class, 1);
342+
$this->assertDispatchedTimes($fake_events, Events\LoopErrorOccurredEvent::class, 1);
343343

344344
$this->assertSame(
345345
$exception,
@@ -440,4 +440,19 @@ private function getPSR7ClientSuccessfulMock()
440440
->withArgs($this->getHtmlResponseValidationClosure())
441441
->getMock();
442442
}
443+
444+
/**
445+
* @param EventFake $dispatcher
446+
* @param $event
447+
* @param int $times
448+
*/
449+
private function assertDispatchedTimes(EventFake $dispatcher, $event, int $times)
450+
{
451+
$count = $dispatcher->dispatched($event)->count();
452+
453+
$this->assertSame(
454+
$times, $count,
455+
"The expected [{$event}] event was dispatched {$count} times instead of {$times} times."
456+
);
457+
}
443458
}

0 commit comments

Comments
 (0)