GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f05462...3060fd )
by Craig
02:44
created

CollectionLayoutTest::testChildrenHorizontal()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 81
Code Lines 12

Duplication

Lines 81
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 81
loc 81
rs 8.8076
cc 1
eloc 12
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Mopa\Bundle\BootstrapBundle\Tests\Form;
4
5
class CollectionLayoutTest extends AbstractDivLayoutTest
6
{
7
    /**
8
     * Should be all horizontal by default including children
9
     */
10
    public function testDefaultCollection()
11
    {
12
        $view = $this->factory->createNamedBuilder('name', $this->getFormType('form'), array(
13
            'names' => array('name1', 'name2', 'name3'),
14
        ))
15
            ->add('names', $this->getFormType('collection'), array(
16
                $this->getCollectionTypeKey() => $this->getFormType('text'),
17
            ))
18
            ->getForm()
19
            ->createView()
20
        ;
21
22
        $html = $this->renderWidget($view);
23
        $this->assertMatchesXpath($this->removeBreaks($html),
24
'
25
/fieldset
26
    [
27
        ./div[@class="form-group"]
28
        [
29
            ./div[@class="col-sm-9"]
30
            [
31
                ./div[@class="form-group collection-items name_names_form_group"]
32
                [
33
                    (
34
                        ./div[@class="collection-item"]
35
                        [
36
                            (
37
                                ./label[@class="control-label col-sm-3 required"]
38
                            )
39
                            and
40
                            (
41
                                ./div[@class="col-sm-9"]
42
                                [
43
                                    ./input[@value="name1"]
44
                                ]
45
                            )
46
                        ]
47
                    )
48
49
                    and
50
51
                    (
52
                        ./div[@class="collection-item"]
53
                        [
54
                            (
55
                                ./label[@class="control-label col-sm-3 required"]
56
                            )
57
                            and
58
                            (
59
                                ./div[@class="col-sm-9"]
60
                                [
61
                                    ./input[@value="name2"]
62
                                ]
63
                            )
64
                        ]
65
                    )
66
67
                    and
68
69
                    (
70
                        ./div[@class="collection-item"]
71
                        [
72
                            (
73
                                ./label[@class="control-label col-sm-3 required"]
74
                            )
75
                            and
76
                            (
77
                                ./div[@class="col-sm-9"]
78
                                [
79
                                    ./input[@value="name3"]
80
                                ]
81
                            )
82
                        ]
83
                    )
84
                ]
85
            ]
86
        ]
87
    ]
88
'
89
        );
90
    }
91
92
    /**
93
     * Parent should be horizontal but all children in the collection should be inline
94
     */
95 View Code Duplication
    public function testChildrenNotHorizontal()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
    {
97
        $view = $this->factory->createNamedBuilder('name', $this->getFormType('form'), array(
98
            'names' => array('name1', 'name2', 'name3'),
99
        ))
100
            ->add('names', $this->getFormType('collection'), array(
101
                $this->getCollectionTypeKey() => $this->getFormType('text'),
102
                $this->getCollectionOptionsKey() => array('horizontal' => false),
103
            ))
104
            ->getForm()
105
            ->createView()
106
        ;
107
108
        $html = $this->renderWidget($view);
109
        $this->assertMatchesXpath($this->removeBreaks($html),
110
'
111
/fieldset
112
    [
113
        ./div[@class="form-group"]
114
        [
115
            ./div[@class="col-sm-9"]
116
            [
117
                ./div[@class="form-group collection-items name_names_form_group"]
118
                [
119
                    (
120
                        ./div[@class="collection-item"]
121
                        [
122
                            (
123
                                ./label[@class="required"]
124
                            )
125
                            and
126
                            (
127
                                ./input[@value="name1"]
128
                            )
129
                        ]
130
                    )
131
132
                    and
133
134
                    (
135
                        ./div[@class="collection-item"]
136
                        [
137
                            (
138
                                ./label[@class="required"]
139
                            )
140
                            and
141
                            (
142
                                ./input[@value="name2"]
143
                            )
144
                        ]
145
                    )
146
147
                    and
148
149
                    (
150
                        ./div[@class="collection-item"]
151
                        [
152
                            (
153
                                ./label[@class="required"]
154
                            )
155
                            and
156
                            (
157
                                ./input[@value="name3"]
158
                            )
159
                        ]
160
                    )
161
                ]
162
            ]
163
        ]
164
    ]
165
'
166
        );
167
    }
168
169
    /**
170
     * Parent should be inline but children are horizontal
171
     */
172 View Code Duplication
    public function testChildrenHorizontal()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
173
    {
174
        $view = $this->factory->createNamedBuilder('name', $this->getFormType('form'), array(
175
            'names' => array('name1', 'name2', 'name3'),
176
        ))
177
            ->add('names', $this->getFormType('collection'), array(
178
                $this->getCollectionTypeKey() => $this->getFormType('text'),
179
                $this->getCollectionOptionsKey() => array('horizontal' => true),
180
                'horizontal' => false,
181
            ))
182
            ->getForm()
183
            ->createView()
184
        ;
185
186
        $html = $this->renderWidget($view);
187
        $this->assertMatchesXpath($this->removeBreaks($html),
188
'
189
/fieldset
190
    [
191
        ./div[@class="form-group"]
192
        [
193
194
            ./div[@class="form-group collection-items name_names_form_group"]
195
            [
196
                (
197
                    ./div[@class="collection-item"]
198
                    [
199
                        (
200
                            ./label[@class="control-label col-sm-3 required"]
201
                        )
202
                        and
203
                        (
204
                            ./div[@class="col-sm-9"]
205
                            [
206
                                ./input[@value="name1"]
207
                            ]
208
                        )
209
                    ]
210
                )
211
212
                and
213
214
                (
215
                    ./div[@class="collection-item"]
216
                    [
217
                        (
218
                            ./label[@class="control-label col-sm-3 required"]
219
                        )
220
                        and
221
                        (
222
                            ./div[@class="col-sm-9"]
223
                            [
224
                                ./input[@value="name2"]
225
                            ]
226
                        )
227
                    ]
228
                )
229
230
                and
231
232
                (
233
                    ./div[@class="collection-item"]
234
                    [
235
                        (
236
                            ./label[@class="control-label col-sm-3 required"]
237
                        )
238
                        and
239
                        (
240
                            ./div[@class="col-sm-9"]
241
                            [
242
                                ./input[@value="name3"]
243
                            ]
244
                        )
245
                    ]
246
                )
247
            ]
248
        ]
249
    ]
250
'
251
        );
252
    }
253
254
    /**
255
     * Everything should be inline
256
     */
257 View Code Duplication
    public function testAllNotHorizontal()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
258
    {
259
        $view = $this->factory->createNamedBuilder('name', $this->getFormType('form'), array(
260
            'names' => array('name1', 'name2', 'name3'),
261
        ))
262
            ->add('names', $this->getFormType('collection'), array(
263
                $this->getCollectionTypeKey() => $this->getFormType('text'),
264
                'horizontal' => false,
265
            ))
266
            ->getForm()
267
            ->createView()
268
        ;
269
270
        $html = $this->renderWidget($view);
271
        $this->assertMatchesXpath($this->removeBreaks($html),
272
'
273
/fieldset
274
    [
275
        ./div[@class="form-group"]
276
        [
277
            ./div[@class="form-group collection-items name_names_form_group"]
278
            [
279
                (
280
                    ./div[@class="collection-item"]
281
                    [
282
                        (
283
                            ./label[@class="required"]
284
                        )
285
                        and
286
                        (
287
                            ./input[@value="name1"]
288
                        )
289
                    ]
290
                )
291
292
                and
293
294
                (
295
                    ./div[@class="collection-item"]
296
                    [
297
                        (
298
                            ./label[@class="required"]
299
                        )
300
                        and
301
                        (
302
                            ./input[@value="name2"]
303
                        )
304
                    ]
305
                )
306
307
                and
308
309
                (
310
                    ./div[@class="collection-item"]
311
                    [
312
                        (
313
                            ./label[@class="required"]
314
                        )
315
                        and
316
                        (
317
                            ./input[@value="name3"]
318
                        )
319
                    ]
320
                )
321
            ]
322
        ]
323
    ]
324
'
325
        );
326
    }
327
}