Completed
Pull Request — master (#91)
by Julien
03:40
created

testDeserializeEntityWithAnInexistantSetter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.8333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mapado\RestClientSdk\Tests\Units\Model;
6
7
use atoum;
8
use DateTime;
9
use libphonenumber\PhoneNumberFormat;
10
use libphonenumber\PhoneNumberUtil;
11
use Mapado\RestClientSdk\Exception\MissingSetterException;
12
use Mapado\RestClientSdk\Mapping;
13
use Mapado\RestClientSdk\Mapping\Attribute;
14
use Mapado\RestClientSdk\Mapping\ClassMetadata;
15
use Mapado\RestClientSdk\Mapping\Driver\AnnotationDriver;
16
use Mapado\RestClientSdk\Mapping\Relation;
17
use Mapado\RestClientSdk\Tests\Model\Issue46;
18
use Mapado\RestClientSdk\Tests\Model\Issue75;
19
use Mapado\RestClientSdk\Tests\Model\Issue80;
20
use Mapado\RestClientSdk\Tests\Model\Issue90;
21
use Mapado\RestClientSdk\Tests\Model\JsonLd;
22
use Mapado\RestClientSdk\UnitOfWork;
23
24
/**
25
 * Class Serializer
26
 *
27
 * @author Julien Deniau <[email protected]>
28
 */
29
class Serializer extends atoum
30
{
31
    /**
32
     * @var UnitOfWork
33
     */
34
    private $unitOfWork;
35
36
    /**
37
     * testJsonEncode
38
     */
39
    public function testJsonEncode()
40
    {
41
        $this->createNewInstance();
42
43
        $this
44
            ->given($cart = $this->createCart())
45
            ->then
46
                ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
47
                    ->isIdenticalTo([
48
                        '@id' => '/v1/carts/8',
49
                        'status' => 'payed',
50
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
51
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
52
                        'cart_items' => [],
53
                        'order' => null,
54
                    ])
55
56
            // reverse the serialization
57
            ->then
58
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
59
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\Cart')
60
                ->string($cart->getId())
61
                    ->isEqualTo('/v1/carts/8')
62
                ->string($cart->getStatus())
63
                    ->isEqualTo('payed')
64
                ->datetime($cart->getCreatedAt())
65
                    ->isEqualTo(new \DateTime('2015-09-20T12:08:00'))
66
                ->array($cart->getCartItemList())
67
                    ->isEmpty()
68
69
        ;
70
    }
71
72
    /**
73
     * testJsonEncodeRelation
74
     */
75
    public function testJsonEncodeRelationWithLink()
76
    {
77
        $this->createNewInstance();
78
79
        $this
80
            ->given($cart = $this->createCart())
81
                ->and($cartItem = $this->createKnownCartItem())
82
                ->and($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
83
84
            ->then
85
                ->array($data = $this->testedInstance->serialize(
86
                    $cart,
87
                    'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
88
                    ['serializeRelations' => ['cart_items']]
89
                ))
90
                    ->isIdenticalTo([
91
                        '@id' => '/v1/carts/8',
92
                        'status' => 'payed',
93
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
94
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
95
                        'cart_items' => [
96
                            [
97
                                '@id' => '/v1/cart_items/16',
98
                                'amount' => 1,
99
                                'createdAt' => (new \DateTime('2015-11-04 15:13:00'))->format(DateTime::RFC3339),
100
                                'data' => [
101
                                    'when' => (new \DateTime('2015-11-04 15:00:00'))->format(DateTime::RFC3339),
102
                                    'who' => 'Jane',
103
                                ],
104
                                'cart' => '/v1/carts/8',
105
                                'product' => '/v1/products/10',
106
                                'cartItemDetailList' => [],
107
                            ],
108
                        ],
109
                        'order' => null,
110
                    ])
111
112
            ->then
113
                ->array($data = $this->testedInstance->serialize(
114
                    $cart,
115
                    'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
116
                    ['serializeRelations' => ['cart_items']]
117
                ))
118
                    ->isIdenticalTo([
119
                        '@id' => '/v1/carts/8',
120
                        'status' => 'payed',
121
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
122
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
123
                        'cart_items' => [
124
                            [
125
                                '@id' => '/v1/cart_items/16',
126
                                'amount' => 1,
127
                                'createdAt' => (new \DateTime('2015-11-04 15:13:00'))->format(DateTime::RFC3339),
128
                                'data' => [
129
                                    'when' => (new \DateTime('2015-11-04 15:00:00'))->format(DateTime::RFC3339),
130
                                    'who' => 'Jane',
131
                                ],
132
                                'cart' => '/v1/carts/8',
133
                                'product' => '/v1/products/10',
134
                                'cartItemDetailList' => [],
135
                            ],
136
                        ],
137
                        'order' => null,
138
                    ])
139
140
            // reverse the serialization
141
            ->then
142
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
143
                ->array($cart->getCartItemList())
144
                    ->size->isEqualTo(1)
145
                ->object($cartItem = current($cart->getCartItemList()))
146
                    ->isInstanceOf(JsonLd\CartItem::class)
147
                ->string($cartItem->getId())
148
                    ->isEqualTo('/v1/cart_items/16')
149
            ;
150
    }
151
152
    /**
153
     * testJsonEncodeRelationWithoutLink
154
     */
155
    public function testJsonEncodeRelationWithoutLink()
156
    {
157
        $this->createNewInstance();
158
159
        $this
160
            ->given($cart = $this->createCart())
161
                ->and($cartItem = $this->createNewCartItem())
162
                ->and($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
163
            ->then
164
                ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
165
                    ->isIdenticalTo([
166
                        '@id' => '/v1/carts/8',
167
                        'status' => 'payed',
168
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
169
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
170
                        'cart_items' => [
171
                            [
172
                                'amount' => 2,
173
                                'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339),
174
                                'data' => [
175
                                    'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339),
176
                                    'who' => 'John',
177
                                ],
178
                                'product' => '/v1/products/10',
179
                                'cartItemDetailList' => [],
180
                            ],
181
                        ],
182
                        'order' => null,
183
                    ])
184
185
            // reverse the serialization
186
            ->then
187
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
188
                ->array($cartItemList = $cart->getCartItemList()) // we can not uneserialize an unlinked entity
189
                    ->size->isEqualTo(1)
190
                ->object($cartItemList[0])
191
                    ->isInstanceOf(JsonLd\CartItem::class)
192
                ->variable($cartItemList[0]->getId())
193
                    ->isNull
194
        ;
195
    }
196
197
    public function testSerializeThreeLevel()
198
    {
199
        $this->createNewInstance();
200
201
        $this
202
            ->given($cart = $this->createNewCart())
203
                ->and($cartItem = $this->createNewCartItem())
204
                ->and($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
205
            ->then
206
                ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
207
                    ->isIdenticalTo([
208
                        'status' => 'payed',
209
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
210
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
211
                        'cart_items' => [
212
                            [
213
                                'amount' => 2,
214
                                'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339),
215
                                'data' => [
216
                                    'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339),
217
                                    'who' => 'John',
218
                                ],
219
                                'product' => '/v1/products/10',
220
                                'cartItemDetailList' => [],
221
                            ],
222
                        ],
223
                        'order' => null,
224
                    ])
225
        ;
226
    }
227
228
    /**
229
     * testJsonEncodeRelationWithoutLinkMultipleLevel
230
     */
231
    public function testJsonEncodeRelationWithoutLinkMultipleLevel()
232
    {
233
        $this->createNewInstance();
234
        $this
235
            ->given($cart = $this->createCart())
236
                ->and($cartItem = $this->createNewCartItem(false))
237
                ->and($cartItem->addCartItemDetailList($this->createNewCartItemDetail()))
238
                ->and($cartItem->addCartItemDetailList($this->createNewCartItemDetail()))
239
            ->if($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
240
            ->then
241
                ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
242
                    ->isIdenticalTo([
243
                        '@id' => '/v1/carts/8',
244
                        'status' => 'payed',
245
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
246
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
247
                        'cart_items' => [
248
                            [
249
                                'amount' => 2,
250
                                'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339),
251
                                'data' => [
252
                                    'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339),
253
                                    'who' => 'John',
254
                                ],
255
                                'cartItemDetailList' => [
256
                                    ['name' => 'Bill'],
257
                                    ['name' => 'Bill'],
258
                                ],
259
                            ],
260
                        ],
261
                        'order' => null,
262
                    ])
263
        ;
264
    }
265
266
    /**
267
     * testJsonEncodeMixRelations
268
     */
269
    public function testJsonEncodeMixRelations()
270
    {
271
        $this->createNewInstance();
272
273
        $this
274
            ->given($cart = $this->createCart())
275
                ->and($cartItem = $this->createNewCartItem())
276
                ->and($knownedCartItem = $this->createKnownCartItem())
277
            ->if($cart->addCartItemList($knownedCartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($knownedCartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
278
                ->and($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
279
            ->then
280
                ->array($data = $this->testedInstance->serialize(
281
                    $cart,
282
                    'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
283
                    ['serializeRelations' => ['cart_items']]
284
                ))
285
                    ->isIdenticalTo([
286
                        '@id' => '/v1/carts/8',
287
                        'status' => 'payed',
288
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
289
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
290
                        'cart_items' => [
291
                            [
292
                                '@id' => '/v1/cart_items/16',
293
                                'amount' => 1,
294
                                'createdAt' => (new \DateTime('2015-11-04 15:13:00'))->format(DateTime::RFC3339),
295
                                'data' => [
296
                                    'when' => (new \DateTime('2015-11-04 15:00:00'))->format(DateTime::RFC3339),
297
                                    'who' => 'Jane',
298
                                ],
299
                                'cart' => '/v1/carts/8',
300
                                'product' => '/v1/products/10',
301
                                'cartItemDetailList' => [],
302
                            ],
303
                            [
304
                                'amount' => 2,
305
                                'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339),
306
                                'data' => [
307
                                    'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339),
308
                                    'who' => 'John',
309
                                ],
310
                                'product' => '/v1/products/10',
311
                                'cartItemDetailList' => [],
312
                            ],
313
                        ],
314
                        'order' => null,
315
                    ])
316
317
            // reverse the serialization
318
            ->then
319
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
320
                ->array($cartItemList = $cart->getCartItemList()) // we can not uneserialize an unlinked entity
321
                    ->size->isEqualTo(2)
322
                ->object($cartItem = $cartItemList[0])
323
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
324
                ->string($cartItem->getId())
325
                    ->isEqualTo('/v1/cart_items/16')
326
                ->object($cartItem = $cartItemList[1])
327
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
328
                ->variable($cartItem->getId())
329
                    ->isNull()
330
        ;
331
    }
332
333
    /**
334
     * testNotAllowedSerialization
335
     */
336
    public function testNotAllowedSerialization()
337
    {
338
        $this->createNewInstance();
339
        $this
340
            ->given($cartItem = $this->createNewCartItem())
341
                ->and($cartItemDetail = $this->createNewCartItemDetail())
342
                ->and($cartItemDetail->setCartItem($cartItem))
343
                ->and($testedInstance = $this->testedInstance)
344
            ->then
345
                ->object($cartItemDetail->getCartItem())
346
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
347
                ->exception(function () use ($testedInstance, $cartItemDetail) {
348
                    $testedInstance->serialize($cartItemDetail, 'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItemDetail');
349
                })
350
                    ->isInstanceOf('Mapado\RestClientSdk\Exception\SdkException')
351
        ;
352
    }
353
354
    /**
355
     * testMultipleLevelSerialization
356
     */
357
    public function testMultipleLevelSerialization()
358
    {
359
        $this->createNewInstance();
360
        $this
361
            ->given($cart = $this->createNewCart())
362
                ->and($cartItem = $this->createNewCartItem())
363
                ->and($cartItem->setCart($cart))
364
            ->then
365
                ->array($this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
366
                    ->isIdenticalTo([
367
                        'status' => 'payed',
368
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
369
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
370
                        'cart_items' => [
371
                            [
372
                                'amount' => 2,
373
                                'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339),
374
                                'data' => [
375
                                    'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339),
376
                                    'who' => 'John',
377
                                ],
378
                                'product' => '/v1/products/10',
379
                                'cartItemDetailList' => [],
380
                            ],
381
                        ],
382
                        'order' => null,
383
                    ])
384
385
        ;
386
    }
387
388
    /**
389
     * testLinkedUnserialize
390
     */
391
    public function testLinkedUnserialize()
392
    {
393
        $this->createNewInstance();
394
        $phoneNumberUtil = PhoneNumberUtil::getInstance();
395
396
        $this
397
            ->given($data = [
398
                    '@id' => '/v1/carts/8',
399
                    'status' => 'payed',
400
                    'clientPhoneNumber' => $phoneNumberUtil->parse('+330123456789', PhoneNumberFormat::INTERNATIONAL),
401
                    'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
402
                    'cart_items' => [
403
                        [
404
                            '@id' => '/v1/cart_items/16',
405
                            'amount' => 2,
406
                            'createdAt' => (new \DateTime('2015-09-20T12:11:00+00:00'))->format(DateTime::RFC3339),
407
                            'data' => [
408
                                'when' => (new \DateTime('2015-09-20T15:00:00+00:00'))->format(DateTime::RFC3339),
409
                                'who' => 'John',
410
                            ],
411
                            'product' => '/v1/products/10',
412
                            'cartItemDetailList' => [],
413
                        ],
414
                    ],
415
                ])
416
            ->then
417
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
418
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\Cart')
419
                ->object($cart->getClientPhoneNumber())
420
                    ->isInstanceOf('libphonenumber\PhoneNumber')
421
                ->array($cart->getCartItemList())
422
                    ->size->isEqualTo(1)
423
                ->object($cartItem = current($cart->getCartItemList()))
424
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
425
                ->string($cartItem->getId())
426
                    ->isEqualTo('/v1/cart_items/16')
427
                ->integer($cartItem->getAmount())
428
                    ->isEqualTo(2)
429
                ->datetime($cartItem->getCreatedAt())
430
                    ->isEqualTo(new \DateTime('2015-09-20T12:11:00+00:00'))
431
                ->array($cartItem->getData())
432
                    ->isEqualTo([
433
                        'when' => (new \DateTime('2015-09-20T15:00:00+00:00'))->format(DateTime::RFC3339),
434
                        'who' => 'John',
435
                    ])
436
                ->object($cartItem->getProduct())
437
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\Product')
438
                ->string($cartItem->getProduct()->getId())
439
                    ->isEqualTo('/v1/products/10')
440
                ->array($cartItem->getCartItemDetailList())
441
                    ->isEmpty()
442
        ;
443
444
        $this->createNewInstance();
445
        $this
446
            ->given($data = [
447
                    '@id' => '/v1/cart_items/16',
448
                    'amount' => 2,
449
                    'cart' => [
450
                        '@id' => '/v1/carts/10',
451
                        'status' => 'waiting',
452
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
453
                    ],
454
                ])
455
456
            ->then
457
                ->object($cartItem = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem'))
458
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
459
                ->object($cart = $cartItem->getCart())
460
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\Cart')
461
                ->string($cart->getClientPhoneNumber())
462
                    ->isEqualTo('+33 1 23 45 67 89')
463
                ->string($cart->getId())
464
                    ->isEqualTo('/v1/carts/10')
465
                ->string($cart->getStatus())
466
                    ->isEqualTo('waiting')
467
        ;
468
    }
469
470
    public function testSerializeNullValues()
471
    {
472
        $this->createNewInstance();
473
        $this
474
            ->given($cart = $this->createNewCart())
475
                ->and($cart->setStatus(null))
476
                ->and($cart->setOrder(null))
477
            ->then
478
                ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
479
                    ->isIdenticalTo([
480
                        'status' => null,
481
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
482
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
483
                        'cart_items' => [],
484
                        'order' => null,
485
                    ])
486
        ;
487
    }
488
489
    public function testSerializingAttributeNameDiffThanPropertyName()
490
    {
491
        $this->createNewInstance();
492
        $this
493
            ->given($product = $this->createNewProduct())
494
            ->then
495
                ->array($data = $this->testedInstance->serialize($product, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Product'))
496
                ->isIdenticalTo([
497
                    'product_value' => 8.2,
498
                    'currency' => 'eur',
499
                ])
500
        ;
501
    }
502
503
    public function testWeirdIdentifier()
504
    {
505
        $mapping = $this->getMapping('weirdId');
506
        $this->createNewInstance($mapping);
507
508
        $this
509
            ->given($cart = $this->createCart())
510
                ->and($cartItem = $this->createKnownCartItem())
511
                ->and($cart->addCartItemList($cartItem))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $cart->addCartItemList($cartItem) targeting Mapado\RestClientSdk\Tes...Cart::addCartItemList() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
512
513
            ->then
514
                ->array($data = $this->testedInstance->serialize(
515
                    $cart,
516
                    'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
517
                    ['serializeRelations' => ['cart_items']]
518
                ))
519
                    ->isIdenticalTo([
520
                        'weirdId' => '/v1/carts/8',
521
                        'status' => 'payed',
522
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
523
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
524
                        'cart_items' => [
525
                            [
526
                                'weirdId' => '/v1/cart_items/16',
527
                                'amount' => 1,
528
                                'createdAt' => (new \DateTime('2015-11-04 15:13:00'))->format(DateTime::RFC3339),
529
                                'data' => [
530
                                    'when' => (new \DateTime('2015-11-04 15:00:00'))->format(DateTime::RFC3339),
531
                                    'who' => 'Jane',
532
                                ],
533
                                'cart' => '/v1/carts/8',
534
                                'product' => '/v1/products/10',
535
                                'cartItemDetailList' => [],
536
                            ],
537
                        ],
538
                        'order' => null,
539
                    ])
540
541
            ->then
542
                ->array($data = $this->testedInstance->serialize(
543
                    $cart,
544
                    'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
545
                    ['serializeRelations' => ['cart_items']]
546
                ))
547
                    ->isIdenticalTo([
548
                        'weirdId' => '/v1/carts/8',
549
                        'status' => 'payed',
550
                        'clientPhoneNumber' => '+33 1 23 45 67 89',
551
                        'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
552
                        'cart_items' => [
553
                            [
554
                                'weirdId' => '/v1/cart_items/16',
555
                                'amount' => 1,
556
                                'createdAt' => (new \DateTime('2015-11-04 15:13:00'))->format(DateTime::RFC3339),
557
                                'data' => [
558
                                    'when' => (new \DateTime('2015-11-04 15:00:00'))->format(DateTime::RFC3339),
559
                                    'who' => 'Jane',
560
                                ],
561
                                'cart' => '/v1/carts/8',
562
                                'product' => '/v1/products/10',
563
                                'cartItemDetailList' => [],
564
                            ],
565
                        ],
566
                        'order' => null,
567
                    ])
568
569
            // reverse the serialization
570
            ->then
571
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
572
                ->string($cart->getId())
573
                    ->isEqualTo('/v1/carts/8')
574
                ->array($cart->getCartItemList())
575
                    ->size->isEqualTo(1)
576
                // ->object($cartItem = current($cart->getCartItemList()))
577
                //     ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem')
578
                // ->string($cartItem->getId())
579
                //     ->isEqualTo('/v1/cart_items/16')
580
            ;
581
    }
582
583
    public function testDeserializeWithExtraFields()
584
    {
585
        $this->createNewInstance();
586
587
        $this
588
            ->given($data = [
589
                '@foo' => 'bar',
590
                '@id' => '/v1/carts/8',
591
                'status' => 'payed',
592
                'clientPhoneNumber' => '+33 1 23 45 67 89',
593
                'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339),
594
                'cart_items' => [],
595
                'order' => null,
596
            ])
597
598
            ->then
599
                ->object($cart = $this->testedInstance->deserialize($data, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'))
600
                    ->isInstanceOf('Mapado\RestClientSdk\Tests\Model\JsonLd\Cart')
601
        ;
602
    }
603
604
    public function testSerializingIriManyToOne()
605
    {
606
        $annotationDriver = new AnnotationDriver(__DIR__ . '/../../cache/');
607
        $mapping = new Mapping();
608
        $mapping->setMapping($annotationDriver->loadDirectory(__DIR__ . '/../../Model/Issue46/'));
609
610
        $section = new Issue46\Section();
611
        $section->setId(46);
612
        $section->setIri('/sections/46');
613
        $section->setTitle('section title');
614
615
        $article = new Issue46\Article();
616
        $article->setSection($section);
617
618
        $this->createNewInstance($mapping);
619
620
        $this
621
            ->then
622
                ->array($this->testedInstance->serialize($article, 'Mapado\RestClientSdk\Tests\Model\Issue46\Article'))
623
                    ->isIdenticalTo([
624
                        'id' => null,
625
                        'section' => '/sections/46',
626
                    ])
627
628
                ->if($article->setIri('/articles/44'))
629
630
                ->array($this->testedInstance
631
                    ->serialize(
632
                        $section,
633
                        'Mapado\RestClientSdk\Tests\Model\Issue46\Section'
634
                    ))
635
                ->isIdenticalTo([
636
                    '@id' => '/sections/46',
637
                    'id' => 46,
638
                    'title' => 'section title',
639
                    'articleList' => [
640
                        '/articles/44',
641
                    ],
642
                ])
643
644
                ->array($this->testedInstance
645
                    ->serialize(
646
                        $section,
647
                        'Mapado\RestClientSdk\Tests\Model\Issue46\Section',
648
                        ['serializeRelations' => ['articleList']]
649
                    ))
650
                ->isIdenticalTo([
651
                    '@id' => '/sections/46',
652
                    'id' => 46,
653
                    'title' => 'section title',
654
                    'articleList' => [
655
                        [
656
                            '@id' => '/articles/44',
657
                            'id' => null,
658
                            'section' => '/sections/46',
659
                        ],
660
                    ],
661
                ])
662
        ;
663
    }
664
665
    public function testDeserializeEntityWithoutIriAttribute()
666
    {
667
        $annotationDriver = new AnnotationDriver(__DIR__ . '/../../cache/');
668
        $mapping = new Mapping();
669
        $mapping->setMapping($annotationDriver->loadDirectory(__DIR__ . '/../../Model/Issue75/'));
670
671
        $this->createNewInstance($mapping);
672
        $this
673
            ->given($data = [
674
                '@id' => '/v1/articles/8',
675
                'tag' => [
676
                    'name' => 'tag name',
677
                ],
678
            ])
679
680
            ->then
681
                ->object($article = $this->testedInstance->deserialize($data, Issue75\Article::class))
682
                    ->isInstanceOf(Issue75\Article::class)
683
                ->object($article->getTag())
684
                    ->isInstanceOf(Issue75\Tag::class)
685
686
            ->given($data = [
687
                '@id' => '/v1/articles/8',
688
                'tagList' => [
689
                    [
690
                        'name' => 'tag 1 name',
691
                    ],
692
                    [
693
                        'name' => 'tag 2 name',
694
                    ],
695
                ],
696
            ])
697
698
            ->then
699
                ->object($article = $this->testedInstance->deserialize($data, Issue75\Article::class))
700
                    ->isInstanceOf(Issue75\Article::class)
701
                ->array($tagList = $article->getTagList())
702
                    ->size->isEqualTo(2)
703
                ->object($tagList[0])
704
                    ->isInstanceOf(Issue75\Tag::class)
705
                ->string($tagList[0]->getName())
706
                    ->isIdenticalTo('tag 1 name')
707
                ->object($tagList[1])
708
                    ->isInstanceOf(Issue75\Tag::class)
709
                ->string($tagList[1]->getName())
710
                    ->isIdenticalTo('tag 2 name')
711
        ;
712
    }
713
714
    public function testSerializeEntityWithoutIriAttribute()
715
    {
716
        $annotationDriver = new AnnotationDriver(__DIR__ . '/../../cache/');
717
        $mapping = new Mapping();
718
        $mapping->setMapping($annotationDriver->loadDirectory(__DIR__ . '/../../Model/Issue75/'));
719
720
        $tag = new Issue75\Tag();
721
        $tag->setName('tag title');
722
723
        $article = new Issue75\Article();
724
        $article->setTitle('article title');
725
726
        $this->createNewInstance($mapping);
727
        $this
728
            ->then
729
                ->array($data = $this->testedInstance->serialize($article, Issue75\Article::class))
730
                ->isIdenticalTo([
731
                    'title' => 'article title',
732
                    'tag' => null,
733
                    'tagList' => null,
734
                ])
735
736
            ->if($article->setTag($tag))
0 ignored issues
show
Bug introduced by
Are you sure the usage of $article->setTag($tag) targeting Mapado\RestClientSdk\Tes...sue75\Article::setTag() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
737
                ->array($data = $this->testedInstance->serialize($article, Issue75\Article::class))
738
                    ->isIdenticalTo([
739
                        'title' => 'article title',
740
                        'tag' => [
741
                            'name' => 'tag title',
742
                        ],
743
                        'tagList' => null,
744
                    ])
745
746
            ->if($article->setTagList([(new Issue75\Tag())->setName('tag 1')]))
747
                ->array($data = $this->testedInstance->serialize($article, Issue75\Article::class))
748
                    ->isIdenticalTo([
749
                        'title' => 'article title',
750
                        'tag' => [
751
                            'name' => 'tag title',
752
                        ],
753
                        'tagList' => [
754
                            ['name' => 'tag 1'],
755
                        ],
756
                    ])
757
758
            ->then
759
                // as tags does not have an Attribute identifier, we ignore the serializeRelations context
760
                ->array($data = $this->testedInstance->serialize($article, Issue75\Article::class, ['serializeRelations' => ['tag', 'tagList']]))
761
                    ->isIdenticalTo([
762
                        'title' => 'article title',
763
                        'tag' => [
764
                            'name' => 'tag title',
765
                        ],
766
                        'tagList' => [
767
                            ['name' => 'tag 1'],
768
                        ],
769
                    ])
770
        ;
771
    }
772
773
    public function testDeserializeEntityWithIntAsId()
774
    {
775
        $annotationDriver = new AnnotationDriver(__DIR__ . '/../../cache/');
776
        $mapping = new Mapping();
777
        $mapping->setMapping($annotationDriver->loadDirectory(__DIR__ . '/../../Model/Issue90/'));
778
779
        $this->createNewInstance($mapping);
780
        $this
781
            ->given($data = [
782
                'id' => 8,
783
            ])
784
785
            ->then
786
                ->object($article = $this->testedInstance->deserialize($data, Issue90\WithIdInt::class))
787
                    ->isInstanceOf(Issue90\WithIdInt::class)
788
789
                ->object($this->unitOfWork->getDirtyEntity('8'))
790
        ;
791
    }
792
793
    public function testDeserializeEntityWithAnInexistantSetter()
794
    {
795
        $annotationDriver = new AnnotationDriver(__DIR__ . '/../../cache/');
796
        $mapping = new Mapping();
797
        $mapping->setMapping($annotationDriver->loadDirectory(__DIR__ . '/../../Model/Issue80/'));
798
799
        $this->createNewInstance($mapping);
800
        $this
801
            ->given($data = [
802
                'id' => 8,
803
                'title' => 'some title',
804
            ])
805
            ->and($testedInstance = $this->testedInstance)
806
807
            ->then
808
                ->exception(function () use ($testedInstance, $data) {
0 ignored issues
show
Unused Code introduced by
The import $testedInstance is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
809
                    $article = $this->testedInstance->deserialize($data, Issue80\Article::class);
0 ignored issues
show
Unused Code introduced by
The assignment to $article is dead and can be removed.
Loading history...
810
                })
811
                    ->isInstanceOf(MissingSetterException::class)
812
        ;
813
    }
814
815
    /**
816
     * getMapping
817
     *
818
     * @return Mapping
819
     */
820
    private function getMapping($idKey = '@id')
821
    {
822
        $mapping = new Mapping('/v1');
823
        $mapping->setMapping([
824
            $this->getCartMetadata($idKey),
825
            $this->getCartItemMetadata($idKey),
826
            $this->getCartItemDetailMetadata($idKey),
827
            $this->getProductMetadata($idKey),
828
        ]);
829
830
        return $mapping;
831
    }
832
833
    /**
834
     * @param string $idKey
835
     */
836
    private function getProductMetadata($idKey)
837
    {
838
        $productMetadata = new ClassMetadata(
839
            'products',
840
            'Mapado\RestClientSdk\Tests\Model\JsonLd\Product',
841
            ''
842
        );
843
844
        $productMetadata->setAttributeList([
845
            new Attribute($idKey, 'id', 'string', true),
846
            new Attribute('product_value', 'value'),
847
            new Attribute('currency'),
848
        ]);
849
850
        return $productMetadata;
851
    }
852
853
    /**
854
     * @param string $idKey
855
     */
856
    private function getCartItemDetailMetadata($idKey)
857
    {
858
        $cartItemDetailMetadata = new ClassMetadata(
859
            'cart_item_details',
860
            'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItemDetail',
861
            ''
862
        );
863
864
        $cartItemDetailMetadata->setRelationList([
865
            new Relation('cartItem', Relation::MANY_TO_ONE, 'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem'),
866
        ]);
867
        $cartItemDetailMetadata->setAttributeList([
868
            new Attribute($idKey, 'id', 'string', true),
869
            new Attribute('name'),
870
            new Attribute('cartItem'),
871
        ]);
872
873
        return $cartItemDetailMetadata;
874
    }
875
876
    /**
877
     * @param string $idKey
878
     */
879
    private function getCartItemMetadata($idKey)
880
    {
881
        $cartItemMetadata = new ClassMetadata(
882
            'cart_items',
883
            'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem',
884
            ''
885
        );
886
887
        $cartItemMetadata->setRelationList([
888
            new Relation('cart', Relation::MANY_TO_ONE, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart'),
889
            new Relation('product', Relation::MANY_TO_ONE, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Product'),
890
            new Relation('cartItemDetailList', Relation::ONE_TO_MANY, 'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItemDetail'),
891
        ]);
892
        $cartItemMetadata->setAttributeList([
893
            new Attribute($idKey, 'id', 'string', true),
894
            new Attribute('amount'),
895
            new Attribute('createdAt', 'createdAt', 'datetime'),
896
            new Attribute('data'),
897
            new Attribute('cart'),
898
            new Attribute('product'),
899
            new Attribute('cartItemDetailList'),
900
        ]);
901
902
        return $cartItemMetadata;
903
    }
904
905
    /**
906
     * @param string $idKey
907
     */
908
    private function getCartMetadata($idKey)
909
    {
910
        $cartMetadata = new ClassMetadata(
911
            'carts',
912
            'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart',
913
            ''
914
        );
915
        $cartMetadata->setAttributeList([
916
            new Attribute($idKey, 'id', 'string', true),
917
            new Attribute('status'),
918
            new Attribute('clientPhoneNumber', 'clientPhoneNumber', 'phone_number'),
919
            new Attribute('createdAt', 'createdAt', 'datetime'),
920
            new Attribute('cart_items', 'cartItemList'),
921
            new Attribute('order'),
922
        ]);
923
        $cartMetadata->setRelationList([
924
            new Relation('cart_items', Relation::ONE_TO_MANY, 'Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem'),
925
            new Relation('order', Relation::MANY_TO_ONE, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Order'),
926
        ]);
927
928
        return $cartMetadata;
929
    }
930
931
    /**
932
     * createNewCart
933
     *
934
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\Cart
935
     */
936
    private function createNewCart()
937
    {
938
        $cart = new \Mapado\RestClientSdk\Tests\Model\JsonLd\Cart();
939
        $cart->setStatus('payed');
940
        $cart->setCreatedAt(new DateTime('2015-09-20 12:08:00'));
941
942
        $phoneNumberUtil = PhoneNumberUtil::getInstance();
943
        $clientPhoneNumber = $phoneNumberUtil->parse('+33123456789', PhoneNumberFormat::INTERNATIONAL);
944
        $cart->setClientPhoneNumber($clientPhoneNumber);
945
946
        return $cart;
947
    }
948
949
    /**
950
     * createCart
951
     *
952
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\Cart
953
     */
954
    private function createCart()
955
    {
956
        $cart = $this->createNewCart();
957
        $cart->setId('/v1/carts/8');
958
959
        return $cart;
960
    }
961
962
    /**
963
     * createKnownCartItem
964
     *
965
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem
966
     */
967
    private function createKnownCartItem()
968
    {
969
        $cartItem = $this->createNewCartItem();
970
        $cartItem->setId('/v1/cart_items/16');
971
        $cartItem->setAmount(1);
972
        $cartItem->setCreatedAt(new DateTime('2015-11-04 15:13:00'));
973
        $cartItem->setData([
974
            'when' => new DateTime('2015-11-04 15:00:00'),
975
            'who' => 'Jane',
976
        ]);
977
        $cartItem->setCart($this->createCart());
978
979
        return $cartItem;
980
    }
981
982
    /**
983
     * createNewCartItem
984
     *
985
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem
986
     */
987
    private function createNewCartItem($addKnownedProduct = true)
988
    {
989
        $cartItem = new \Mapado\RestClientSdk\Tests\Model\JsonLd\CartItem();
990
        $cartItem->setAmount(2);
991
        $cartItem->setCreatedAt(new DateTime('2015-09-20 12:11:00'));
992
        $cartItem->setData([
993
            'when' => new DateTime('2015-09-20 15:00:00'),
994
            'who' => 'John',
995
        ]);
996
997
        if ($addKnownedProduct) {
998
            $cartItem->setProduct($this->createKnownedProduct());
999
        }
1000
1001
        return $cartItem;
1002
    }
1003
1004
    /**
1005
     * createNewProduct
1006
     *
1007
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\Product
1008
     */
1009
    private function createNewProduct()
1010
    {
1011
        $product = new \Mapado\RestClientSdk\Tests\Model\JsonLd\Product();
1012
1013
        $product->setValue(8.2);
1014
        $product->setCurrency('eur');
1015
1016
        return $product;
1017
    }
1018
1019
    /**
1020
     * createKnownedProduct
1021
     *
1022
     * @return \Mapado\RestClientSdk\Tests\Model\JsonLd\Product
1023
     */
1024
    private function createKnownedProduct()
1025
    {
1026
        $product = $this->createNewProduct();
1027
        $product->setId('/v1/products/10');
0 ignored issues
show
Bug introduced by
'/v1/products/10' of type string is incompatible with the type integer expected by parameter $id of Mapado\RestClientSdk\Tes...JsonLd\Product::setId(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1027
        $product->setId(/** @scrutinizer ignore-type */ '/v1/products/10');
Loading history...
1028
1029
        return $product;
1030
    }
1031
1032
    private function createNewCartItemDetail()
1033
    {
1034
        $item = new \Mapado\RestClientSdk\Tests\Model\JsonLd\CartItemDetail();
1035
1036
        $item->setName('Bill');
1037
1038
        return $item;
1039
    }
1040
1041
    /**
1042
     * createNewInstance
1043
     *
1044
     * @param Mapping $mapping
1045
     */
1046
    private function createNewInstance($mapping = null)
1047
    {
1048
        $mapping = $mapping ?: $this->getMapping();
1049
        $this->unitOfWork = new UnitOfWork($mapping);
1050
        $this->newTestedInstance($mapping, $this->unitOfWork);
1051
1052
        $this->mockGenerator->orphanize('__construct');
1053
        $this->mockGenerator->shuntParentClassCalls();
1054
        $restClient = new \mock\Mapado\RestClientSdk\RestClient();
0 ignored issues
show
Bug introduced by
The type mock\Mapado\RestClientSdk\RestClient was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1055
        $this->mockGenerator->unshuntParentClassCalls();
1056
        $sdk = new \mock\Mapado\RestClientSdk\SdkClient($restClient, $mapping, $this->unitOfWork, $this->testedInstance);
0 ignored issues
show
Bug introduced by
The type mock\Mapado\RestClientSdk\SdkClient was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1057
        $sdk->setFileCachePath(__DIR__ . '/../../cache/');
1058
1059
        $cartRepositoryMock = $this->getCartRepositoryMock($sdk, $restClient, $this->unitOfWork, 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart');
1060
1061
        $this->calling($sdk)->getRepository = function ($modelName) use ($cartRepositoryMock) {
1062
            switch ($modelName) {
1063
                case 'Mapado\RestClientSdk\Tests\Model\JsonLd\Cart':
1064
                    return $cartRepositoryMock;
1065
                default:
1066
                    return;
1067
            }
1068
        };
1069
1070
        $this->testedInstance->setSdk($sdk);
1071
    }
1072
1073
    /**
1074
     * @param string $modelName
1075
     * @param UnitOfWork $unitOfWork
1076
     */
1077
    private function getCartRepositoryMock($sdk, $restClient, $unitOfWork, $modelName)
1078
    {
1079
        $repository = new \mock\Mapado\RestClientSdk\EntityRepository(
0 ignored issues
show
Bug introduced by
The type mock\Mapado\RestClientSdk\EntityRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1080
            $sdk,
1081
            $restClient,
1082
            $unitOfWork,
1083
            $modelName
1084
        );
1085
1086
        $_this = $this;
1087
1088
        $this->calling($repository)->find = function ($id) use ($_this) {
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1088
        $this->calling($repository)->find = function (/** @scrutinizer ignore-unused */ $id) use ($_this) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1089
            return $_this->createCart();
1090
        };
1091
1092
        return $repository;
1093
    }
1094
}
1095