Completed
Push — master ( de8c12...6bfa1f )
by Portey
05:07
created

UnionResolveTest::dataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 74
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 74
rs 9.0336
cc 1
eloc 25
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
 * Date: 16.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\Tests\Type\Union;
9
10
11
use Youshido\GraphQL\Processor;
12
use Youshido\GraphQL\Validator\ResolveValidator\ResolveValidator;
13
use Youshido\Tests\Type\Union\Schema\Schema;
14
15
class UnionResolveTest extends \PHPUnit_Framework_TestCase
16
{
17
18
    /**
19
     * @param $query
20
     * @param $response
21
     *
22
     * @dataProvider dataProvider
23
     */
24
    public function testResolve($query, $response)
25
    {
26
        $processor = new Processor(new ResolveValidator());
27
        $processor->setSchema(new Schema());
28
29
        $processor->processQuery($query);
30
31
        $this->assertEquals($processor->getResponseData(), $response);
32
    }
33
34
    public function dataProvider()
35
    {
36
        return [
37
            [
38
                '{
39
                    list : unionList {
40
                        name,
41
                        ... on FirstType {
42
                            secondName
43
                        }
44
                    }
45
                }',
46
                [
47
                    'data' => [
48
                        'list' => [
49
                            ['name' => 'object 1'],
50
                            ['name' => 'object 2', 'secondName' => 'object second name 2'],
51
                            ['name' => 'object 3'],
52
                            ['name' => 'object 4', 'secondName' => 'object second name 4']
53
                        ]
54
                    ]
55
                ]
56
            ],
57
            [
58
                '{
59
                    oneUnion {
60
                        name,
61
                        ... on FirstType {
62
                            secondName
63
                        }
64
                    }
65
                }',
66
                [
67
                    'data' => [
68
                        'oneUnion' => [
69
                            'name' => 'object one',
70
                            'secondName' => 'second name'
71
                        ]
72
                    ]
73
                ]
74
            ],
75
            [
76
                '{
77
                    list : unionList {
78
                        name
79
                    }
80
                }',
81
                [
82
                    'data' => [
83
                        'list' => [
84
                            ['name' => 'object 1'],
85
                            ['name' => 'object 2'],
86
                            ['name' => 'object 3'],
87
                            ['name' => 'object 4']
88
                        ]
89
                    ]
90
                ]
91
            ],
92
            [
93
                '{
94
                    oneUnion {
95
                        name
96
                    }
97
                }',
98
                [
99
                    'data' => [
100
                        'oneUnion' => [
101
                            'name' => 'object one'
102
                        ]
103
                    ]
104
                ]
105
            ],
106
        ];
107
    }
108
109
}