Skip to content

Commit b5ef49d

Browse files
committed
fix test
1 parent 7c99096 commit b5ef49d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/unit/BaseTestClass.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ protected function tearDown()
6262
{
6363
parent::tearDown();
6464

65-
// cleanup
66-
$this->async->purge(TestTask::$queueName);
67-
if ($this->async->receiveTask('wrong')) {
68-
$this->async->purge('wrong');
65+
if (\Yii::$app) {
66+
$this->async = \Yii::$app->async;
67+
68+
// cleanup
69+
$this->async->purge(TestTask::$queueName);
70+
if ($this->async->receiveTask('wrong')) {
71+
$this->async->purge('wrong');
72+
}
6973
}
7074
}
7175

@@ -215,7 +219,7 @@ public function testSubscribe()
215219

216220
$fork = $manager->fork(
217221
function () use ($task) {
218-
return \Yii::$app->asyncFork->receiveTask($task::$queueName, true);
222+
return \Yii::$app->asyncFork->waitAndReceive($task::$queueName);
219223
}
220224
);
221225

@@ -224,6 +228,7 @@ function () use ($task) {
224228
$fork->then(
225229
function (\Spork\Fork $fork) {
226230
$task = $fork->getResult();
231+
$this->assertNotEmpty($task);
227232
$this->assertEquals(1, $task->execute());
228233
}
229234
);

0 commit comments

Comments
 (0)