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
|
|
|
|