| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Text;
|
|
|
3 |
|
|
|
4 |
class IsEmptyStringTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString();
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testEmptyDoesNotMatchNull()
|
|
|
13 |
{
|
|
|
14 |
$this->assertDoesNotMatch(emptyString(), null, 'null');
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
public function testEmptyDoesNotMatchZero()
|
|
|
18 |
{
|
|
|
19 |
$this->assertDoesNotMatch(emptyString(), 0, 'zero');
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function testEmptyDoesNotMatchFalse()
|
|
|
23 |
{
|
|
|
24 |
$this->assertDoesNotMatch(emptyString(), false, 'false');
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function testEmptyDoesNotMatchEmptyArray()
|
|
|
28 |
{
|
|
|
29 |
$this->assertDoesNotMatch(emptyString(), array(), 'empty array');
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function testEmptyMatchesEmptyString()
|
|
|
33 |
{
|
|
|
34 |
$this->assertMatches(emptyString(), '', 'empty string');
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public function testEmptyDoesNotMatchNonEmptyString()
|
|
|
38 |
{
|
|
|
39 |
$this->assertDoesNotMatch(emptyString(), 'foo', 'non-empty string');
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public function testEmptyHasAReadableDescription()
|
|
|
43 |
{
|
|
|
44 |
$this->assertDescription('an empty string', emptyString());
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public function testEmptyOrNullMatchesNull()
|
|
|
48 |
{
|
|
|
49 |
$this->assertMatches(nullOrEmptyString(), null, 'null');
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public function testEmptyOrNullMatchesEmptyString()
|
|
|
53 |
{
|
|
|
54 |
$this->assertMatches(nullOrEmptyString(), '', 'empty string');
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public function testEmptyOrNullDoesNotMatchNonEmptyString()
|
|
|
58 |
{
|
|
|
59 |
$this->assertDoesNotMatch(nullOrEmptyString(), 'foo', 'non-empty string');
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public function testEmptyOrNullHasAReadableDescription()
|
|
|
63 |
{
|
|
|
64 |
$this->assertDescription('(null or an empty string)', nullOrEmptyString());
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public function testNonEmptyDoesNotMatchNull()
|
|
|
68 |
{
|
|
|
69 |
$this->assertDoesNotMatch(nonEmptyString(), null, 'null');
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public function testNonEmptyDoesNotMatchEmptyString()
|
|
|
73 |
{
|
|
|
74 |
$this->assertDoesNotMatch(nonEmptyString(), '', 'empty string');
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public function testNonEmptyMatchesNonEmptyString()
|
|
|
78 |
{
|
|
|
79 |
$this->assertMatches(nonEmptyString(), 'foo', 'non-empty string');
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public function testNonEmptyHasAReadableDescription()
|
|
|
83 |
{
|
|
|
84 |
$this->assertDescription('a non-empty string', nonEmptyString());
|
|
|
85 |
}
|
|
|
86 |
}
|