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.

77 lines
1.8 KiB

3 years ago
  1. <?php
  2. namespace Hamcrest\Collection;
  3. use Hamcrest\AbstractMatcherTest;
  4. class IsEmptyTraversableTest extends AbstractMatcherTest
  5. {
  6. protected function createMatcher()
  7. {
  8. return IsEmptyTraversable::emptyTraversable();
  9. }
  10. public function testEmptyMatcherMatchesWhenEmpty()
  11. {
  12. $this->assertMatches(
  13. emptyTraversable(),
  14. new \ArrayObject(array()),
  15. 'an empty traversable'
  16. );
  17. }
  18. public function testEmptyMatcherDoesNotMatchWhenNotEmpty()
  19. {
  20. $this->assertDoesNotMatch(
  21. emptyTraversable(),
  22. new \ArrayObject(array(1, 2, 3)),
  23. 'a non-empty traversable'
  24. );
  25. }
  26. public function testEmptyMatcherDoesNotMatchNull()
  27. {
  28. $this->assertDoesNotMatch(
  29. emptyTraversable(),
  30. null,
  31. 'should not match null'
  32. );
  33. }
  34. public function testEmptyMatcherHasAReadableDescription()
  35. {
  36. $this->assertDescription('an empty traversable', emptyTraversable());
  37. }
  38. public function testNonEmptyDoesNotMatchNull()
  39. {
  40. $this->assertDoesNotMatch(
  41. nonEmptyTraversable(),
  42. null,
  43. 'should not match null'
  44. );
  45. }
  46. public function testNonEmptyDoesNotMatchWhenEmpty()
  47. {
  48. $this->assertDoesNotMatch(
  49. nonEmptyTraversable(),
  50. new \ArrayObject(array()),
  51. 'an empty traversable'
  52. );
  53. }
  54. public function testNonEmptyMatchesWhenNotEmpty()
  55. {
  56. $this->assertMatches(
  57. nonEmptyTraversable(),
  58. new \ArrayObject(array(1, 2, 3)),
  59. 'a non-empty traversable'
  60. );
  61. }
  62. public function testNonEmptyNonEmptyMatcherHasAReadableDescription()
  63. {
  64. $this->assertDescription('a non-empty traversable', nonEmptyTraversable());
  65. }
  66. }