mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-12 10:54:05 +00:00
adds tests
This commit is contained in:
parent
d636ab5fe3
commit
d7f2f027f7
1 changed files with 36 additions and 0 deletions
|
|
@ -133,6 +133,22 @@ class JobPipelineTest extends TestCase
|
|||
// Foo job is not excuted
|
||||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function the_pipeline_can_execute_failed_method_on_job()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
ExceptionJob::class,
|
||||
])->send(function () {
|
||||
return $this->valuestore;
|
||||
})->toListener());
|
||||
|
||||
event(new TestEvent(new TestModel()));
|
||||
|
||||
sleep(1);
|
||||
|
||||
$this->assertEquals($this->valuestore->get('exeception'), 'pipeline exception');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function closures_can_be_used_as_jobs()
|
||||
|
|
@ -251,3 +267,23 @@ class FalseJob
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ExceptionJob
|
||||
{
|
||||
protected $valuestore;
|
||||
|
||||
public function __construct(Valuestore $valuestore)
|
||||
{
|
||||
$this->valuestore = $valuestore;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
throw new \Exception('pipeline exception', 1);
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e)
|
||||
{
|
||||
$this->valuestore->put('exeception', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue