You are here

public function ClosureExpressionVisitorTest::testSortDelegate in Plug 7

File

lib/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php, line 192

Class

ClosureExpressionVisitorTest
@group DDC-1637

Namespace

Doctrine\Tests\Common\Collections

Code

public function testSortDelegate() {
  $objects = array(
    new TestObject("a", "c"),
    new TestObject("a", "b"),
    new TestObject("a", "a"),
  );
  $sort = ClosureExpressionVisitor::sortByField("bar", 1);
  $sort = ClosureExpressionVisitor::sortByField("foo", 1, $sort);
  usort($objects, $sort);
  $this
    ->assertEquals("a", $objects[0]
    ->getBar());
  $this
    ->assertEquals("b", $objects[1]
    ->getBar());
  $this
    ->assertEquals("c", $objects[2]
    ->getBar());
}