菜谱项目

IsEmptyStringTest.php 2.2KB

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