public function testAddAndResolveMethods()
 {
     $s = new MutableSortingFieldResolver();
     $this->assertNull($s->resolve('foo', 'blah'));
     $s->add('FooEntity', 'fooProperty', 'result-yo');
     $this->assertEquals('result-yo', $s->resolve('FooEntity', 'fooProperty'));
     $this->assertNull($s->resolve('FooEntity', 'barProperty'));
     $s->add('FooEntity', 'barProperty', 'result-yo2');
     $this->assertEquals('result-yo2', $s->resolve('FooEntity', 'barProperty'));
 }
 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);
 }