| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Core;
|
|
|
3 |
|
|
|
4 |
class DescribedAsTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return \Hamcrest\Core\DescribedAs::describedAs('irrelevant', anything());
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testOverridesDescriptionOfOtherMatcherWithThatPassedToConstructor()
|
|
|
13 |
{
|
|
|
14 |
$m1 = describedAs('m1 description', anything());
|
|
|
15 |
$m2 = describedAs('m2 description', not(anything()));
|
|
|
16 |
|
|
|
17 |
$this->assertDescription('m1 description', $m1);
|
|
|
18 |
$this->assertDescription('m2 description', $m2);
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
public function testAppendsValuesToDescription()
|
|
|
22 |
{
|
|
|
23 |
$m = describedAs('value 1 = %0, value 2 = %1', anything(), 33, 97);
|
|
|
24 |
|
|
|
25 |
$this->assertDescription('value 1 = <33>, value 2 = <97>', $m);
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public function testDelegatesMatchingToAnotherMatcher()
|
|
|
29 |
{
|
|
|
30 |
$m1 = describedAs('irrelevant', anything());
|
|
|
31 |
$m2 = describedAs('irrelevant', not(anything()));
|
|
|
32 |
|
|
|
33 |
$this->assertTrue($m1->matches(new \stdClass()));
|
|
|
34 |
$this->assertFalse($m2->matches('hi'));
|
|
|
35 |
}
|
|
|
36 |
}
|