public function testBuildQueryOrderByNestedAssociation()
 {
     $resolver = new MutableSortingFieldResolver();
     $resolver->add(DummyOrder::clazz(), 'user', 'address');
     $resolver->add(DummyUser::clazz(), 'address', 'country');
     $resolver->add(DummyAddress::clazz(), 'country', 'name');
     $qb = self::$builder->buildQueryBuilder(DummyOrder::clazz(), array('sort' => array(array('property' => 'user', 'direction' => 'DESC'))), $resolver);
     $this->assertEquals(4, count($qb->getDQLPart('join'), \COUNT_RECURSIVE));
     // there must be three joins
     /* @var DummyOrder[] $result */
     $result = $qb->getQuery()->getResult();
     $this->assertEquals(2, count($result));
     $this->assertEquals('ORDER-2', $result[0]->number);
     $this->assertEquals('ORDER-1', $result[1]->number);
 }
 public static function tearDownAfterClass()
 {
     $orderUserMetadata = self::$em->getClassMetadata(DummyOrder::clazz());
     $dummyUserMetadata = self::$em->getClassMetadata(DummyUser::clazz());
     $dummyAddressMetadata = self::$em->getClassMetadata(DummyAddress::clazz());
     $dummyCountryMetadata = self::$em->getClassMetadata(DummyCountry::clazz());
     $dummyCCMetadata = self::$em->getClassMetadata(CreditCard::clazz());
     $groupMetadata = self::$em->getClassMetadata(Group::clazz());
     $presidentMetadata = self::$em->getClassMetadata(President::clazz());
     $st = new SchemaTool(self::$em);
     $st->dropSchema(array($orderUserMetadata, $dummyUserMetadata, $dummyAddressMetadata, $dummyCountryMetadata, $dummyCCMetadata, $groupMetadata, $presidentMetadata));
 }