Beispiel #1
0
 public function testYouCanFlattenAnIdentityValueToItsBaseType()
 {
     $sut = new Identity(function () {
         return 'foo';
     });
     $func = function ($value) {
         return $value . 'bar';
     };
     $this->assertEquals('foobar', $sut->bind($func)->flatten());
 }
Beispiel #2
0
 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());
 }