You are here

public function ClosureExpressionVisitorTest::testSortByFieldAscending in Plug 7

File

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

Class

ClosureExpressionVisitorTest
@group DDC-1637

Namespace

Doctrine\Tests\Common\Collections

Code

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