parametersProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 75
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 9
c 0
b 0
f 0
cc 1
eloc 40
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 Stp\SndApi\News\Test\Validator;
4
5
use Stp\SndApi\News\Validator\ArticlesListParametersValidator;
6
7
class ArticlesListParametersValidatorTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function parametersProvider()
10
    {
11
        return [
12
            [
13
                'desked',
14
                [
15
                    'areaLimit' => 1
16
                ],
17
                true
18
            ],
19
            [
20
                'desked',
21
                [
22
                    'invalid' => 'true'
23
                ],
24
                false
25
            ],
26
            [
27
                'auto',
28
                [
29
                    'offset' => 20,
30
                    'limit' => 20
31
                ],
32
                true
33
            ],
34
            [
35
                'auto',
36
                [
37
                    'offset' => 20,
38
                    'limit' => 20,
39
                    'invalid' => 'true'
40
                ],
41
                false
42
            ],
43
            [
44
                'auto',
45
                [
46
                    'offset' => 20,
47
                    'limit' => 20,
48
                    'includeSubsections' => 'true'
49
                ],
50
                true
51
            ],
52
            [
53
                'auto',
54
                [
55
                    'offset' => 20,
56
                    'limit' => 20,
57
                    'includeSubsections' => 'true',
58
                    'homeSectionOnly' => 'true'
59
                ],
60
                true
61
            ],
62
            [
63
                'auto',
64
                [
65
                    'offset' => 20,
66
                    'limit' => 20,
67
                    'includeSubsections' => 'true',
68
                    'invalid' => 'true'
69
                ],
70
                false
71
            ],
72
            [
73
                'auto',
74
                [
75
                    'offset' => 20,
76
                    'limit' => 20,
77
                    'invalid' => 'true',
78
                    'homeSectionOnly' => 'true'
79
                ],
80
                false
81
            ]
82
        ];
83
    }
84
85
    /**
86
     * @dataProvider parametersProvider
87
     */
88
    public function testValidator($method, $parameters, $expected)
89
    {
90
        $validator = new ArticlesListParametersValidator($method, $parameters);
91
        $this->assertEquals($expected, $validator->isValid());
92
    }
93
}
94