2020-03-01 11:49:22 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-09-29 15:54:27 +02:00
|
|
|
namespace Psl\Tests\Result;
|
2020-03-01 11:49:22 +01:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2020-09-29 15:54:27 +02:00
|
|
|
use Psl\Result\Failure;
|
2020-03-01 11:49:22 +01:00
|
|
|
|
2020-09-29 15:54:27 +02:00
|
|
|
class FailureTest extends TestCase
|
2020-03-01 11:49:22 +01:00
|
|
|
{
|
|
|
|
public function testIsSucceeded(): void
|
|
|
|
{
|
2020-09-29 15:54:27 +02:00
|
|
|
$wrapper = new Failure(new \Exception('foo'));
|
2020-07-12 16:51:18 +02:00
|
|
|
self::assertFalse($wrapper->isSucceeded());
|
2020-03-01 11:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsFailed(): void
|
|
|
|
{
|
2020-09-29 15:54:27 +02:00
|
|
|
$wrapper = new Failure(new \Exception('foo'));
|
2020-07-12 16:51:18 +02:00
|
|
|
self::assertTrue($wrapper->isFailed());
|
2020-03-01 11:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetResult(): void
|
|
|
|
{
|
|
|
|
$exception = new \Exception('bar');
|
2020-09-29 15:54:27 +02:00
|
|
|
$wrapper = new Failure($exception);
|
2020-03-01 11:49:22 +01:00
|
|
|
|
|
|
|
$this->expectExceptionObject($exception);
|
|
|
|
$wrapper->getResult();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetException(): void
|
|
|
|
{
|
|
|
|
$exception = new \Exception('bar');
|
2020-09-29 15:54:27 +02:00
|
|
|
$wrapper = new Failure($exception);
|
2020-09-05 17:23:37 +02:00
|
|
|
$e = $wrapper->getException();
|
2020-07-12 16:51:18 +02:00
|
|
|
self::assertSame($exception, $e);
|
2020-03-01 11:49:22 +01:00
|
|
|
}
|
|
|
|
}
|