-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Matchers can now be used as callables (#40)
Matchers can now be used as callables
- Loading branch information
1 parent
8bfb401
commit b7a5e18
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
namespace Hamcrest; | ||
|
||
|
||
class SampleInvokeMatcher extends BaseMatcherTest | ||
{ | ||
private $matchAgainst; | ||
|
||
public function __construct($matchAgainst) | ||
{ | ||
$this->matchAgainst = $matchAgainst; | ||
} | ||
|
||
public function matches($item) | ||
{ | ||
return $item == $this->matchAgainst; | ||
} | ||
|
||
} | ||
|
||
class InvokedMatcherTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testInvokedMatchersCallMatches() | ||
{ | ||
$sampleMatcher = new SampleInvokeMatcher('foo'); | ||
|
||
$this->assertTrue($sampleMatcher('foo')); | ||
$this->assertFalse($sampleMatcher('bar')); | ||
} | ||
} |