2017-12-14 06:06:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Parallel\Test\Worker;
|
|
|
|
|
|
|
|
use Amp\Parallel\Worker\Internal\TaskFailure;
|
|
|
|
use Amp\Parallel\Worker\Worker;
|
|
|
|
use Amp\PHPUnit\TestCase;
|
|
|
|
use Amp\Promise;
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
class TaskFailureTest extends TestCase
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
/**
|
|
|
|
* @expectedException \Amp\Parallel\Worker\TaskException
|
|
|
|
* @expectedExceptionMessage Uncaught Exception in worker
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testWithException()
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
$exception = new \Exception("Message", 1);
|
|
|
|
$result = new TaskFailure('a', $exception);
|
|
|
|
Promise\wait($result->promise());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Amp\Parallel\Worker\TaskError
|
|
|
|
* @expectedExceptionMessage Uncaught Error in worker
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testWithError()
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
$exception = new \Error("Message", 1);
|
|
|
|
$result = new TaskFailure('a', $exception);
|
|
|
|
Promise\wait($result->promise());
|
|
|
|
}
|
|
|
|
}
|