Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
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
17
/**
18
 * Class AbstractArticleOverviewPageRepositoryTest
19
 */
20
class AbstractArticleOverviewPageRepositoryTest extends 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...
21
{
22
    public function testFindActiveOverviewPages()
23
    {
24
        $query = $this->createMock(AbstractQuery::class);
25
        $query->expects($this->once())->method('getResult')->willReturn(['fake', 'data']);
26
27
        $qb = $this->createMock(QueryBuilder::class);
28
        $qb->expects($this->exactly(3))->method('innerJoin')->willReturn($qb);
29
        $qb->expects($this->once())->method('select')->willReturn($qb);
30
        $qb->expects($this->once())->method('from')->willReturn($qb);
31
        $qb->expects($this->once())->method('where')->willReturn($qb);
32
        $qb->expects($this->once())->method('andWhere')->willReturn($qb);
33
        $qb->expects($this->once())->method('setParameter')->willReturn($qb);
34
        $qb->expects($this->once())->method('getQuery')->willReturn($query);
35
36
        $em = $this->createMock(EntityManager::class);
37
        $em->expects($this->once())->method('createQueryBuilder')->willReturn($qb);
38
39
        $entity = new Repo($em, new ClassMetadata(Article::class));
40
41
        $pages = $entity->findActiveOverviewPages();
42
43
        $this->assertCount(2, $pages);
44
    }
45
}
46