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

DriverSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_implements_grid_driver() 0 4 1
A it_throws_exception_if_class_is_undefined() 0 6 1
A it_creates_data_source_via_doctrine_phpcrodm_query_builder() 0 10 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