Add PhpOption support to Option::of

This commit is contained in:
2024-07-27 21:20:35 -04:00
parent 7837f4af17
commit 7d25b9ea28
4 changed files with 96 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ namespace Test;
use BitBadger\InspiredByFSharp\Option;
use InvalidArgumentException;
use PhpOption\{None, Some};
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
@@ -64,6 +65,21 @@ class OptionTest extends TestCase
$this->assertEquals('test', $it->get(), 'The value was not assigned correctly');
}
#[TestDox('Of succeeds with PhpOption\Some')]
public function testOfSucceedsWithPhpOptionSome(): void
{
$it = Option::of(Some::create('something'));
$this->assertTrue(Option::isSome($it), 'A "Some" PhpOption should have created a "Some" option');
$this->assertEquals('something', $it->get(), 'The value was not assigned correctly');
}
#[TestDox('Of succeeds with PhpOption\None')]
public function testOfSucceedsWithPhpOptionNone(): void
{
$it = Option::of(None::create());
$this->assertTrue(Option::isNone($it), 'A "None" PhpOption should have created a "None" option');
}
#[TestDox('IsNone succeeds with None')]
public function testIsNoneSucceedsWithNone(): void
{