Completed
Push — master ( f9a038...cc9983 )
by Kamil
22:34
created

DriverSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 37
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_grid_driver() 0 4 1
A it_throws_exception_if_class_is_undefined() 0 7 1
A it_creates_data_source_via_doctrine_phpcrodm_query_builder() 0 11 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
namespace spec\Sylius\Bundle\GridBundle\Doctrine\PHPCRODM;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Component\Grid\Data\DriverInterface;
17
use Sylius\Component\Grid\Parameters;
18
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
19
use Doctrine\ODM\PHPCR\DocumentRepository;
20
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
21
use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\DataSource;
22
23
/**
24
 * @mixin Driver
25
 */
26
class DriverSpec extends ObjectBehavior
27
{
28
    function let(DocumentManagerInterface $documentManager)
29
    {
30
        $this->beConstructedWith($documentManager);
31
    }
32
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType('Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\Driver');
36
    }
37
38
    function it_implements_grid_driver()
39
    {
40
        $this->shouldImplement(DriverInterface::class);
41
    }
42
43
    function it_throws_exception_if_class_is_undefined(Parameters $parameters)
44
    {
45
        $this
46
            ->shouldThrow(\InvalidArgumentException::class)
47
            ->during('getDataSource', [[], $parameters]);
48
        ;
49
    }
50
51
    function it_creates_data_source_via_doctrine_phpcrodm_query_builder(
52
        DocumentManagerInterface $documentManager,
53
        DocumentRepository $documentRepository,
54
        QueryBuilder $queryBuilder,
55
        Parameters $parameters
56
    ) {
57
        $documentManager->getRepository('App:Book')->willReturn($documentRepository);
58
        $documentRepository->createQueryBuilder('o')->willReturn($queryBuilder);
59
        
60
        $this->getDataSource(['class' => 'App:Book'], $parameters)->shouldHaveType(DataSource::class);
61
    }
62
}
63