Code Duplication    Length = 40-40 lines in 2 locations

eZ/Publish/Core/REST/Server/Tests/Output/ValueObjectVisitor/ResourceLinkTest.php 2 locations

@@ 116-155 (lines=40) @@
113
    /**
114
     * @dataProvider buildValueObject
115
     */
116
    public function testVisitUnauthorizedException(ResourceLinkValue $resourceLink)
117
    {
118
        $visitor = $this->getVisitor();
119
        $generator = $this->getGenerator();
120
121
        $generator->startDocument(null);
122
        $generator->startObjectElement('SomeRoot');
123
        $generator->startObjectElement('SomeObject');
124
125
        $this->getPathExpansionCheckerMock()
126
            ->expects($this->once())
127
            ->method('needsExpansion')
128
            ->with('SomeRoot.SomeObject')
129
            ->will($this->returnValue(true));
130
131
        $this->getValueLoaderMock()
132
            ->expects($this->once())
133
            ->method('load')
134
            ->will($this->throwException(new UnauthorizedException('something', 'load')));
135
136
        $this->getValueObjectVisitorDispatcherMock()
137
            ->expects($this->never())
138
            ->method('visit');
139
140
        $visitor->visit($this->getVisitorMock(), $generator, $resourceLink);
141
142
        $generator->endObjectElement('SomeObject');
143
        $generator->endObjectElement('SomeRoot');
144
145
        $result = $generator->endDocument(null);
146
147
        $this->assertNotNull($result);
148
149
        $dom = new \DOMDocument();
150
        $dom->loadXml($result);
151
152
        $this->assertXPath($dom, '//SomeObject[@href="' . $resourceLink->link . '"]');
153
        $this->assertXPath($dom, '//SomeObject[@media-type="application/vnd.ez.api.SomeObject+xml"]');
154
        $this->assertXPath($dom, '//SomeObject[@embed-error="User does not have access to \'load\' \'something\'"]');
155
    }
156
157
    /**
158
     * @dataProvider buildValueObject
@@ 160-199 (lines=40) @@
157
    /**
158
     * @dataProvider buildValueObject
159
     */
160
    public function testVisitMultipleLoadException(ResourceLinkValue $resourceLink)
161
    {
162
        $visitor = $this->getVisitor();
163
        $generator = $this->getGenerator();
164
165
        $generator->startDocument(null);
166
        $generator->startObjectElement('SomeRoot');
167
        $generator->startObjectElement('SomeObject');
168
169
        $this->getPathExpansionCheckerMock()
170
            ->expects($this->once())
171
            ->method('needsExpansion')
172
            ->with('SomeRoot.SomeObject')
173
            ->will($this->returnValue(true));
174
175
        $this->getValueLoaderMock()
176
            ->expects($this->once())
177
            ->method('load')
178
            ->will($this->throwException(new MultipleValueLoadException()));
179
180
        $this->getValueObjectVisitorDispatcherMock()
181
            ->expects($this->never())
182
            ->method('visit');
183
184
        $visitor->visit($this->getVisitorMock(), $generator, $resourceLink);
185
186
        $generator->endObjectElement('SomeObject');
187
        $generator->endObjectElement('SomeRoot');
188
189
        $result = $generator->endDocument(null);
190
191
        $this->assertNotNull($result);
192
193
        $dom = new \DOMDocument();
194
        $dom->loadXml($result);
195
196
        $this->assertXPath($dom, '//SomeObject[@href="' . $resourceLink->link . '"]');
197
        $this->assertXPath($dom, '//SomeObject[@media-type="application/vnd.ez.api.SomeObject+xml"]');
198
        $this->assertXPath($dom, '//SomeObject[@embed-error="Value was already loaded"]');
199
    }
200
201
    public function testVisitCircularLoadException()
202
    {