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 Sylius\Bundle\GridBundle\Tests\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
17
|
|
|
use Sylius\Bundle\GridBundle\DependencyInjection\SyliusGridExtension; |
18
|
|
|
|
19
|
|
|
final class SyliusGridExtensionTest extends AbstractExtensionTestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @test |
23
|
|
|
*/ |
24
|
|
|
public function it_sets_configured_grids_as_parameter(): void |
25
|
|
|
{ |
26
|
|
|
$this->load([ |
27
|
|
|
'grids' => [ |
28
|
|
|
'sylius_admin_tax_category' => [ |
29
|
|
|
'driver' => [ |
30
|
|
|
'name' => 'doctrine/orm', |
31
|
|
|
'options' => [ |
32
|
|
|
'class' => 'Sylius\Component\Taxation\Model\TaxCategory', |
33
|
|
|
], |
34
|
|
|
], |
35
|
|
|
], |
36
|
|
|
], |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
$this->assertContainerBuilderHasParameter('sylius.grids_definitions', [ |
40
|
|
|
'sylius_admin_tax_category' => [ |
41
|
|
|
'driver' => [ |
42
|
|
|
'name' => 'doctrine/orm', |
43
|
|
|
'options' => [ |
44
|
|
|
'class' => 'Sylius\Component\Taxation\Model\TaxCategory', |
45
|
|
|
], |
46
|
|
|
], |
47
|
|
|
'sorting' => [], |
48
|
|
|
'limits' => [10, 25, 50], |
49
|
|
|
'fields' => [], |
50
|
|
|
'filters' => [], |
51
|
|
|
'actions' => [], |
52
|
|
|
], |
53
|
|
|
]); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @test |
58
|
|
|
*/ |
59
|
|
|
public function it_aliases_default_services(): void |
60
|
|
|
{ |
61
|
|
|
$this->load([]); |
62
|
|
|
|
63
|
|
|
$this->assertContainerBuilderHasAlias('sylius.grid.renderer', 'sylius.grid.renderer.twig'); |
64
|
|
|
$this->assertContainerBuilderHasAlias('sylius.grid.data_extractor', 'sylius.grid.data_extractor.property_access'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @test |
69
|
|
|
*/ |
70
|
|
|
public function it_always_defines_template_parameters(): void |
71
|
|
|
{ |
72
|
|
|
$this->load([]); |
73
|
|
|
|
74
|
|
|
$this->assertContainerBuilderHasParameter('sylius.grid.templates.filter', []); |
75
|
|
|
$this->assertContainerBuilderHasParameter('sylius.grid.templates.action', []); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @test |
80
|
|
|
*/ |
81
|
|
|
public function it_sets_filter_templates_as_parameters(): void |
82
|
|
|
{ |
83
|
|
|
$this->load([ |
84
|
|
|
'templates' => [ |
85
|
|
|
'filter' => [ |
86
|
|
|
'string' => 'AppBundle:Grid/Filter:string.html.twig', |
87
|
|
|
'date' => 'AppBundle:Grid/Filter:date.html.twig', |
88
|
|
|
], |
89
|
|
|
], |
90
|
|
|
]); |
91
|
|
|
|
92
|
|
|
$this->assertContainerBuilderHasParameter('sylius.grid.templates.filter', [ |
93
|
|
|
'string' => 'AppBundle:Grid/Filter:string.html.twig', |
94
|
|
|
'date' => 'AppBundle:Grid/Filter:date.html.twig', |
95
|
|
|
]); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @test |
100
|
|
|
*/ |
101
|
|
|
public function it_sets_action_templates_as_parameters(): void |
102
|
|
|
{ |
103
|
|
|
$this->load([ |
104
|
|
|
'templates' => [ |
105
|
|
|
'action' => [ |
106
|
|
|
'create' => 'AppBundle:Grid/Filter:create.html.twig', |
107
|
|
|
'update' => 'AppBundle:Grid/Filter:update.html.twig', |
108
|
|
|
], |
109
|
|
|
], |
110
|
|
|
]); |
111
|
|
|
|
112
|
|
|
$this->assertContainerBuilderHasParameter('sylius.grid.templates.action', [ |
113
|
|
|
'create' => 'AppBundle:Grid/Filter:create.html.twig', |
114
|
|
|
'update' => 'AppBundle:Grid/Filter:update.html.twig', |
115
|
|
|
]); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
|
|
protected function getContainerExtensions(): array |
122
|
|
|
{ |
123
|
|
|
return [ |
124
|
|
|
new SyliusGridExtension(), |
125
|
|
|
]; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|