mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-12 08:04:04 +00:00
Add the ability to use closures inside pipelines
This commit is contained in:
parent
86873515ae
commit
f86e55ace7
3 changed files with 23 additions and 2 deletions
|
|
@ -133,6 +133,24 @@ class JobPipelineTest extends TestCase
|
|||
// Foo job is not excuted
|
||||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function closures_can_be_used_as_jobs()
|
||||
{
|
||||
$passes = false;
|
||||
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
function (TestModel $model) use (&$passes) {
|
||||
$passes = $model instanceof TestModel;
|
||||
}
|
||||
])->send(function (TestEvent $event) {
|
||||
return $event->testModel;
|
||||
})->toListener());
|
||||
|
||||
event(new TestEvent(new TestModel()));
|
||||
|
||||
$this->assertTrue($passes);
|
||||
}
|
||||
}
|
||||
|
||||
class FooJob
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
{"false_job_executed":true}
|
||||
Loading…
Add table
Add a link
Reference in a new issue