2017-12-14 06:06:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Parallel\Test\Sync;
|
|
|
|
|
|
|
|
use Amp\Parallel\Sync\ExitFailure;
|
|
|
|
use Amp\Parallel\Sync\PanicError;
|
|
|
|
use Amp\PHPUnit\TestCase;
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
class ExitFailureTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testGetResult()
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
$message = "Test message";
|
|
|
|
$exception = new \Exception($message);
|
|
|
|
$result = new ExitFailure($exception);
|
|
|
|
try {
|
|
|
|
$result->getResult();
|
|
|
|
} catch (PanicError $caught) {
|
|
|
|
$this->assertGreaterThan(0, \stripos($caught->getMessage(), $message));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->fail(\sprintf("Exception should be thrown from %s::getResult()", ExitFailure::class));
|
|
|
|
}
|
|
|
|
}
|