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