EnsureTest::testOptionReturnedFromClosure()


Source

File: vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php

    public function testOptionReturnedFromClosure()
    {
        $option = $this->ensure(function() { return Some::create(1); });
        $this->assertTrue($option->isDefined());
        $this->assertSame(1, $option->get());

        $option = $this->ensure(function() { return None::create(); });
        $this->assertFalse($option->isDefined());
    }