1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-04 18:47:50 +01:00
parallel/test/Worker/TaskFailureTest.php

32 lines
859 B
PHP
Raw Normal View History

2017-12-14 06:06:38 +01:00
<?php
namespace Amp\Parallel\Test\Worker;
use Amp\Parallel\Worker\Internal\TaskFailure;
2019-08-27 19:17:41 +02:00
use Amp\Parallel\Worker\TaskError;
use Amp\Parallel\Worker\TaskException;
use Amp\PHPUnit\AsyncTestCase;
2017-12-14 06:06:38 +01:00
2019-08-27 19:17:41 +02:00
class TaskFailureTest extends AsyncTestCase
2018-10-07 16:50:45 +02:00
{
public function testWithException()
{
2019-08-27 19:17:41 +02:00
$this->expectException(TaskException::class);
$this->expectExceptionMessage('Uncaught Exception in worker');
2017-12-14 06:06:38 +01:00
$exception = new \Exception("Message", 1);
$result = new TaskFailure('a', $exception);
2019-08-27 19:17:41 +02:00
yield $result->promise();
2017-12-14 06:06:38 +01:00
}
2018-10-07 16:50:45 +02:00
public function testWithError()
{
2019-08-27 19:17:41 +02:00
$this->expectException(TaskError::class);
$this->expectExceptionMessage('Uncaught Error in worker');
2017-12-14 06:06:38 +01:00
$exception = new \Error("Message", 1);
$result = new TaskFailure('a', $exception);
2019-08-27 19:17:41 +02:00
yield $result->promise();
2017-12-14 06:06:38 +01:00
}
}