first commit
This commit is contained in:
86
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEmptyStringTest.php
vendored
Normal file
86
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEmptyStringTest.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class IsEmptyStringTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString();
|
||||
}
|
||||
|
||||
public function testEmptyDoesNotMatchNull()
|
||||
{
|
||||
$this->assertDoesNotMatch(emptyString(), null, 'null');
|
||||
}
|
||||
|
||||
public function testEmptyDoesNotMatchZero()
|
||||
{
|
||||
$this->assertDoesNotMatch(emptyString(), 0, 'zero');
|
||||
}
|
||||
|
||||
public function testEmptyDoesNotMatchFalse()
|
||||
{
|
||||
$this->assertDoesNotMatch(emptyString(), false, 'false');
|
||||
}
|
||||
|
||||
public function testEmptyDoesNotMatchEmptyArray()
|
||||
{
|
||||
$this->assertDoesNotMatch(emptyString(), array(), 'empty array');
|
||||
}
|
||||
|
||||
public function testEmptyMatchesEmptyString()
|
||||
{
|
||||
$this->assertMatches(emptyString(), '', 'empty string');
|
||||
}
|
||||
|
||||
public function testEmptyDoesNotMatchNonEmptyString()
|
||||
{
|
||||
$this->assertDoesNotMatch(emptyString(), 'foo', 'non-empty string');
|
||||
}
|
||||
|
||||
public function testEmptyHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('an empty string', emptyString());
|
||||
}
|
||||
|
||||
public function testEmptyOrNullMatchesNull()
|
||||
{
|
||||
$this->assertMatches(nullOrEmptyString(), null, 'null');
|
||||
}
|
||||
|
||||
public function testEmptyOrNullMatchesEmptyString()
|
||||
{
|
||||
$this->assertMatches(nullOrEmptyString(), '', 'empty string');
|
||||
}
|
||||
|
||||
public function testEmptyOrNullDoesNotMatchNonEmptyString()
|
||||
{
|
||||
$this->assertDoesNotMatch(nullOrEmptyString(), 'foo', 'non-empty string');
|
||||
}
|
||||
|
||||
public function testEmptyOrNullHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('(null or an empty string)', nullOrEmptyString());
|
||||
}
|
||||
|
||||
public function testNonEmptyDoesNotMatchNull()
|
||||
{
|
||||
$this->assertDoesNotMatch(nonEmptyString(), null, 'null');
|
||||
}
|
||||
|
||||
public function testNonEmptyDoesNotMatchEmptyString()
|
||||
{
|
||||
$this->assertDoesNotMatch(nonEmptyString(), '', 'empty string');
|
||||
}
|
||||
|
||||
public function testNonEmptyMatchesNonEmptyString()
|
||||
{
|
||||
$this->assertMatches(nonEmptyString(), 'foo', 'non-empty string');
|
||||
}
|
||||
|
||||
public function testNonEmptyHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('a non-empty string', nonEmptyString());
|
||||
}
|
||||
}
|
40
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringCaseTest.php
vendored
Normal file
40
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringCaseTest.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class IsEqualIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return \Hamcrest\Text\IsEqualIgnoringCase::equalToIgnoringCase('irrelevant');
|
||||
}
|
||||
|
||||
public function testIgnoresCaseOfCharsInString()
|
||||
{
|
||||
assertThat('HELLO', equalToIgnoringCase('heLLo'));
|
||||
assertThat('hello', equalToIgnoringCase('heLLo'));
|
||||
assertThat('HelLo', equalToIgnoringCase('heLLo'));
|
||||
|
||||
assertThat('bye', not(equalToIgnoringCase('heLLo')));
|
||||
}
|
||||
|
||||
public function testFailsIfAdditionalWhitespaceIsPresent()
|
||||
{
|
||||
assertThat('heLLo ', not(equalToIgnoringCase('heLLo')));
|
||||
assertThat(' heLLo', not(equalToIgnoringCase('heLLo')));
|
||||
assertThat('hello', not(equalToIgnoringCase(' heLLo')));
|
||||
}
|
||||
|
||||
public function testFailsIfMatchingAgainstNull()
|
||||
{
|
||||
assertThat(null, not(equalToIgnoringCase('heLLo')));
|
||||
}
|
||||
|
||||
public function testDescribesItselfAsCaseInsensitive()
|
||||
{
|
||||
$this->assertDescription(
|
||||
'equalToIgnoringCase("heLLo")',
|
||||
equalToIgnoringCase('heLLo')
|
||||
);
|
||||
}
|
||||
}
|
51
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php
vendored
Normal file
51
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class IsEqualIgnoringWhiteSpaceTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
private $_matcher;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_matcher = \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace(
|
||||
"Hello World how\n are we? "
|
||||
);
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_matcher;
|
||||
}
|
||||
|
||||
public function testPassesIfWordsAreSameButWhitespaceDiffers()
|
||||
{
|
||||
assertThat('Hello World how are we?', $this->_matcher);
|
||||
assertThat(" Hello \rWorld \t how are\nwe?", $this->_matcher);
|
||||
}
|
||||
|
||||
public function testFailsIfTextOtherThanWhitespaceDiffers()
|
||||
{
|
||||
assertThat('Hello PLANET how are we?', not($this->_matcher));
|
||||
assertThat('Hello World how are we', not($this->_matcher));
|
||||
}
|
||||
|
||||
public function testFailsIfWhitespaceIsAddedOrRemovedInMidWord()
|
||||
{
|
||||
assertThat('HelloWorld how are we?', not($this->_matcher));
|
||||
assertThat('Hello Wo rld how are we?', not($this->_matcher));
|
||||
}
|
||||
|
||||
public function testFailsIfMatchingAgainstNull()
|
||||
{
|
||||
assertThat(null, not($this->_matcher));
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription(
|
||||
"equalToIgnoringWhiteSpace(\"Hello World how\\n are we? \")",
|
||||
$this->_matcher
|
||||
);
|
||||
}
|
||||
}
|
30
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/MatchesPatternTest.php
vendored
Normal file
30
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/MatchesPatternTest.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class MatchesPatternTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return matchesPattern('/o+b/');
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentmatchesPattern()
|
||||
{
|
||||
assertThat('foobar', matchesPattern('/o+b/'));
|
||||
assertThat('foobar', matchesPattern('/^foo/'));
|
||||
assertThat('foobar', matchesPattern('/ba*r$/'));
|
||||
assertThat('foobar', matchesPattern('/^foobar$/'));
|
||||
}
|
||||
|
||||
public function testEvaluatesToFalseIfArgumentDoesntMatchRegex()
|
||||
{
|
||||
assertThat('foobar', not(matchesPattern('/^foob$/')));
|
||||
assertThat('foobar', not(matchesPattern('/oobe/')));
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('a string matching "pattern"', matchesPattern('pattern'));
|
||||
}
|
||||
}
|
80
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
vendored
Normal file
80
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
const EXCERPT = 'ExcErPt';
|
||||
|
||||
private $_stringContains;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase(
|
||||
strtolower(self::EXCERPT)
|
||||
);
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_stringContains;
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT . 'END'),
|
||||
'should be true if excerpt at beginning'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches('START' . self::EXCERPT),
|
||||
'should be true if excerpt at end'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches('START' . self::EXCERPT . 'END'),
|
||||
'should be true if excerpt in middle'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT . self::EXCERPT),
|
||||
'should be true if excerpt is repeated'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches('Something else'),
|
||||
'should not be true if excerpt is not in string'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches(substr(self::EXCERPT, 1)),
|
||||
'should not be true if part of excerpt is in string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT),
|
||||
'should be true if excerpt is entire string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentContainsExactSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(strtolower(self::EXCERPT)),
|
||||
'should be false if excerpt is entire string ignoring case'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches('START' . strtolower(self::EXCERPT) . 'END'),
|
||||
'should be false if excerpt is contained in string ignoring case'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription(
|
||||
'a string containing in any case "'
|
||||
. strtolower(self::EXCERPT) . '"',
|
||||
$this->_stringContains
|
||||
);
|
||||
}
|
||||
}
|
42
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsInOrderTest.php
vendored
Normal file
42
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsInOrderTest.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class StringContainsInOrderTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
private $_m;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_m = \Hamcrest\Text\StringContainsInOrder::stringContainsInOrder(array('a', 'b', 'c'));
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_m;
|
||||
}
|
||||
|
||||
public function testMatchesOnlyIfStringContainsGivenSubstringsInTheSameOrder()
|
||||
{
|
||||
$this->assertMatches($this->_m, 'abc', 'substrings in order');
|
||||
$this->assertMatches($this->_m, '1a2b3c4', 'substrings separated');
|
||||
|
||||
$this->assertDoesNotMatch($this->_m, 'cab', 'substrings out of order');
|
||||
$this->assertDoesNotMatch($this->_m, 'xyz', 'no substrings in string');
|
||||
$this->assertDoesNotMatch($this->_m, 'ac', 'substring missing');
|
||||
$this->assertDoesNotMatch($this->_m, '', 'empty string');
|
||||
}
|
||||
|
||||
public function testAcceptsVariableArguments()
|
||||
{
|
||||
$this->assertMatches(stringContainsInOrder('a', 'b', 'c'), 'abc', 'substrings as variable arguments');
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription(
|
||||
'a string containing "a", "b", "c" in order',
|
||||
$this->_m
|
||||
);
|
||||
}
|
||||
}
|
86
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsTest.php
vendored
Normal file
86
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsTest.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class StringContainsTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
const EXCERPT = 'EXCERPT';
|
||||
|
||||
private $_stringContains;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_stringContains = \Hamcrest\Text\StringContains::containsString(self::EXCERPT);
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_stringContains;
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentContainsSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT . 'END'),
|
||||
'should be true if excerpt at beginning'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches('START' . self::EXCERPT),
|
||||
'should be true if excerpt at end'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches('START' . self::EXCERPT . 'END'),
|
||||
'should be true if excerpt in middle'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT . self::EXCERPT),
|
||||
'should be true if excerpt is repeated'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches('Something else'),
|
||||
'should not be true if excerpt is not in string'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches(substr(self::EXCERPT, 1)),
|
||||
'should not be true if part of excerpt is in string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->matches(self::EXCERPT),
|
||||
'should be true if excerpt is entire string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToFalseIfArgumentContainsSubstringIgnoringCase()
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches(strtolower(self::EXCERPT)),
|
||||
'should be false if excerpt is entire string ignoring case'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringContains->matches('START' . strtolower(self::EXCERPT) . 'END'),
|
||||
'should be false if excerpt is contained in string ignoring case'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIgnoringCaseReturnsCorrectMatcher()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringContains->ignoringCase()->matches('EXceRpT'),
|
||||
'should be true if excerpt is entire string ignoring case'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription(
|
||||
'a string containing "'
|
||||
. self::EXCERPT . '"',
|
||||
$this->_stringContains
|
||||
);
|
||||
}
|
||||
}
|
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringEndsWithTest.php
vendored
Normal file
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringEndsWithTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class StringEndsWithTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
const EXCERPT = 'EXCERPT';
|
||||
|
||||
private $_stringEndsWith;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_stringEndsWith = \Hamcrest\Text\StringEndsWith::endsWith(self::EXCERPT);
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_stringEndsWith;
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring()
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->_stringEndsWith->matches(self::EXCERPT . 'END'),
|
||||
'should be false if excerpt at beginning'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringEndsWith->matches('START' . self::EXCERPT),
|
||||
'should be true if excerpt at end'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringEndsWith->matches('START' . self::EXCERPT . 'END'),
|
||||
'should be false if excerpt in middle'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringEndsWith->matches(self::EXCERPT . self::EXCERPT),
|
||||
'should be true if excerpt is at end and repeated'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_stringEndsWith->matches('Something else'),
|
||||
'should be false if excerpt is not in string'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringEndsWith->matches(substr(self::EXCERPT, 0, strlen(self::EXCERPT) - 2)),
|
||||
'should be false if part of excerpt is at end of string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringEndsWith->matches(self::EXCERPT),
|
||||
'should be true if excerpt is entire string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('a string ending with "EXCERPT"', $this->_stringEndsWith);
|
||||
}
|
||||
}
|
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringStartsWithTest.php
vendored
Normal file
62
vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringStartsWithTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Hamcrest\Text;
|
||||
|
||||
class StringStartsWithTest extends \Hamcrest\AbstractMatcherTest
|
||||
{
|
||||
|
||||
const EXCERPT = 'EXCERPT';
|
||||
|
||||
private $_stringStartsWith;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_stringStartsWith = \Hamcrest\Text\StringStartsWith::startsWith(self::EXCERPT);
|
||||
}
|
||||
|
||||
protected function createMatcher()
|
||||
{
|
||||
return $this->_stringStartsWith;
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringStartsWith->matches(self::EXCERPT . 'END'),
|
||||
'should be true if excerpt at beginning'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringStartsWith->matches('START' . self::EXCERPT),
|
||||
'should be false if excerpt at end'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringStartsWith->matches('START' . self::EXCERPT . 'END'),
|
||||
'should be false if excerpt in middle'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_stringStartsWith->matches(self::EXCERPT . self::EXCERPT),
|
||||
'should be true if excerpt is at beginning and repeated'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_stringStartsWith->matches('Something else'),
|
||||
'should be false if excerpt is not in string'
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_stringStartsWith->matches(substr(self::EXCERPT, 1)),
|
||||
'should be false if part of excerpt is at start of string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testEvaluatesToTrueIfArgumentIsEqualToSubstring()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->_stringStartsWith->matches(self::EXCERPT),
|
||||
'should be true if excerpt is entire string'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHasAReadableDescription()
|
||||
{
|
||||
$this->assertDescription('a string starting with "EXCERPT"', $this->_stringStartsWith);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user