1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-12 21:54:04 +00:00

Add the ability to use closures inside pipelines

This commit is contained in:
Samuel Štancl 2020-11-15 16:11:02 +01:00
parent 86873515ae
commit f86e55ace7
3 changed files with 23 additions and 2 deletions

View file

@ -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