菜谱项目

IsEqualIgnoringCaseTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Hamcrest\Text;
  3. class IsEqualIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
  4. {
  5. protected function createMatcher()
  6. {
  7. return \Hamcrest\Text\IsEqualIgnoringCase::equalToIgnoringCase('irrelevant');
  8. }
  9. public function testIgnoresCaseOfCharsInString()
  10. {
  11. assertThat('HELLO', equalToIgnoringCase('heLLo'));
  12. assertThat('hello', equalToIgnoringCase('heLLo'));
  13. assertThat('HelLo', equalToIgnoringCase('heLLo'));
  14. assertThat('bye', not(equalToIgnoringCase('heLLo')));
  15. }
  16. public function testFailsIfAdditionalWhitespaceIsPresent()
  17. {
  18. assertThat('heLLo ', not(equalToIgnoringCase('heLLo')));
  19. assertThat(' heLLo', not(equalToIgnoringCase('heLLo')));
  20. assertThat('hello', not(equalToIgnoringCase(' heLLo')));
  21. }
  22. public function testFailsIfMatchingAgainstNull()
  23. {
  24. assertThat(null, not(equalToIgnoringCase('heLLo')));
  25. }
  26. public function testDescribesItselfAsCaseInsensitive()
  27. {
  28. $this->assertDescription(
  29. 'equalToIgnoringCase("heLLo")',
  30. equalToIgnoringCase('heLLo')
  31. );
  32. }
  33. }