diff --git a/src/Behaviors/ActiveRecordDeferredEventRoutingBehavior.php b/src/Behaviors/ActiveRecordDeferredEventRoutingBehavior.php index 359ae7c..a587d73 100644 --- a/src/Behaviors/ActiveRecordDeferredEventRoutingBehavior.php +++ b/src/Behaviors/ActiveRecordDeferredEventRoutingBehavior.php @@ -50,6 +50,7 @@ public function routeEvent($event) { } $route = $handler[0]; unset($handler[0]); + $handler['scenario'] = $this->owner->getScenario(); $data = $handler; $this->queue->post(new \UrbanIndo\Yii2\Queue\Job([ 'route' => $route, diff --git a/tests/Behaviors/ActiveRecordDeferredEventRoutingBehaviorTest.php b/tests/Behaviors/ActiveRecordDeferredEventRoutingBehaviorTest.php index 031b930..1ca2d8e 100644 --- a/tests/Behaviors/ActiveRecordDeferredEventRoutingBehaviorTest.php +++ b/tests/Behaviors/ActiveRecordDeferredEventRoutingBehaviorTest.php @@ -27,6 +27,7 @@ public function testEventRouting() { $this->assertEquals(0, $queue->getQueueLength()); $this->assertEquals([ 'id' => 5, + 'scenario' => 'default', ], $job->data); $model->trigger('eventTest2'); $this->assertEquals(1, $queue->getQueueLength()); @@ -35,7 +36,8 @@ public function testEventRouting() { $this->assertFalse($job->isCallable()); $this->assertEquals(0, $queue->getQueueLength()); $this->assertEquals([ - 'halo' => 5 + 'halo' => 5, + 'scenario' => 'default', ], $job->data); }