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