| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Arrays;
|
|
|
3 |
|
|
|
4 |
use Hamcrest\AbstractMatcherTest;
|
|
|
5 |
|
|
|
6 |
class IsArrayWithSizeTest extends AbstractMatcherTest
|
|
|
7 |
{
|
|
|
8 |
|
|
|
9 |
protected function createMatcher()
|
|
|
10 |
{
|
|
|
11 |
return IsArrayWithSize::arrayWithSize(equalTo(2));
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
public function testMatchesWhenSizeIsCorrect()
|
|
|
15 |
{
|
|
|
16 |
$this->assertMatches(arrayWithSize(equalTo(3)), array(1, 2, 3), 'correct size');
|
|
|
17 |
$this->assertDoesNotMatch(arrayWithSize(equalTo(2)), array(1, 2, 3), 'incorrect size');
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function testProvidesConvenientShortcutForArrayWithSizeEqualTo()
|
|
|
21 |
{
|
|
|
22 |
$this->assertMatches(arrayWithSize(3), array(1, 2, 3), 'correct size');
|
|
|
23 |
$this->assertDoesNotMatch(arrayWithSize(2), array(1, 2, 3), 'incorrect size');
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public function testEmptyArray()
|
|
|
27 |
{
|
|
|
28 |
$this->assertMatches(emptyArray(), array(), 'correct size');
|
|
|
29 |
$this->assertDoesNotMatch(emptyArray(), array(1), 'incorrect size');
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function testHasAReadableDescription()
|
|
|
33 |
{
|
|
|
34 |
$this->assertDescription('an array with size <3>', arrayWithSize(equalTo(3)));
|
|
|
35 |
$this->assertDescription('an empty array', emptyArray());
|
|
|
36 |
}
|
|
|
37 |
}
|