Completed
Push — reproduce-taxon-autocompletion ( 8c649e )
by Kamil
22:05
created

it_sets_configured_grids_as_parameter()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

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