You are here

public function ArrayCollectionTest::testMatchingWithSortingPreservesyKeys in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php \Doctrine\Tests\Common\Collections\ArrayCollectionTest::testMatchingWithSortingPreservesyKeys()

File

vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php, line 273

Class

ArrayCollectionTest
Tests for { @covers \Doctrine\Common\Collections\ArrayCollection

Namespace

Doctrine\Tests\Common\Collections

Code

public function testMatchingWithSortingPreservesyKeys() {
  $object1 = new \stdClass();
  $object2 = new \stdClass();
  $object1->sortField = 2;
  $object2->sortField = 1;
  $collection = new ArrayCollection(array(
    'object1' => $object1,
    'object2' => $object2,
  ));
  $this
    ->assertSame(array(
    'object2' => $object2,
    'object1' => $object1,
  ), $collection
    ->matching(new Criteria(null, array(
    'sortField' => Criteria::ASC,
  )))
    ->toArray());
}