1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-27 04:44:56 +01:00
parallel/test/Worker/TaskFailureTest.php

34 lines
866 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;
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());
}
}