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