IsEqualIgnoringCaseTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }