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 ( 1978d2...e2f699 )
by William
03:55
created

testEmbeddedRelationIsMergedWithCustomRelations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 69
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 69
rs 9.2083
cc 1
eloc 29
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 Hateoas\Tests\Representation;
4
5
use Hateoas\Configuration\Relation;
6
use Hateoas\Configuration\Route;
7
use Hateoas\Representation\CollectionRepresentation;
8
9
class CollectionRepresentationTest extends RepresentationTestCase
10
{
11
    /**
12
     * @dataProvider getTestSerializeData
13
     */
14
    public function testSerialize($resources)
15
    {
16
        $collection = new CollectionRepresentation(
17
            $resources,
18
            'authors'
19
        );
20
        $collection->setXmlElementName('users');
21
22
        $this->assertSame(
23
            <<<XML
24
<?xml version="1.0" encoding="UTF-8"?>
25
<collection>
26
  <users rel="authors">
27
    <entry><![CDATA[Adrien]]></entry>
28
    <entry><![CDATA[William]]></entry>
29
  </users>
30
</collection>
31
32
XML
33
            ,
34
            $this->hateoas->serialize($collection, 'xml')
35
        );
36
        $this->assertSame(
37
            <<<XML
38
<?xml version="1.0" encoding="UTF-8"?>
39
<collection>
40
  <resource rel="authors"><![CDATA[Adrien]]></resource>
41
  <resource rel="authors"><![CDATA[William]]></resource>
42
</collection>
43
44
XML
45
            ,
46
            $this->halHateoas->serialize($collection, 'xml')
47
        );
48
49
        $this->assertSame(
50
            <<<JSON
51
{
52
    "_embedded": {
53
        "authors": [
54
            "Adrien",
55
            "William"
56
        ]
57
    }
58
}
59
JSON
60
            ,
61
            $this->json($this->halHateoas->serialize($collection, 'json'))
62
        );
63
    }
64
65
    public function getTestSerializeData()
66
    {
67
        return array(
68
            array(
69
                array(
70
                    'Adrien',
71
                    'William',
72
                )
73
            ),
74
            array(
75
                new \ArrayIterator(array(
76
                    'Adrien',
77
                    'William',
78
                ))
79
            ),
80
        );
81
    }
82
83
    public function testEmbeddedRelationIsMergedWithCustomRelations()
84
    {
85
        $collection = new CollectionRepresentation(
86
            array(
87
                'Adrien',
88
                'William',
89
            ),
90
            'authors',
91
            null,
92
            null,
93
            null,
94
            array(
95
                new Relation(
96
                    'custom',
97
                    new Route('/custom')
98
                ),
99
            )
100
        );
101
        $collection->setXmlElementName('users');
102
103
        $this->assertSame(
104
            <<<XML
105
<?xml version="1.0" encoding="UTF-8"?>
106
<collection>
107
  <link rel="custom" href="/custom"/>
108
  <users rel="authors">
109
    <entry><![CDATA[Adrien]]></entry>
110
    <entry><![CDATA[William]]></entry>
111
  </users>
112
</collection>
113
114
XML
115
            ,
116
            $this->hateoas->serialize($collection, 'xml')
117
        );
118
        $this->assertSame(
119
            <<<XML
120
<?xml version="1.0" encoding="UTF-8"?>
121
<collection>
122
  <link rel="custom" href="/custom"/>
123
  <resource rel="authors"><![CDATA[Adrien]]></resource>
124
  <resource rel="authors"><![CDATA[William]]></resource>
125
</collection>
126
127
XML
128
            ,
129
            $this->halHateoas->serialize($collection, 'xml')
130
        );
131
132
        $this->assertSame(
133
            <<<JSON
134
{
135
    "_links": {
136
        "custom": {
137
            "href": "\/custom"
138
        }
139
    },
140
    "_embedded": {
141
        "authors": [
142
            "Adrien",
143
            "William"
144
        ]
145
    }
146
}
147
JSON
148
            ,
149
            $this->json($this->halHateoas->serialize($collection, 'json'))
150
        );
151
    }
152
}
153