No Description

IsArrayContainingInOrderTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Hamcrest\Arrays;
  3. use Hamcrest\AbstractMatcherTest;
  4. class IsArrayContainingInOrderTest extends AbstractMatcherTest
  5. {
  6. protected function createMatcher()
  7. {
  8. return IsArrayContainingInOrder::arrayContaining(array(1, 2));
  9. }
  10. public function testHasAReadableDescription()
  11. {
  12. $this->assertDescription('[<1>, <2>]', arrayContaining(array(1, 2)));
  13. }
  14. public function testMatchesItemsInOrder()
  15. {
  16. $this->assertMatches(arrayContaining(array(1, 2, 3)), array(1, 2, 3), 'in order');
  17. $this->assertMatches(arrayContaining(array(1)), array(1), 'single');
  18. }
  19. public function testAppliesMatchersInOrder()
  20. {
  21. $this->assertMatches(
  22. arrayContaining(array(1, 2, 3)),
  23. array(1, 2, 3),
  24. 'in order'
  25. );
  26. $this->assertMatches(arrayContaining(array(1)), array(1), 'single');
  27. }
  28. public function testMismatchesItemsInAnyOrder()
  29. {
  30. if (defined('HHVM_VERSION')) {
  31. $this->markTestSkipped('Broken on HHVM.');
  32. }
  33. $matcher = arrayContaining(array(1, 2, 3));
  34. $this->assertMismatchDescription('was null', $matcher, null);
  35. $this->assertMismatchDescription('No item matched: <1>', $matcher, array());
  36. $this->assertMismatchDescription('No item matched: <2>', $matcher, array(1));
  37. $this->assertMismatchDescription('item with key 0: was <4>', $matcher, array(4, 3, 2, 1));
  38. $this->assertMismatchDescription('item with key 2: was <4>', $matcher, array(1, 2, 4));
  39. }
  40. }