public function testCreatingAnIdentityWithANonIdentityParameterWillReturnAnIdentityContainingTheParameterAsValue() { $sut = Identity::create('foo'); $this->assertInstanceOf('Monad\\Identity', $sut); $this->assertEquals('foo', $sut->value()); $sut1 = Identity::create(function ($a) { return $a; }); $this->assertInstanceOf('Monad\\Identity', $sut1); $this->assertInstanceOf('Closure', $sut1->value()); }
public function testYouCanNestMatches() { $this->assertEquals('foo', $this->nestedMatcher('foo')->value()); $this->assertEquals('bar', $this->nestedMatcher(Option::create('bar'))->value()); try { $this->nestedMatcher(Option::create()); $this->fail('Expected an Exception but got none'); } catch (\Exception $e) { $this->assertTrue(true); } $this->assertEquals('foobar', $this->nestedMatcher(Identity::create('foo'))->value()); //expecting match on any() as integer won't be matched $this->assertEquals('any', $this->nestedMatcher(2)->value()); }