Total Complexity | 2 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | class FragmentTest extends TestCase |
||
10 | { |
||
11 | /** |
||
12 | * Tests adding fields and args using constructor parameters or method call. |
||
13 | */ |
||
14 | public function testAddFields() |
||
15 | { |
||
16 | $fragment1 = Fragment::create('articleFragment', 'article', [ |
||
17 | 'id', |
||
18 | 'title', |
||
19 | 'image' => Query::create()->fields([ |
||
20 | 'width', |
||
21 | 'height', |
||
22 | 'filename', |
||
23 | 'size', |
||
24 | ]), |
||
25 | ]); |
||
26 | |||
27 | $fragment2 = Fragment::create('articleFragment', 'article')->fields([ |
||
28 | 'id', |
||
29 | 'title', |
||
30 | 'image' => Query::create()->fields([ |
||
31 | 'width', |
||
32 | 'height', |
||
33 | 'filename', |
||
34 | 'size', |
||
35 | ]), |
||
36 | ]); |
||
37 | |||
38 | $expected = |
||
39 | 'fragment articleFragment on article { |
||
40 | id |
||
41 | image { |
||
42 | filename |
||
43 | height |
||
44 | size |
||
45 | width |
||
46 | } |
||
47 | title |
||
48 | } |
||
49 | '; |
||
50 | $this->assertEquals($expected, (string) $fragment1); |
||
51 | $this->assertEquals($expected, (string) $fragment2); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Tests the order of fields. |
||
56 | */ |
||
57 | public function testSortFields() |
||
72 | } |
||
73 | } |
||
74 |