Completed
Push — 1.1-coding-standard-fixes-2 ( e2da86 )
by Kamil
38:16 queued 10:43
created

DriverSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\GridBundle\Doctrine\PHPCRODM;
15
16
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
17
use Doctrine\ODM\PHPCR\DocumentRepository;
18
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
19
use PhpSpec\ObjectBehavior;
20
use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\DataSource;
21
use Sylius\Component\Grid\Data\DriverInterface;
22
use Sylius\Component\Grid\Parameters;
23
24
/**
25
 * @require Doctrine\ODM\PHPCR\DocumentManagerInterface
26
 */
27
final class DriverSpec extends ObjectBehavior
28
{
29
    function let(DocumentManagerInterface $documentManager): void
30
    {
31
        $this->beConstructedWith($documentManager);
32
    }
33
34
    function it_implements_grid_driver(): void
35
    {
36
        $this->shouldImplement(DriverInterface::class);
37
    }
38
39
    function it_throws_exception_if_class_is_undefined(): void
40
    {
41
        $this
42
            ->shouldThrow(\InvalidArgumentException::class)
43
            ->during('getDataSource', [[], new Parameters()]);
44
    }
45
46
    function it_creates_data_source_via_doctrine_phpcrodm_query_builder(
47
        DocumentManagerInterface $documentManager,
48
        DocumentRepository $documentRepository,
49
        QueryBuilder $queryBuilder
50
    ): void {
51
        $documentManager->getRepository('App:Book')->willReturn($documentRepository);
52
        $documentRepository->createQueryBuilder('o')->willReturn($queryBuilder);
53
54
        $this->getDataSource(['class' => 'App:Book'], new Parameters())->shouldHaveType(DataSource::class);
55
    }
56
}
57