You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.2 KiB

3 years ago
  1. <?php
  2. namespace Hamcrest\Text;
  3. class IsEmptyStringTest extends \Hamcrest\AbstractMatcherTest
  4. {
  5. protected function createMatcher()
  6. {
  7. return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString();
  8. }
  9. public function testEmptyDoesNotMatchNull()
  10. {
  11. $this->assertDoesNotMatch(emptyString(), null, 'null');
  12. }
  13. public function testEmptyDoesNotMatchZero()
  14. {
  15. $this->assertDoesNotMatch(emptyString(), 0, 'zero');
  16. }
  17. public function testEmptyDoesNotMatchFalse()
  18. {
  19. $this->assertDoesNotMatch(emptyString(), false, 'false');
  20. }
  21. public function testEmptyDoesNotMatchEmptyArray()
  22. {
  23. $this->assertDoesNotMatch(emptyString(), array(), 'empty array');
  24. }
  25. public function testEmptyMatchesEmptyString()
  26. {
  27. $this->assertMatches(emptyString(), '', 'empty string');
  28. }
  29. public function testEmptyDoesNotMatchNonEmptyString()
  30. {
  31. $this->assertDoesNotMatch(emptyString(), 'foo', 'non-empty string');
  32. }
  33. public function testEmptyHasAReadableDescription()
  34. {
  35. $this->assertDescription('an empty string', emptyString());
  36. }
  37. public function testEmptyOrNullMatchesNull()
  38. {
  39. $this->assertMatches(nullOrEmptyString(), null, 'null');
  40. }
  41. public function testEmptyOrNullMatchesEmptyString()
  42. {
  43. $this->assertMatches(nullOrEmptyString(), '', 'empty string');
  44. }
  45. public function testEmptyOrNullDoesNotMatchNonEmptyString()
  46. {
  47. $this->assertDoesNotMatch(nullOrEmptyString(), 'foo', 'non-empty string');
  48. }
  49. public function testEmptyOrNullHasAReadableDescription()
  50. {
  51. $this->assertDescription('(null or an empty string)', nullOrEmptyString());
  52. }
  53. public function testNonEmptyDoesNotMatchNull()
  54. {
  55. $this->assertDoesNotMatch(nonEmptyString(), null, 'null');
  56. }
  57. public function testNonEmptyDoesNotMatchEmptyString()
  58. {
  59. $this->assertDoesNotMatch(nonEmptyString(), '', 'empty string');
  60. }
  61. public function testNonEmptyMatchesNonEmptyString()
  62. {
  63. $this->assertMatches(nonEmptyString(), 'foo', 'non-empty string');
  64. }
  65. public function testNonEmptyHasAReadableDescription()
  66. {
  67. $this->assertDescription('a non-empty string', nonEmptyString());
  68. }
  69. }