Completed
Push — EZP-29891 ( 916cf6...0402ff )
by
unknown
16:53
created

ContentHandlerTest   B

Complexity

Total Complexity 50

Size/Duplication

Total Lines 1591
Duplicated Lines 7.92 %

Coupling/Cohesion

Components 1
Dependencies 14

Importance

Changes 0
Metric Value
dl 126
loc 1591
rs 7.2
c 0
b 0
f 0
wmc 50
lcom 1
cbo 14

40 Methods

Rating   Name   Duplication   Size   Complexity  
A testCtor() 21 21 1
B testCreate() 0 94 1
B testPublishFirstVersion() 0 68 1
B testPublish() 0 74 1
B testCreateDraftFromVersion() 0 87 1
A testLoad() 0 44 1
A testLoadContentInfoByRemoteId() 21 21 1
A testLoadErrorNotFound() 14 14 1
A getContentFixtureForDraft() 0 15 1
B testUpdateContent() 0 97 1
A testUpdateMetadata() 0 34 1
B testUpdateMetadataUpdatesPathIdentificationString() 0 63 1
A testLoadRelations() 0 29 1
A testLoadReverseRelations() 0 28 1
A testAddRelation() 0 43 1
A testRemoveRelation() 0 10 1
A getRelationFixture() 0 9 1
A getCreateStructFixture() 0 28 1
A testLoadDraftsForUser() 0 30 1
A testListVersions() 0 19 1
A testRemoveRawContent() 0 12 1
A testDeleteContentWithLocations() 0 21 1
A testDeleteContentWithoutLocations() 0 15 1
B testDeleteVersion() 0 59 1
B testCopySingleVersion() 0 60 1
B testCopyAllVersions() 0 151 1
A testCopyThrowsNotFoundExceptionContentNotFound() 0 15 1
A testCopyThrowsNotFoundExceptionVersionNotFound() 12 12 1
A testSetStatus() 16 16 1
A getContentHandler() 0 17 2
A getPartlyMockedHandler() 0 19 1
A getTreeHandlerMock() 0 14 2
A getContentTypeHandlerMock() 14 14 2
A getFieldHandlerMock() 14 14 2
A getMapperMock() 14 14 2
A getLocationGatewayMock() 0 10 2
A getTypeGatewayMock() 0 10 2
A getGatewayMock() 0 10 2
A getSlugConverterMock() 0 14 2
A getUrlAliasGatewayMock() 0 10 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like ContentHandlerTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ContentHandlerTest, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * File contains: eZ\Publish\Core\Persistence\Legacy\Tests\Content\ContentHandlerTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Persistence\Legacy\Tests\Content;
10
11
use eZ\Publish\Core\Persistence\Legacy\Tests\TestCase;
12
use eZ\Publish\SPI\Persistence\Content;
13
use eZ\Publish\SPI\Persistence\Content\ContentInfo;
14
use eZ\Publish\SPI\Persistence\Content\Field;
15
use eZ\Publish\SPI\Persistence\Content\FieldValue;
16
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
17
use eZ\Publish\SPI\Persistence\Content\CreateStruct;
18
use eZ\Publish\SPI\Persistence\Content\UpdateStruct;
19
use eZ\Publish\SPI\Persistence\Content\Relation;
20
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct;
21
use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct as LocationCreateStruct;
22
use eZ\Publish\Core\Persistence\Legacy\Content\Handler;
23
use eZ\Publish\API\Repository\Values\Content\Relation as RelationValue;
24
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct;
25
use eZ\Publish\Core\Base\Exceptions\NotFoundException;
26
27
/**
28
 * Test case for Content Handler.
29
 */
30
class ContentHandlerTest extends TestCase
31
{
32
    /**
33
     * Content handler to test.
34
     *
35
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Handler
36
     */
37
    protected $contentHandler;
38
39
    /**
40
     * Gateway mock.
41
     *
42
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway
43
     */
44
    protected $gatewayMock;
45
46
    /**
47
     * Location gateway mock.
48
     *
49
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
50
     */
51
    protected $locationGatewayMock;
52
53
    /**
54
     * Type gateway mock.
55
     *
56
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Type\Gateway
57
     */
58
    protected $typeGatewayMock;
59
60
    /**
61
     * Mapper mock.
62
     *
63
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Mapper
64
     */
65
    protected $mapperMock;
66
67
    /**
68
     * Field handler mock.
69
     *
70
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler
71
     */
72
    protected $fieldHandlerMock;
73
74
    /**
75
     * Location handler mock.
76
     *
77
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\TreeHandler
78
     */
79
    protected $treeHandlerMock;
80
81
    /**
82
     * Slug converter mock.
83
     *
84
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter
85
     */
86
    protected $slugConverterMock;
87
88
    /**
89
     * Location handler mock.
90
     *
91
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway
92
     */
93
    protected $urlAliasGatewayMock;
94
95
    /**
96
     * ContentType handler mock.
97
     *
98
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler
99
     */
100
    protected $contentTypeHandlerMock;
101
102
    /**
103
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::__construct
104
     */
105 View Code Duplication
    public function testCtor()
106
    {
107
        $handler = $this->getContentHandler();
108
109
        $this->assertAttributeSame(
110
            $this->getGatewayMock(),
111
            'contentGateway',
112
            $handler
113
        );
114
        $this->assertAttributeSame(
115
            $this->getMapperMock(),
116
            'mapper',
117
            $handler
118
        );
119
        $this->assertAttributeSame(
120
            $this->getFieldHandlerMock(),
121
            'fieldHandler',
122
            $handler
123
        );
124
        // @todo Assert missing properties
125
    }
126
127
    /**
128
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::create
129
     *
130
     * @todo Current method way to complex to test, refactor!
131
     */
132
    public function testCreate()
133
    {
134
        $handler = $this->getContentHandler();
135
136
        $mapperMock = $this->getMapperMock();
137
        $gatewayMock = $this->getGatewayMock();
138
        $fieldHandlerMock = $this->getFieldHandlerMock();
139
        $locationMock = $this->getLocationGatewayMock();
140
        $contentTypeHandlerMock = $this->getContentTypeHandlerMock();
141
        $contentTypeMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type');
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
142
        $createStruct = $this->getCreateStructFixture();
143
144
        $contentTypeHandlerMock->expects($this->once())
145
            ->method('load')
146
            ->with($createStruct->typeId)
147
            ->will($this->returnValue($contentTypeMock));
148
149
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
            ->method('createVersionInfoFromCreateStruct')
151
            ->with(
152
                $this->isInstanceOf(
153
                    'eZ\\Publish\\SPI\\Persistence\\Content\\CreateStruct'
154
                )
155
            )->will(
156
                $this->returnValue(
157
                    new VersionInfo(
158
                        array(
159
                            'names' => array(),
160
                            'contentInfo' => new ContentInfo(),
161
                        )
162
                    )
163
                )
164
            );
165
166
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
167
            ->method('insertContentObject')
168
            ->with(
169
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\CreateStruct')
170
            )->will($this->returnValue(23));
171
172
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
173
            ->method('insertVersion')
174
            ->with(
175
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo'),
176
                $this->isType('array')
177
            )->will($this->returnValue(1));
178
179
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
180
            ->method('createNewFields')
181
            ->with(
182
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'),
183
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type')
184
            );
185
186
        $locationMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
187
            ->method('createNodeAssignment')
188
            ->with(
189
                $this->isInstanceOf(
190
                    'eZ\\Publish\\SPI\\Persistence\\Content\\Location\\CreateStruct'
191
                ),
192
                $this->equalTo(42),
193
                $this->equalTo(3) // Location\Gateway::NODE_ASSIGNMENT_OP_CODE_CREATE
194
            );
195
196
        $res = $handler->create($createStruct);
197
198
        // @todo Make subsequent tests
199
200
        $this->assertInstanceOf(
201
            'eZ\\Publish\\SPI\\Persistence\\Content',
202
            $res,
203
            'Content not created'
204
        );
205
        $this->assertEquals(
206
            23,
207
            $res->versionInfo->contentInfo->id,
208
            'Content ID not set correctly'
209
        );
210
        $this->assertInstanceOf(
211
            '\\eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo',
212
            $res->versionInfo,
213
            'Version infos not created'
214
        );
215
        $this->assertEquals(
216
            1,
217
            $res->versionInfo->id,
218
            'Version ID not set correctly'
219
        );
220
        $this->assertEquals(
221
            2,
222
            count($res->fields),
223
            'Fields not set correctly in version'
224
        );
225
    }
226
227
    /**
228
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::publish
229
     */
230
    public function testPublishFirstVersion()
231
    {
232
        $handler = $this->getPartlyMockedHandler(array('loadVersionInfo', 'setStatus'));
233
234
        $gatewayMock = $this->getGatewayMock();
235
        $mapperMock = $this->getMapperMock();
236
        $locationMock = $this->getLocationGatewayMock();
237
        $fieldHandlerMock = $this->getFieldHandlerMock();
238
        $metadataUpdateStruct = new MetadataUpdateStruct();
239
240
        $handler->expects($this->at(0))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
241
            ->method('loadVersionInfo')
242
            ->with(23, 1)
243
            ->will(
244
                $this->returnValue(
245
                    new VersionInfo(array('contentInfo' => new ContentInfo(array('currentVersionNo' => 1))))
246
                )
247
            );
248
249
        $contentRows = [['ezcontentobject_version_version' => 1]];
250
251
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
252
            ->method('load')
253
            ->with(
254
                $this->equalTo(23),
255
                $this->equalTo(1),
256
                $this->equalTo(null)
257
            )->willReturn($contentRows);
258
259
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
260
            ->method('loadVersionedNameData')
261
            ->with(
262
                $this->equalTo(array(array('id' => 23, 'version' => 1)))
263
            )->will(
264
                $this->returnValue(array(22))
265
            );
266
267
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
268
            ->method('extractContentFromRows')
269
            ->with($this->equalTo($contentRows), $this->equalTo(array(22)))
270
            ->will($this->returnValue(array($this->getContentFixtureForDraft())));
271
272
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
273
            ->method('loadExternalFieldData')
274
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'));
275
276
        $gatewayMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
277
            ->expects($this->once())
278
            ->method('updateContent')
279
            ->with(23, $metadataUpdateStruct);
280
281
        $locationMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
282
            ->expects($this->once())
283
            ->method('createLocationsFromNodeAssignments')
284
            ->with(23, 1);
285
286
        $locationMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
287
            ->expects($this->once())
288
            ->method('updateLocationsContentVersionNo')
289
            ->with(23, 1);
290
291
        $handler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
292
            ->expects($this->once())
293
            ->method('setStatus')
294
            ->with(23, VersionInfo::STATUS_PUBLISHED, 1);
295
296
        $handler->publish(23, 1, $metadataUpdateStruct);
297
    }
298
299
    /**
300
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::publish
301
     */
302
    public function testPublish()
303
    {
304
        $handler = $this->getPartlyMockedHandler(array('loadVersionInfo', 'setStatus'));
305
306
        $gatewayMock = $this->getGatewayMock();
307
        $mapperMock = $this->getMapperMock();
308
        $locationMock = $this->getLocationGatewayMock();
309
        $fieldHandlerMock = $this->getFieldHandlerMock();
310
        $metadataUpdateStruct = new MetadataUpdateStruct();
311
312
        $handler->expects($this->at(0))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
313
            ->method('loadVersionInfo')
314
            ->with(23, 2)
315
            ->will(
316
                $this->returnValue(
317
                    new VersionInfo(array('contentInfo' => new ContentInfo(array('currentVersionNo' => 1))))
318
                )
319
            );
320
321
        $handler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
322
            ->expects($this->at(1))
323
            ->method('setStatus')
324
            ->with(23, VersionInfo::STATUS_ARCHIVED, 1);
325
326
        $contentRows = [['ezcontentobject_version_version' => 2]];
327
328
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
329
            ->method('load')
330
            ->with(
331
                $this->equalTo(23),
332
                $this->equalTo(2),
333
                $this->equalTo(null)
334
            )
335
            ->willReturn($contentRows);
336
337
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
338
            ->method('loadVersionedNameData')
339
            ->with(
340
                $this->equalTo(array(array('id' => 23, 'version' => 2)))
341
            )->will(
342
                $this->returnValue(array(22))
343
            );
344
345
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
346
            ->method('extractContentFromRows')
347
            ->with($this->equalTo($contentRows), $this->equalTo(array(22)))
348
            ->will($this->returnValue(array($this->getContentFixtureForDraft())));
349
350
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
351
            ->method('loadExternalFieldData')
352
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'));
353
354
        $gatewayMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
355
            ->expects($this->once())
356
            ->method('updateContent')
357
            ->with(23, $metadataUpdateStruct, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo'));
358
359
        $locationMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
360
            ->expects($this->once())
361
            ->method('createLocationsFromNodeAssignments')
362
            ->with(23, 2);
363
364
        $locationMock
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
365
            ->expects($this->once())
366
            ->method('updateLocationsContentVersionNo')
367
            ->with(23, 2);
368
369
        $handler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
370
            ->expects($this->at(2))
371
            ->method('setStatus')
372
            ->with(23, VersionInfo::STATUS_PUBLISHED, 2);
373
374
        $handler->publish(23, 2, $metadataUpdateStruct);
375
    }
376
377
    /**
378
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::createDraftFromVersion
379
     */
380
    public function testCreateDraftFromVersion()
381
    {
382
        $handler = $this->getPartlyMockedHandler(array('load'));
383
384
        $mapperMock = $this->getMapperMock();
385
        $gatewayMock = $this->getGatewayMock();
386
        $fieldHandlerMock = $this->getFieldHandlerMock();
387
388
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
389
            ->method('load')
390
            ->with(23, 2)
391
            ->will($this->returnValue($this->getContentFixtureForDraft()));
392
393
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
394
            ->method('createVersionInfoForContent')
395
            ->with(
396
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'),
397
                $this->equalTo(3),
398
                $this->equalTo(14)
399
            )->will(
400
                $this->returnValue(
401
                    new VersionInfo(
402
                        array(
403
                            'names' => array(),
404
                            'versionNo' => 3,
405
                        )
406
                    )
407
                )
408
            );
409
410
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
411
            ->method('insertVersion')
412
            ->with(
413
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo'),
414
                $this->getContentFixtureForDraft()->fields
415
            )->will($this->returnValue(42));
416
417
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
418
            ->method('getLastVersionNumber')
419
            ->with($this->equalTo(23))
420
            ->will($this->returnValue(2));
421
422
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
423
            ->method('createExistingFieldsInNewVersion')
424
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'));
425
426
        $relationData = array(
427
            array(
428
                'ezcontentobject_link_contentclassattribute_id' => 0,
429
                'ezcontentobject_link_to_contentobject_id' => 42,
430
                'ezcontentobject_link_relation_type' => 1,
431
            ),
432
        );
433
434
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
435
            ->method('loadRelations')
436
            ->with(
437
                $this->equalTo(23),
438
                $this->equalTo(2)
439
            )
440
            ->will($this->returnValue($relationData));
441
442
        $relationStruct = new RelationCreateStruct(
443
            array(
444
                'sourceContentId' => 23,
445
                'sourceContentVersionNo' => 3,
446
                'sourceFieldDefinitionId' => 0,
447
                'destinationContentId' => 42,
448
                'type' => 1,
449
            )
450
        );
451
452
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
453
            ->method('insertRelation')
454
            ->with($this->equalTo($relationStruct));
455
456
        $result = $handler->createDraftFromVersion(23, 2, 14);
457
458
        $this->assertInstanceOf(
459
            'eZ\\Publish\\SPI\\Persistence\\Content',
460
            $result
461
        );
462
        $this->assertEquals(
463
            42,
464
            $result->versionInfo->id
465
        );
466
    }
467
468
    /**
469
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::load
470
     */
471
    public function testLoad()
472
    {
473
        $handler = $this->getContentHandler();
474
475
        $gatewayMock = $this->getGatewayMock();
476
        $mapperMock = $this->getMapperMock();
477
        $fieldHandlerMock = $this->getFieldHandlerMock();
478
479
        $contentRows = [['ezcontentobject_version_version' => 2]];
480
481
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
482
            ->method('load')
483
            ->with(
484
                $this->equalTo(23),
485
                $this->equalTo(2),
486
                $this->equalTo(array('eng-GB'))
487
            )->will(
488
                $this->returnValue($contentRows)
489
            );
490
491
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
492
            ->method('loadVersionedNameData')
493
            ->with(
494
                $this->equalTo(array(array('id' => 23, 'version' => 2)))
495
            )->will(
496
                $this->returnValue(array(22))
497
            );
498
499
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
500
            ->method('extractContentFromRows')
501
            ->with($this->equalTo($contentRows), $this->equalTo(array(22)))
502
            ->will($this->returnValue(array($this->getContentFixtureForDraft())));
503
504
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
505
            ->method('loadExternalFieldData')
506
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'));
507
508
        $result = $handler->load(23, 2, array('eng-GB'));
509
510
        $this->assertEquals(
511
            $result,
512
            $this->getContentFixtureForDraft()
513
        );
514
    }
515
516
    /**
517
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::loadContentInfoByRemoteId
518
     */
519 View Code Duplication
    public function testLoadContentInfoByRemoteId()
520
    {
521
        $contentInfoData = array(new ContentInfo());
522
        $this->getGatewayMock()->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
523
            ->method('loadContentInfoByRemoteId')
524
            ->with(
525
                $this->equalTo('15b256dbea2ae72418ff5facc999e8f9')
526
            )->will(
527
                $this->returnValue(array(42))
528
            );
529
530
        $this->getMapperMock()->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
531
            ->method('extractContentInfoFromRow')
532
            ->with($this->equalTo(array(42)))
533
            ->will($this->returnValue($contentInfoData));
534
535
        $this->assertSame(
536
            $contentInfoData,
537
            $this->getContentHandler()->loadContentInfoByRemoteId('15b256dbea2ae72418ff5facc999e8f9')
538
        );
539
    }
540
541
    /**
542
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::load
543
     * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException
544
     */
545 View Code Duplication
    public function testLoadErrorNotFound()
546
    {
547
        $handler = $this->getContentHandler();
548
549
        $gatewayMock = $this->getGatewayMock();
550
551
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
552
            ->method('load')
553
            ->will(
554
                $this->returnValue(array())
555
            );
556
557
        $result = $handler->load(23, 2, array('eng-GB'));
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
558
    }
559
560
    /**
561
     * Returns a Content for {@link testCreateDraftFromVersion()}.
562
     *
563
     * @return \eZ\Publish\SPI\Persistence\Content
564
     */
565
    protected function getContentFixtureForDraft()
566
    {
567
        $content = new Content();
568
        $content->versionInfo = new VersionInfo();
569
        $content->versionInfo->versionNo = 2;
570
571
        $content->versionInfo->contentInfo = new ContentInfo();
572
573
        $field = new Field();
574
        $field->versionNo = 2;
575
576
        $content->fields = array($field);
577
578
        return $content;
579
    }
580
581
    /**
582
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::updateContent
583
     */
584
    public function testUpdateContent()
585
    {
586
        $handler = $this->getPartlyMockedHandler(array('load', 'loadContentInfo'));
587
588
        $gatewayMock = $this->getGatewayMock();
589
        $fieldHandlerMock = $this->getFieldHandlerMock();
590
        $contentTypeHandlerMock = $this->getContentTypeHandlerMock();
591
        $contentTypeMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type');
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
592
        $contentStub = new Content(
593
            array(
594
                'versionInfo' => new VersionInfo(
595
                    array(
596
                        'contentInfo' => new ContentInfo(
597
                            array(
598
                                'contentTypeId' => 4242,
599
                            )
600
                        ),
601
                    )
602
                ),
603
            )
604
        );
605
606
        $contentTypeHandlerMock->expects($this->once())
607
            ->method('load')
608
            ->with($contentStub->versionInfo->contentInfo->contentTypeId)
609
            ->will($this->returnValue($contentTypeMock));
610
611
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
612
            ->method('updateContent')
613
            ->with(14, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\MetadataUpdateStruct'));
614
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
615
            ->method('updateVersion')
616
            ->with(14, 4, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UpdateStruct'));
617
618
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
619
            ->method('updateFields')
620
            ->with(
621
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'),
622
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UpdateStruct'),
623
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type')
624
            );
625
626
        $handler->expects($this->at(0))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
627
            ->method('load')
628
            ->with(14, 4)
629
            ->will($this->returnValue($contentStub));
630
631
        $handler->expects($this->at(1))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
632
            ->method('load')
633
            ->with(14, 4);
634
635
        $handler->expects($this->at(2))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
636
            ->method('loadContentInfo')
637
            ->with(14);
638
639
        $resultContent = $handler->updateContent(
0 ignored issues
show
Unused Code introduced by
$resultContent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
640
            14, // ContentId
641
            4, // VersionNo
642
            new UpdateStruct(
643
                array(
644
                    'creatorId' => 14,
645
                    'modificationDate' => time(),
646
                    'initialLanguageId' => 2,
647
                    'fields' => array(
648
                        new Field(
649
                            array(
650
                                'id' => 23,
651
                                'fieldDefinitionId' => 42,
652
                                'type' => 'some-type',
653
                                'value' => new FieldValue(),
654
                            )
655
                        ),
656
                        new Field(
657
                            array(
658
                                'id' => 23,
659
                                'fieldDefinitionId' => 43,
660
                                'type' => 'some-type',
661
                                'value' => new FieldValue(),
662
                            )
663
                        ),
664
                    ),
665
                )
666
            )
667
        );
668
669
        $resultContentInfo = $handler->updateMetadata(
0 ignored issues
show
Unused Code introduced by
$resultContentInfo is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
670
            14, // ContentId
671
            new MetadataUpdateStruct(
672
                array(
673
                    'ownerId' => 14,
674
                    'name' => 'Some name',
675
                    'modificationDate' => time(),
676
                    'alwaysAvailable' => true,
677
                )
678
            )
679
        );
680
    }
681
682
    /**
683
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::updateMetadata
684
     */
685
    public function testUpdateMetadata()
686
    {
687
        $handler = $this->getPartlyMockedHandler(array('load', 'loadContentInfo'));
688
689
        $gatewayMock = $this->getGatewayMock();
690
        $fieldHandlerMock = $this->getFieldHandlerMock();
0 ignored issues
show
Unused Code introduced by
$fieldHandlerMock is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
691
        $updateStruct = new MetadataUpdateStruct(
692
            array(
693
                'ownerId' => 14,
694
                'name' => 'Some name',
695
                'modificationDate' => time(),
696
                'alwaysAvailable' => true,
697
            )
698
        );
699
700
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
701
            ->method('updateContent')
702
            ->with(14, $updateStruct);
703
704
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
705
            ->method('loadContentInfo')
706
            ->with(14)
707
            ->will(
708
                $this->returnValue(
709
                    $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo')
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
710
                )
711
            );
712
713
        $resultContentInfo = $handler->updateMetadata(
714
            14, // ContentId
715
            $updateStruct
716
        );
717
        self::assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo', $resultContentInfo);
718
    }
719
720
    /**
721
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::updateMetadata
722
     */
723
    public function testUpdateMetadataUpdatesPathIdentificationString()
724
    {
725
        $handler = $this->getPartlyMockedHandler(array('load', 'loadContentInfo'));
726
        $locationGatewayMock = $this->getLocationGatewayMock();
727
        $slugConverterMock = $this->getSlugConverterMock();
728
        $urlAliasGatewayMock = $this->getUrlAliasGatewayMock();
729
        $gatewayMock = $this->getGatewayMock();
730
        $updateStruct = new MetadataUpdateStruct(array('mainLanguageId' => 2));
731
732
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
733
            ->method('updateContent')
734
            ->with(14, $updateStruct);
735
736
        $locationGatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
737
            ->method('loadLocationDataByContent')
738
            ->with(14)
739
            ->will(
740
                $this->returnValue(
741
                    array(
742
                        array(
743
                            'node_id' => 100,
744
                            'parent_node_id' => 200,
745
                        ),
746
                    )
747
                )
748
            );
749
750
        $urlAliasGatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\UrlAlias\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
751
            ->method('loadLocationEntries')
752
            ->with(100, false, 2)
753
            ->will(
754
                $this->returnValue(
755
                    array(
756
                        array(
757
                            'text' => 'slug',
758
                        ),
759
                    )
760
                )
761
            );
762
763
        $slugConverterMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...UrlAlias\SlugConverter>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
764
            ->method('convert')
765
            ->with('slug', 'node_100', 'urlalias_compat')
766
            ->will($this->returnValue('transformed_slug'));
767
768
        $locationGatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
769
            ->method('updatePathIdentificationString')
770
            ->with(100, 200, 'transformed_slug');
771
772
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
773
            ->method('loadContentInfo')
774
            ->with(14)
775
            ->will(
776
                $this->returnValue(
777
                    $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo')
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
778
                )
779
            );
780
781
        $handler->updateMetadata(
782
            14, // ContentId
783
            $updateStruct
784
        );
785
    }
786
787
    /**
788
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::loadRelations
789
     */
790
    public function testLoadRelations()
791
    {
792
        $handler = $this->getContentHandler();
793
794
        $gatewayMock = $this->getGatewayMock();
795
        $mapperMock = $this->getMapperMock();
796
797
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
798
            ->method('loadRelations')
799
            ->with(
800
                $this->equalTo(23),
801
                $this->equalTo(null),
802
                $this->equalTo(null)
803
            )->will(
804
                $this->returnValue(array(42))
805
            );
806
807
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
808
            ->method('extractRelationsFromRows')
809
            ->with($this->equalTo(array(42)))
810
            ->will($this->returnValue($this->getRelationFixture()));
811
812
        $result = $handler->loadRelations(23);
813
814
        $this->assertEquals(
815
            $result,
816
            $this->getRelationFixture()
817
        );
818
    }
819
820
    /**
821
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::loadReverseRelations
822
     */
823
    public function testLoadReverseRelations()
824
    {
825
        $handler = $this->getContentHandler();
826
827
        $gatewayMock = $this->getGatewayMock();
828
        $mapperMock = $this->getMapperMock();
829
830
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
831
            ->method('loadReverseRelations')
832
            ->with(
833
                $this->equalTo(23),
834
                $this->equalTo(null)
835
            )->will(
836
                $this->returnValue(array(42))
837
            );
838
839
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
840
            ->method('extractRelationsFromRows')
841
            ->with($this->equalTo(array(42)))
842
            ->will($this->returnValue($this->getRelationFixture()));
843
844
        $result = $handler->loadReverseRelations(23);
845
846
        $this->assertEquals(
847
            $result,
848
            $this->getRelationFixture()
849
        );
850
    }
851
852
    public function testAddRelation()
853
    {
854
        // expected relation object after creation
855
        $expectedRelationObject = new Relation();
856
        $expectedRelationObject->id = 42; // mocked value, not a real one
857
        $expectedRelationObject->sourceContentId = 23;
858
        $expectedRelationObject->sourceContentVersionNo = 1;
859
        $expectedRelationObject->destinationContentId = 66;
860
        $expectedRelationObject->type = RelationValue::COMMON;
861
862
        // relation create struct
863
        $relationCreateStruct = new Relation\CreateStruct();
864
        $relationCreateStruct->destinationContentId = 66;
865
        $relationCreateStruct->sourceContentId = 23;
866
        $relationCreateStruct->sourceContentVersionNo = 1;
867
        $relationCreateStruct->type = RelationValue::COMMON;
868
869
        $handler = $this->getContentHandler();
870
871
        $gatewayMock = $this->getGatewayMock();
872
        $mapperMock = $this->getMapperMock();
873
874
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
875
            ->method('createRelationFromCreateStruct')
876
            // @todo Connected with the todo above
877
            ->with($this->equalTo($relationCreateStruct))
878
            ->will($this->returnValue($expectedRelationObject));
879
880
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
881
            ->method('insertRelation')
882
            ->with($this->equalTo($relationCreateStruct))
883
            ->will(
884
                // @todo Should this return a row as if it was selected from the database, the id... ? Check with other, similar create methods
885
                $this->returnValue(42)
886
            );
887
888
        $result = $handler->addRelation($relationCreateStruct);
889
890
        $this->assertEquals(
891
            $result,
892
            $expectedRelationObject
893
        );
894
    }
895
896
    /**
897
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::removeRelation
898
     */
899
    public function testRemoveRelation()
900
    {
901
        $gatewayMock = $this->getGatewayMock();
902
903
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
904
            ->method('deleteRelation')
905
            ->with($this->equalTo(1, RelationValue::COMMON));
906
907
        $this->getContentHandler()->removeRelation(1, RelationValue::COMMON);
908
    }
909
910
    protected function getRelationFixture()
911
    {
912
        $relation = new Relation();
913
        $relation->sourceContentId = 23;
914
        $relation->sourceContentVersionNo = 1;
915
        $relation->destinationContentId = 69;
916
917
        return $relation;
918
    }
919
920
    /**
921
     * Returns a CreateStruct fixture.
922
     *
923
     * @return \eZ\Publish\SPI\Persistence\Content\CreateStruct
924
     */
925
    public function getCreateStructFixture()
926
    {
927
        $struct = new CreateStruct();
928
929
        $struct->typeId = 4242;
930
931
        $firstField = new Field();
932
        $firstField->type = 'some-type';
933
        $firstField->value = new FieldValue();
934
935
        $secondField = clone $firstField;
936
937
        $struct->fields = array(
938
            $firstField, $secondField,
939
        );
940
941
        $struct->locations = array(
942
            new LocationCreateStruct(
943
                array('parentId' => 42)
944
            ),
945
        );
946
947
        $struct->name = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('eng-GB' => 'This is a test name') of type array<string,string,{"eng-GB":"string"}> is incompatible with the declared type array<integer,string> of property $name.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
948
            'eng-GB' => 'This is a test name',
949
        );
950
951
        return $struct;
952
    }
953
954
    /**
955
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::loadDraftsForUser
956
     */
957
    public function testLoadDraftsForUser()
958
    {
959
        $handler = $this->getContentHandler();
960
        $rows = array(array('ezcontentobject_version_contentobject_id' => 42, 'ezcontentobject_version_version' => 2));
961
962
        $gatewayMock = $this->getGatewayMock();
963
        $mapperMock = $this->getMapperMock();
964
965
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
966
            ->method('listVersionsForUser')
967
            ->with($this->equalTo(23))
968
            ->will($this->returnValue($rows));
969
970
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
971
            ->method('loadVersionedNameData')
972
            ->with($this->equalTo(array(array('id' => 42, 'version' => 2))))
973
            ->will($this->returnValue(array()));
974
975
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
976
            ->method('extractVersionInfoListFromRows')
977
            ->with($this->equalTo($rows), $this->equalTo(array()))
978
            ->will($this->returnValue(array(new VersionInfo())));
979
980
        $res = $handler->loadDraftsForUser(23);
981
982
        $this->assertEquals(
983
            array(new VersionInfo()),
984
            $res
985
        );
986
    }
987
988
    public function testListVersions()
989
    {
990
        $handler = $this->getContentHandler();
991
992
        $treeHandlerMock = $this->getTreeHandlerMock();
993
994
        $treeHandlerMock
995
            ->expects($this->once())
996
            ->method('listVersions')
997
            ->with(23)
998
            ->will($this->returnValue(array(new VersionInfo())));
999
1000
        $versions = $handler->listVersions(23);
1001
1002
        $this->assertEquals(
1003
            array(new VersionInfo()),
1004
            $versions
1005
        );
1006
    }
1007
1008
    public function testRemoveRawContent()
1009
    {
1010
        $handler = $this->getContentHandler();
1011
        $treeHandlerMock = $this->getTreeHandlerMock();
1012
1013
        $treeHandlerMock
1014
            ->expects($this->once())
1015
            ->method('removeRawContent')
1016
            ->with(23);
1017
1018
        $handler->removeRawContent(23);
1019
    }
1020
1021
    /**
1022
     * Test for the deleteContent() method.
1023
     *
1024
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::deleteContent
1025
     */
1026
    public function testDeleteContentWithLocations()
1027
    {
1028
        $handlerMock = $this->getPartlyMockedHandler(array('getAllLocationIds'));
1029
        $gatewayMock = $this->getGatewayMock();
1030
        $treeHandlerMock = $this->getTreeHandlerMock();
1031
1032
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1033
            ->method('getAllLocationIds')
1034
            ->with($this->equalTo(23))
1035
            ->will($this->returnValue(array(42, 24)));
1036
        $treeHandlerMock->expects($this->exactly(2))
1037
            ->method('removeSubtree')
1038
            ->with(
1039
                $this->logicalOr(
1040
                    $this->equalTo(42),
1041
                    $this->equalTo(24)
1042
                )
1043
            );
1044
1045
        $handlerMock->deleteContent(23);
1046
    }
1047
1048
    /**
1049
     * Test for the deleteContent() method.
1050
     *
1051
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::deleteContent
1052
     */
1053
    public function testDeleteContentWithoutLocations()
1054
    {
1055
        $handlerMock = $this->getPartlyMockedHandler(array('removeRawContent'));
1056
        $gatewayMock = $this->getGatewayMock();
1057
1058
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1059
            ->method('getAllLocationIds')
1060
            ->with($this->equalTo(23))
1061
            ->will($this->returnValue(array()));
1062
        $handlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1063
            ->method('removeRawContent')
1064
            ->with($this->equalTo(23));
1065
1066
        $handlerMock->deleteContent(23);
1067
    }
1068
1069
    /**
1070
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::deleteVersion
1071
     */
1072
    public function testDeleteVersion()
1073
    {
1074
        $handler = $this->getContentHandler();
1075
1076
        $gatewayMock = $this->getGatewayMock();
1077
        $mapperMock = $this->getMapperMock();
1078
        $locationHandlerMock = $this->getLocationGatewayMock();
1079
        $fieldHandlerMock = $this->getFieldHandlerMock();
1080
1081
        // Load VersionInfo to delete fields
1082
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1083
            ->method('loadVersionInfo')
1084
            ->with($this->equalTo(225), $this->equalTo(2))
1085
            ->will($this->returnValue(array(42)));
1086
1087
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1088
            ->method('loadVersionedNameData')
1089
            ->with($this->equalTo(array(array('id' => 225, 'version' => 2))))
1090
            ->will($this->returnValue(array(22)));
1091
1092
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1093
            ->method('extractVersionInfoListFromRows')
1094
            ->with($this->equalTo(array(42)), $this->equalTo(array(22)))
1095
            ->will($this->returnValue(array(new VersionInfo())));
1096
1097
        $locationHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1098
            ->method('deleteNodeAssignment')
1099
            ->with(
1100
                $this->equalTo(225),
1101
                $this->equalTo(2)
1102
            );
1103
1104
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1105
            ->method('deleteFields')
1106
            ->with(
1107
                $this->equalTo(225),
1108
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo')
1109
            );
1110
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1111
            ->method('deleteRelations')
1112
            ->with(
1113
                $this->equalTo(225),
1114
                $this->equalTo(2)
1115
            );
1116
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1117
            ->method('deleteVersions')
1118
            ->with(
1119
                $this->equalTo(225),
1120
                $this->equalTo(2)
1121
            );
1122
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1123
            ->method('deleteNames')
1124
            ->with(
1125
                $this->equalTo(225),
1126
                $this->equalTo(2)
1127
            );
1128
1129
        $handler->deleteVersion(225, 2);
1130
    }
1131
1132
    /**
1133
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::copy
1134
     */
1135
    public function testCopySingleVersion()
1136
    {
1137
        $handler = $this->getPartlyMockedHandler(array('load', 'internalCreate'));
1138
        $gatewayMock = $this->getGatewayMock();
1139
        $mapperMock = $this->getMapperMock();
1140
1141
        $handler->expects(
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1142
            $this->once()
1143
        )->method(
1144
            'load'
1145
        )->with(
1146
            $this->equalTo(23),
1147
            $this->equalTo(32)
1148
        )->will(
1149
            $this->returnValue(new Content())
1150
        );
1151
1152
        $mapperMock->expects(
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1153
            $this->once()
1154
        )->method(
1155
            'createCreateStructFromContent'
1156
        )->with(
1157
            $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content')
1158
        )->will(
1159
            $this->returnValue(new CreateStruct())
1160
        );
1161
1162
        $handler->expects(
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1163
            $this->once()
1164
        )->method(
1165
            'internalCreate'
1166
        )->with(
1167
            $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\CreateStruct'),
1168
            $this->equalTo(32)
1169
        )->will(
1170
            $this->returnValue(
1171
                new Content(
1172
                    [
1173
                        'versionInfo' => new VersionInfo(['contentInfo' => new ContentInfo(['id' => 24])]),
1174
                    ]
1175
                )
1176
            )
1177
        );
1178
1179
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1180
            ->method('copyRelations')
1181
            ->with(
1182
                $this->equalTo(23),
1183
                $this->equalTo(24),
1184
                $this->equalTo(32)
1185
            )
1186
            ->will($this->returnValue(null));
1187
1188
        $result = $handler->copy(23, 32);
1189
1190
        $this->assertInstanceOf(
1191
            'eZ\\Publish\\SPI\\Persistence\\Content',
1192
            $result
1193
        );
1194
    }
1195
1196
    /**
1197
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::copy
1198
     */
1199
    public function testCopyAllVersions()
1200
    {
1201
        $handler = $this->getPartlyMockedHandler(
1202
            array(
1203
                'loadContentInfo',
1204
                'load',
1205
                'internalCreate',
1206
                'listVersions',
1207
            )
1208
        );
1209
        $gatewayMock = $this->getGatewayMock();
1210
        $mapperMock = $this->getMapperMock();
1211
        $fieldHandlerMock = $this->getFieldHandlerMock();
1212
        $contentTypeHandlerMock = $this->getContentTypeHandlerMock();
1213
        $contentTypeMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type');
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1214
        $time = time();
1215
        $createStructStub = new CreateStruct(
1216
            array(
1217
                'modified' => $time,
1218
                'typeId' => 4242,
1219
            )
1220
        );
1221
1222
        $contentTypeHandlerMock->expects($this->once())
1223
            ->method('load')
1224
            ->with($createStructStub->typeId)
1225
            ->will($this->returnValue($contentTypeMock));
1226
1227
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1228
            ->method('loadContentInfo')
1229
            ->with($this->equalTo(23))
1230
            ->will($this->returnValue(new ContentInfo(array('currentVersionNo' => 2))));
1231
1232
        $handler->expects($this->at(1))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1233
            ->method('load')
1234
            ->with($this->equalTo(23), $this->equalTo(2))
1235
            ->will($this->returnValue(new Content()));
1236
1237
        $mapperMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...\Legacy\Content\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1238
            ->method('createCreateStructFromContent')
1239
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'))
1240
            ->will(
1241
                $this->returnValue($createStructStub)
1242
            );
1243
1244
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1245
            ->method('internalCreate')
1246
            ->with(
1247
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\CreateStruct'),
1248
                $this->equalTo(2)
1249
            )->will(
1250
                $this->returnValue(
1251
                    new Content(
1252
                        array(
1253
                            'versionInfo' => new VersionInfo(
1254
                                array(
1255
                                    'contentInfo' => new ContentInfo(array('id' => 24)),
1256
                                )
1257
                            ),
1258
                        )
1259
                    )
1260
                )
1261
            );
1262
1263
        $handler->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1264
            ->method('listVersions')
1265
            ->with($this->equalTo(23))
1266
            ->will(
1267
                $this->returnValue(
1268
                    array(
1269
                        new VersionInfo(array('versionNo' => 1)),
1270
                        new VersionInfo(array('versionNo' => 2)),
1271
                    )
1272
                )
1273
            );
1274
1275
        $versionInfo = new VersionInfo(
1276
            array(
1277
                'names' => array('eng-US' => 'Test'),
1278
                'contentInfo' => new ContentInfo(
1279
                    array(
1280
                        'id' => 24,
1281
                        'alwaysAvailable' => true,
1282
                    )
1283
                ),
1284
            )
1285
        );
1286
        $handler->expects($this->at(4))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1287
            ->method('load')
1288
            ->with($this->equalTo(23), $this->equalTo(1))
1289
            ->will(
1290
                $this->returnValue(
1291
                    new Content(
1292
                        array(
1293
                            'versionInfo' => $versionInfo,
1294
                            'fields' => array(),
1295
                        )
1296
                    )
1297
                )
1298
            );
1299
1300
        $versionInfo->creationDate = $time;
1301
        $versionInfo->modificationDate = $time;
1302
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1303
            ->method('insertVersion')
1304
            ->with(
1305
                $this->equalTo($versionInfo),
1306
                $this->isType('array')
1307
            )->will($this->returnValue(42));
1308
1309
        $versionInfo = clone $versionInfo;
1310
        $versionInfo->id = 42;
1311
        $fieldHandlerMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...y\Content\FieldHandler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1312
            ->method('createNewFields')
1313
            ->with(
1314
                $this->equalTo(
1315
                    new Content(
1316
                        array(
1317
                            'versionInfo' => $versionInfo,
1318
                            'fields' => array(),
1319
                        )
1320
                    )
1321
                ),
1322
                $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type')
1323
            );
1324
1325
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1326
            ->method('setName')
1327
            ->with(
1328
                $this->equalTo(24),
1329
                $this->equalTo(1),
1330
                $this->equalTo('Test'),
1331
                $this->equalTo('eng-US')
1332
            );
1333
1334
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1335
            ->method('copyRelations')
1336
            ->with(
1337
                $this->equalTo(23),
1338
                $this->equalTo(24),
1339
                $this->equalTo(null)
1340
            )
1341
            ->will($this->returnValue(null));
1342
1343
        $result = $handler->copy(23);
1344
1345
        $this->assertInstanceOf(
1346
            'eZ\\Publish\\SPI\\Persistence\\Content',
1347
            $result
1348
        );
1349
    }
1350
1351
    /**
1352
     * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException
1353
     */
1354
    public function testCopyThrowsNotFoundExceptionContentNotFound()
1355
    {
1356
        $handler = $this->getContentHandler();
1357
1358
        $treeHandlerMock = $this->getTreeHandlerMock();
1359
        $treeHandlerMock
1360
            ->expects($this->once())
1361
            ->method('loadContentInfo')
1362
            ->with($this->equalTo(23))
1363
            ->will(
1364
                $this->throwException(new NotFoundException('ContentInfo', 23))
1365
            );
1366
1367
        $handler->copy(23);
1368
    }
1369
1370
    /**
1371
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::copy
1372
     * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException
1373
     */
1374 View Code Duplication
    public function testCopyThrowsNotFoundExceptionVersionNotFound()
1375
    {
1376
        $handler = $this->getContentHandler();
1377
1378
        $gatewayMock = $this->getGatewayMock();
1379
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1380
            ->method('load')
1381
            ->with($this->equalTo(23, 32))
1382
            ->will($this->returnValue(array()));
1383
1384
        $result = $handler->copy(23, 32);
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1385
    }
1386
1387
    /**
1388
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Handler::setStatus
1389
     */
1390 View Code Duplication
    public function testSetStatus()
1391
    {
1392
        $handler = $this->getContentHandler();
1393
1394
        $mapperMock = $this->getMapperMock();
0 ignored issues
show
Unused Code introduced by
$mapperMock is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1395
        $gatewayMock = $this->getGatewayMock();
1396
1397
        $gatewayMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...Legacy\Content\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1398
            ->method('setStatus')
1399
            ->with(23, 5, 2)
1400
            ->will($this->returnValue(true));
1401
1402
        $this->assertTrue(
1403
            $handler->setStatus(23, 2, 5)
1404
        );
1405
    }
1406
1407
    /**
1408
     * Returns the handler to test.
1409
     *
1410
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Handler
1411
     */
1412
    protected function getContentHandler()
1413
    {
1414
        if (!isset($this->contentHandler)) {
1415
            $this->contentHandler = new Handler(
1416
                $this->getGatewayMock(),
1417
                $this->getLocationGatewayMock(),
1418
                $this->getMapperMock(),
1419
                $this->getFieldHandlerMock(),
1420
                $this->getSlugConverterMock(),
1421
                $this->getUrlAliasGatewayMock(),
1422
                $this->getContentTypeHandlerMock(),
0 ignored issues
show
Bug introduced by
It seems like $this->getContentTypeHandlerMock() targeting eZ\Publish\Core\Persiste...ontentTypeHandlerMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, eZ\Publish\Core\Persiste...\Handler::__construct() does only seem to accept object<eZ\Publish\SPI\Pe...e\Content\Type\Handler>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
1423
                $this->getTreeHandlerMock()
0 ignored issues
show
Bug introduced by
It seems like $this->getTreeHandlerMock() targeting eZ\Publish\Core\Persiste...t::getTreeHandlerMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, eZ\Publish\Core\Persiste...\Handler::__construct() does only seem to accept object<eZ\Publish\Core\P...cy\Content\TreeHandler>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
1424
            );
1425
        }
1426
1427
        return $this->contentHandler;
1428
    }
1429
1430
    /**
1431
     * Returns the handler to test with $methods mocked.
1432
     *
1433
     * @param string[] $methods
1434
     *
1435
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Handler
1436
     */
1437
    protected function getPartlyMockedHandler(array $methods)
1438
    {
1439
        $mock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1440
            '\\eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Handler',
1441
            $methods,
1442
            array(
1443
                $this->getGatewayMock(),
1444
                $this->getLocationGatewayMock(),
1445
                $this->getMapperMock(),
1446
                $this->getFieldHandlerMock(),
1447
                $this->getSlugConverterMock(),
1448
                $this->getUrlAliasGatewayMock(),
1449
                $this->getContentTypeHandlerMock(),
1450
                $this->getTreeHandlerMock(),
1451
            )
1452
        );
1453
1454
        return $mock;
1455
    }
1456
1457
    /**
1458
     * Returns a TreeHandler mock.
1459
     *
1460
     * @return \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\Persistence\Legacy\Content\TreeHandler
1461
     */
1462
    protected function getTreeHandlerMock()
1463
    {
1464
        if (!isset($this->treeHandlerMock)) {
1465
            $this->treeHandlerMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1466
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\TreeHandler',
1467
                array(),
1468
                array(),
1469
                '',
1470
                false
1471
            );
1472
        }
1473
1474
        return $this->treeHandlerMock;
1475
    }
1476
1477
    /**
1478
     * Returns a ContentTypeHandler mock.
1479
     *
1480
     * @return \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler
1481
     */
1482 View Code Duplication
    protected function getContentTypeHandlerMock()
1483
    {
1484
        if (!isset($this->contentTypeHandlerMock)) {
1485
            $this->contentTypeHandlerMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1486
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Type\\Handler',
1487
                array(),
1488
                array(),
1489
                '',
1490
                false
1491
            );
1492
        }
1493
1494
        return $this->contentTypeHandlerMock;
1495
    }
1496
1497
    /**
1498
     * Returns a FieldHandler mock.
1499
     *
1500
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler
1501
     */
1502 View Code Duplication
    protected function getFieldHandlerMock()
1503
    {
1504
        if (!isset($this->fieldHandlerMock)) {
1505
            $this->fieldHandlerMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1506
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\FieldHandler',
1507
                array(),
1508
                array(),
1509
                '',
1510
                false
1511
            );
1512
        }
1513
1514
        return $this->fieldHandlerMock;
1515
    }
1516
1517
    /**
1518
     * Returns a Mapper mock.
1519
     *
1520
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper
1521
     */
1522 View Code Duplication
    protected function getMapperMock()
1523
    {
1524
        if (!isset($this->mapperMock)) {
1525
            $this->mapperMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1526
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Mapper',
1527
                array(),
1528
                array(),
1529
                '',
1530
                false
1531
            );
1532
        }
1533
1534
        return $this->mapperMock;
1535
    }
1536
1537
    /**
1538
     * Returns a Location Gateway mock.
1539
     *
1540
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
1541
     */
1542
    protected function getLocationGatewayMock()
1543
    {
1544
        if (!isset($this->locationGatewayMock)) {
1545
            $this->locationGatewayMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1546
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway'
1547
            );
1548
        }
1549
1550
        return $this->locationGatewayMock;
1551
    }
1552
1553
    /**
1554
     * Returns a Content Type gateway mock.
1555
     *
1556
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Type\Gateway
1557
     */
1558
    protected function getTypeGatewayMock()
1559
    {
1560
        if (!isset($this->typeGatewayMock)) {
1561
            $this->typeGatewayMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1562
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Type\\Gateway'
1563
            );
1564
        }
1565
1566
        return $this->typeGatewayMock;
1567
    }
1568
1569
    /**
1570
     * Returns a mock object for the Content Gateway.
1571
     *
1572
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Gateway
1573
     */
1574
    protected function getGatewayMock()
1575
    {
1576
        if (!isset($this->gatewayMock)) {
1577
            $this->gatewayMock = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...acy\\Content\\Gateway') of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<eZ\Publish\Core\P...Legacy\Content\Gateway> of property $gatewayMock.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1578
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Gateway'
1579
            );
1580
        }
1581
1582
        return $this->gatewayMock;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->gatewayMock; of type PHPUnit_Framework_MockOb...\Legacy\Content\Gateway adds the type PHPUnit_Framework_MockObject_MockObject to the return on line 1582 which is incompatible with the return type documented by eZ\Publish\Core\Persiste...lerTest::getGatewayMock of type eZ\Publish\Core\Persistence\Legacy\Content\Gateway.
Loading history...
1583
    }
1584
1585
    /**
1586
     * Returns a mock object for the UrlAlias Handler.
1587
     *
1588
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter
1589
     */
1590
    protected function getSlugConverterMock()
1591
    {
1592
        if (!isset($this->slugConverterMock)) {
1593
            $this->slugConverterMock = $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
{@inheritdoc}

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1594
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\UrlAlias\\SlugConverter',
1595
                array(),
1596
                array(),
1597
                '',
1598
                false
1599
            );
1600
        }
1601
1602
        return $this->slugConverterMock;
1603
    }
1604
1605
    /**
1606
     * Returns a mock object for the UrlAlias Gateway.
1607
     *
1608
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway
1609
     */
1610
    protected function getUrlAliasGatewayMock()
1611
    {
1612
        if (!isset($this->urlAliasGatewayMock)) {
1613
            $this->urlAliasGatewayMock = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...nt\\UrlAlias\\Gateway') of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<eZ\Publish\Core\P...ntent\UrlAlias\Gateway> of property $urlAliasGatewayMock.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1614
                'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\UrlAlias\\Gateway'
1615
            );
1616
        }
1617
1618
        return $this->urlAliasGatewayMock;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->urlAliasGatewayMock; of type PHPUnit_Framework_MockOb...ontent\UrlAlias\Gateway adds the type PHPUnit_Framework_MockObject_MockObject to the return on line 1618 which is incompatible with the return type documented by eZ\Publish\Core\Persiste...:getUrlAliasGatewayMock of type eZ\Publish\Core\Persiste...ontent\UrlAlias\Gateway.
Loading history...
1619
    }
1620
}
1621