first commit
This commit is contained in:
54
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInAnyOrderTest.php
vendored
Normal file
54
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInAnyOrderTest.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayContainingInAnyOrderTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayContainingInAnyOrder::arrayContainingInAnyOrder(array(1, 2));
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('[<1>, <2>] in any order', containsInAnyOrder(array(1, 2)));
|
||||
}
|
||||
|
||||
public function testMatchesItemsInAnyOrder()
|
||||
{
|
||||
$this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(1, 2, 3), 'in order');
|
||||
$this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(3, 2, 1), 'out of order');
|
||||
$this->assertMatches(containsInAnyOrder(array(1)), array(1), 'single');
|
||||
}
|
||||
|
||||
public function testAppliesMatchersInAnyOrder()
|
||||
{
|
||||
$this->assertMatches(
|
||||
containsInAnyOrder(array(1, 2, 3)),
|
||||
array(1, 2, 3),
|
||||
'in order'
|
||||
);
|
||||
$this->assertMatches(
|
||||
containsInAnyOrder(array(1, 2, 3)),
|
||||
array(3, 2, 1),
|
||||
'out of order'
|
||||
);
|
||||
$this->assertMatches(
|
||||
containsInAnyOrder(array(1)),
|
||||
array(1),
|
||||
'single'
|
||||
);
|
||||
}
|
||||
|
||||
public function testMismatchesItemsInAnyOrder()
|
||||
{
|
||||
$matcher = containsInAnyOrder(array(1, 2, 3));
|
||||
|
||||
$this->assertMismatchDescription('was null', $matcher, null);
|
||||
$this->assertMismatchDescription('No item matches: <1>, <2>, <3> in []', $matcher, array());
|
||||
$this->assertMismatchDescription('No item matches: <2>, <3> in [<1>]', $matcher, array(1));
|
||||
$this->assertMismatchDescription('Not matched: <4>', $matcher, array(4, 3, 2, 1));
|
||||
}
|
||||
}
|
48
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInOrderTest.php
vendored
Normal file
48
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInOrderTest.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayContainingInOrderTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayContainingInOrder::arrayContaining(array(1, 2));
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('[<1>, <2>]', arrayContaining(array(1, 2)));
|
||||
}
|
||||
|
||||
public function testMatchesItemsInOrder()
|
||||
{
|
||||
$this->assertMatches(arrayContaining(array(1, 2, 3)), array(1, 2, 3), 'in order');
|
||||
$this->assertMatches(arrayContaining(array(1)), array(1), 'single');
|
||||
}
|
||||
|
||||
public function testAppliesMatchersInOrder()
|
||||
{
|
||||
$this->assertMatches(
|
||||
arrayContaining(array(1, 2, 3)),
|
||||
array(1, 2, 3),
|
||||
'in order'
|
||||
);
|
||||
$this->assertMatches(arrayContaining(array(1)), array(1), 'single');
|
||||
}
|
||||
|
||||
public function testMismatchesItemsInAnyOrder()
|
||||
{
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('Broken on HHVM.');
|
||||
}
|
||||
|
||||
$matcher = arrayContaining(array(1, 2, 3));
|
||||
$this->assertMismatchDescription('was null', $matcher, null);
|
||||
$this->assertMismatchDescription('No item matched: <1>', $matcher, array());
|
||||
$this->assertMismatchDescription('No item matched: <2>', $matcher, array(1));
|
||||
$this->assertMismatchDescription('item with key 0: was <4>', $matcher, array(4, 3, 2, 1));
|
||||
$this->assertMismatchDescription('item with key 2: was <4>', $matcher, array(1, 2, 4));
|
||||
}
|
||||
}
|
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
vendored
Normal file
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayContainingKeyTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayContainingKey::hasKeyInArray('irrelevant');
|
||||
}
|
||||
|
||||
public function testMatchesSingleElementArrayContainingKey()
|
||||
{
|
||||
$array = array('a'=>1);
|
||||
|
||||
$this->assertMatches(hasKey('a'), $array, 'Matches single key');
|
||||
}
|
||||
|
||||
public function testMatchesArrayContainingKey()
|
||||
{
|
||||
$array = array('a'=>1, 'b'=>2, 'c'=>3);
|
||||
|
||||
$this->assertMatches(hasKey('a'), $array, 'Matches a');
|
||||
$this->assertMatches(hasKey('c'), $array, 'Matches c');
|
||||
}
|
||||
|
||||
public function testMatchesArrayContainingKeyWithIntegerKeys()
|
||||
{
|
||||
$array = array(1=>'A', 2=>'B');
|
||||
|
||||
assertThat($array, hasKey(1));
|
||||
}
|
||||
|
||||
public function testMatchesArrayContainingKeyWithNumberKeys()
|
||||
{
|
||||
$array = array(1=>'A', 2=>'B');
|
||||
|
||||
assertThat($array, hasKey(1));
|
||||
|
||||
// very ugly version!
|
||||
assertThat($array, IsArrayContainingKey::hasKeyInArray(2));
|
||||
}
|
||||
|
||||
public function testHasReadableDescription()
|
||||
{
|
||||
$this->assertDescription('array with key "a"', hasKey('a'));
|
||||
}
|
||||
|
||||
public function testDoesNotMatchEmptyArray()
|
||||
{
|
||||
$this->assertMismatchDescription('array was []', hasKey('Foo'), array());
|
||||
}
|
||||
|
||||
public function testDoesNotMatchArrayMissingKey()
|
||||
{
|
||||
$array = array('a'=>1, 'b'=>2, 'c'=>3);
|
||||
|
||||
$this->assertMismatchDescription('array was ["a" => <1>, "b" => <2>, "c" => <3>]', hasKey('d'), $array);
|
||||
}
|
||||
}
|
36
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php
vendored
Normal file
36
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayContainingKeyValuePairTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayContainingKeyValuePair::hasKeyValuePair('irrelevant', 'irrelevant');
|
||||
}
|
||||
|
||||
public function testMatchesArrayContainingMatchingKeyAndValue()
|
||||
{
|
||||
$array = array('a'=>1, 'b'=>2);
|
||||
|
||||
$this->assertMatches(hasKeyValuePair(equalTo('a'), equalTo(1)), $array, 'matcherA');
|
||||
$this->assertMatches(hasKeyValuePair(equalTo('b'), equalTo(2)), $array, 'matcherB');
|
||||
$this->assertMismatchDescription(
|
||||
'array was ["a" => <1>, "b" => <2>]',
|
||||
hasKeyValuePair(equalTo('c'), equalTo(3)),
|
||||
$array
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchNull()
|
||||
{
|
||||
$this->assertMismatchDescription('was null', hasKeyValuePair(anything(), anything()), null);
|
||||
}
|
||||
|
||||
public function testHasReadableDescription()
|
||||
{
|
||||
$this->assertDescription('array containing ["a" => <2>]', hasKeyValuePair(equalTo('a'), equalTo(2)));
|
||||
}
|
||||
}
|
50
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingTest.php
vendored
Normal file
50
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingTest.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayContainingTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayContaining::hasItemInArray('irrelevant');
|
||||
}
|
||||
|
||||
public function testMatchesAnArrayThatContainsAnElementMatchingTheGivenMatcher()
|
||||
{
|
||||
$this->assertMatches(
|
||||
hasItemInArray('a'),
|
||||
array('a', 'b', 'c'),
|
||||
"should matches array that contains 'a'"
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchAnArrayThatDoesntContainAnElementMatchingTheGivenMatcher()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
hasItemInArray('a'),
|
||||
array('b', 'c'),
|
||||
"should not matches array that doesn't contain 'a'"
|
||||
);
|
||||
$this->assertDoesNotMatch(
|
||||
hasItemInArray('a'),
|
||||
array(),
|
||||
'should not match empty array'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchNull()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
hasItemInArray('a'),
|
||||
null,
|
||||
'should not match null'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('an array containing "a"', hasItemInArray('a'));
|
||||
}
|
||||
}
|
89
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayTest.php
vendored
Normal file
89
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayTest.php
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArray::anArray(array(equalTo('irrelevant')));
|
||||
}
|
||||
|
||||
public function testMatchesAnArrayThatMatchesAllTheElementMatchers()
|
||||
{
|
||||
$this->assertMatches(
|
||||
anArray(array(equalTo('a'), equalTo('b'), equalTo('c'))),
|
||||
array('a', 'b', 'c'),
|
||||
'should match array with matching elements'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchAnArrayWhenElementsDoNotMatch()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
anArray(array(equalTo('a'), equalTo('b'))),
|
||||
array('b', 'c'),
|
||||
'should not match array with different elements'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchAnArrayOfDifferentSize()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
anArray(array(equalTo('a'), equalTo('b'))),
|
||||
array('a', 'b', 'c'),
|
||||
'should not match larger array'
|
||||
);
|
||||
$this->assertDoesNotMatch(
|
||||
anArray(array(equalTo('a'), equalTo('b'))),
|
||||
array('a'),
|
||||
'should not match smaller array'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchNull()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
anArray(array(equalTo('a'))),
|
||||
null,
|
||||
'should not match null'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription(
|
||||
'["a", "b"]',
|
||||
anArray(array(equalTo('a'), equalTo('b')))
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableMismatchDescriptionWhenKeysDontMatch()
|
||||
{
|
||||
$this->assertMismatchDescription(
|
||||
'array keys were [<1>, <2>]',
|
||||
anArray(array(equalTo('a'), equalTo('b'))),
|
||||
array(1 => 'a', 2 => 'b')
|
||||
);
|
||||
}
|
||||
|
||||
public function testSupportsMatchesAssociativeArrays()
|
||||
{
|
||||
$this->assertMatches(
|
||||
anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'), 'z'=>equalTo('c'))),
|
||||
array('x'=>'a', 'y'=>'b', 'z'=>'c'),
|
||||
'should match associative array with matching elements'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoesNotMatchAnAssociativeArrayWhenKeysDoNotMatch()
|
||||
{
|
||||
$this->assertDoesNotMatch(
|
||||
anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'))),
|
||||
array('x'=>'b', 'z'=>'c'),
|
||||
'should not match array with different keys'
|
||||
);
|
||||
}
|
||||
}
|
37
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayWithSizeTest.php
vendored
Normal file
37
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayWithSizeTest.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace Hamcrest\Arrays;
|
||||
|
||||
use Hamcrest\AbstractMatcherTest;
|
||||
|
||||
class IsArrayWithSizeTest extends AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return IsArrayWithSize::arrayWithSize(equalTo(2));
|
||||
}
|
||||
|
||||
public function testMatchesWhenSizeIsCorrect()
|
||||
{
|
||||
$this->assertMatches(arrayWithSize(equalTo(3)), array(1, 2, 3), 'correct size');
|
||||
$this->assertDoesNotMatch(arrayWithSize(equalTo(2)), array(1, 2, 3), 'incorrect size');
|
||||
}
|
||||
|
||||
public function testProvidesConvenientShortcutForArrayWithSizeEqualTo()
|
||||
{
|
||||
$this->assertMatches(arrayWithSize(3), array(1, 2, 3), 'correct size');
|
||||
$this->assertDoesNotMatch(arrayWithSize(2), array(1, 2, 3), 'incorrect size');
|
||||
}
|
||||
|
||||
public function testEmptyArray()
|
||||
{
|
||||
$this->assertMatches(emptyArray(), array(), 'correct size');
|
||||
$this->assertDoesNotMatch(emptyArray(), array(1), 'incorrect size');
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('an array with size <3>', arrayWithSize(equalTo(3)));
|
||||
$this->assertDescription('an empty array', emptyArray());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user