Completed
Pull Request — master (#2101)
by Kevin
18:19
created

AbstractArticleOverviewPageRepositoryTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\ArticleBundle\Tests\Repository;
4
5
use Doctrine\ORM\AbstractQuery;
6
use Doctrine\ORM\EntityManager;
7
use Doctrine\ORM\Mapping\ClassMetadata;
8
use Doctrine\ORM\QueryBuilder;
9
use Kunstmaan\ArticleBundle\Repository\AbstractArticleOverviewPageRepository;
10
use PHPUnit_Framework_TestCase;
11
use Tests\DoctrineExtensions\Taggable\Fixtures\Article;
12
13
class Repo extends AbstractArticleOverviewPageRepository {}
14
15
/**
16
 * Class AbstractArticleOverviewPageRepositoryTest
17
 * @package Tests\Kunstmaan\ArticleBundle\Repository
18
 */
19
class AbstractArticleOverviewPageRepositoryTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
20
{
21
    public function testFindActiveOverviewPages()
22
    {
23
        $query = $this->createMock(AbstractQuery::class);
24
        $query->expects($this->once())->method('getResult')->willReturn(['fake', 'data']);
25
26
        $qb = $this->createMock(QueryBuilder::class);
27
        $qb->expects($this->exactly(3))->method('innerJoin')->willReturn($qb);
28
        $qb->expects($this->once())->method('select')->willReturn($qb);
29
        $qb->expects($this->once())->method('from')->willReturn($qb);
30
        $qb->expects($this->once())->method('where')->willReturn($qb);
31
        $qb->expects($this->once())->method('andWhere')->willReturn($qb);
32
        $qb->expects($this->once())->method('setParameter')->willReturn($qb);
33
        $qb->expects($this->once())->method('getQuery')->willReturn($query);
34
35
        $em = $this->createMock(EntityManager::class);
36
        $em->expects($this->once())->method('createQueryBuilder')->willReturn($qb);
37
38
        $entity = new Repo($em, new ClassMetadata(Article::class));
39
40
        $pages = $entity->findActiveOverviewPages();
41
42
        $this->assertCount(2, $pages);
43
    }
44
}
45