endtoend-test-psl/tests/Psl/Result/FailureTest.php

41 lines
942 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
2020-09-29 15:54:27 +02:00
namespace Psl\Tests\Result;
use PHPUnit\Framework\TestCase;
2020-09-29 15:54:27 +02:00
use Psl\Result\Failure;
2020-09-29 15:54:27 +02:00
class FailureTest extends TestCase
{
public function testIsSucceeded(): void
{
2020-09-29 15:54:27 +02:00
$wrapper = new Failure(new \Exception('foo'));
self::assertFalse($wrapper->isSucceeded());
}
public function testIsFailed(): void
{
2020-09-29 15:54:27 +02:00
$wrapper = new Failure(new \Exception('foo'));
self::assertTrue($wrapper->isFailed());
}
public function testGetResult(): void
{
$exception = new \Exception('bar');
2020-09-29 15:54:27 +02:00
$wrapper = new Failure($exception);
$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);
$e = $wrapper->getException();
self::assertSame($exception, $e);
}
}