Skip to content

Commit

Permalink
Improved join tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Padam87 committed Dec 6, 2013
1 parent b0fbcc2 commit 09e7104
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Tests/Functional/EntityFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public function testCollectionValuedAssociation()

$qb = $filter->createQueryBuilder('Padam87SearchBundleTest:Company');

$this->assertEquals(1, count($qb->getDQLPart('join')));
$joins = $qb->getDQLPart('join');

$this->assertEquals(1, count($joins));
$this->assertEquals(1, count($joins['c']));
}

public function testCollectionHandling()
Expand Down
32 changes: 31 additions & 1 deletion Tests/Functional/JoinFiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,37 @@ public function testJoinFilters()
$companyFilter->createQueryBuilder('Padam87SearchBundleTest:Company'), 'projects'
);

$joins = $qb->getDQLPart('join');
$join = $joins['c'][0];

$this->assertEquals(2, count($qb->getDQLPart('where')->getParts()));
$this->assertEquals(1, count($joins));
$this->assertEquals(1, count($joins['c']));
$this->assertEquals('INNER', $join->getJoinType());
}

public function testLeftJoinFilters()
{
$company = new Company();
$company->setEmail('[email protected]');
$companyFilter = new EntityFilter($company, 'c');
$companyFilter->setEntityManager(self::$kernel->getContainer()->get('doctrine')->getManager());

$project = new Project();
$project->setName('Test');
$projectFilter = new EntityFilter($project, 'p');
$projectFilter->setEntityManager(self::$kernel->getContainer()->get('doctrine')->getManager());

$qb = $projectFilter->applyToQueryBuilder(
$companyFilter->createQueryBuilder('Padam87SearchBundleTest:Company'), 'projects', 'left'
);

$joins = $qb->getDQLPart('join');
$join = $joins['c'][0];

$this->assertEquals(2, count($qb->getDQLPart('where')->getParts()));
$this->assertEquals(1, count($qb->getDQLPart('join')));
$this->assertEquals(1, count($joins));
$this->assertEquals(1, count($joins['c']));
$this->assertEquals('LEFT', $join->getJoinType());
}
}

0 comments on commit 09e7104

Please sign in to comment.