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));
 }
 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 function testGetMapping()
 {
     $addressMapping = $this->exprMgr->getMapping('address');
     $addressCountry = $this->exprMgr->getMapping('address.country');
     $addressZip = $this->exprMgr->getMapping('address.zip');
     $firstname = $this->exprMgr->getMapping('firstname');
     $this->assertNotNull($addressMapping);
     $this->assertTrue(is_array($addressMapping));
     $this->assertArrayHasKey('targetEntity', $addressMapping);
     $this->assertEquals(DummyAddress::clazz(), $addressMapping['targetEntity']);
     $this->assertNotNull($addressCountry);
     $this->assertTrue(is_array($addressCountry));
     $this->assertArrayHasKey('targetEntity', $addressCountry);
     $this->assertEquals(DummyCountry::clazz(), $addressCountry['targetEntity']);
     $this->assertNotNull($addressZip);
     $this->assertTrue(is_array($addressZip));
     $this->assertArrayHasKey('fieldName', $addressZip);
     $this->assertEquals('zip', $addressZip['fieldName']);
     $this->assertNotNull($firstname);
     $this->assertTrue(is_array($firstname));
     $this->assertArrayHasKey('fieldName', $firstname);
     $this->assertEquals('firstname', $firstname['fieldName']);
 }