Completed
Push — master ( 5bcafe...c5dea9 )
by Tim
13s
created

UrlRewriteObserverTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 449
Duplicated Lines 2.45 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 11
loc 449
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 11 11 1
B testHandleWithSuccessfullCreateWithoutCategories() 0 141 1
B testHandleWithSuccessfullUpdateAndSameCategories() 0 260 1

How to fix   Duplicated Code   

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:

1
<?php
2
3
/**
4
 * TechDivision\Import\Product\UrlRewrite\Observers\UrlRewriteObserverTest
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-product-url-rewrite
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\UrlRewrite\Observers;
22
23
use TechDivision\Import\Utils\EntityStatus;
24
use TechDivision\Import\Utils\StoreViewCodes;
25
use TechDivision\Import\Product\Utils\VisibilityKeys;
26
use TechDivision\Import\Product\Utils\CoreConfigDataKeys;
27
use TechDivision\Import\Product\UrlRewrite\Utils\ColumnKeys;
28
use TechDivision\Import\Product\UrlRewrite\Utils\MemberNames;
29
30
/**
31
 * Test class for the product URL rewrite observer implementation.
32
 *
33
 * @author    Tim Wagner <[email protected]>
34
 * @copyright 2016 TechDivision GmbH <[email protected]>
35
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
36
 * @link      https://github.com/techdivision/import-product-url-rewrite
37
 * @link      http://www.techdivision.com
38
 */
39
class UrlRewriteObserverTest extends \PHPUnit_Framework_TestCase
40
{
41
42
    /**
43
     * The observer we want to test.
44
     *
45
     * @var \TechDivision\Import\Product\UrlRewrite\Observers\UrlRewriteObserver
46
     */
47
    protected $observer;
48
49
    /**
50
     * A mock processor instance.
51
     *
52
     * @var \TechDivision\Import\Product\UrlRewrite\Services\ProductUrlRewriteProcessorInterface
53
     */
54
    protected $mockProductUrlRewriteProcessor;
55
56
    /**
57
     * Sets up the fixture, for example, open a network connection.
58
     * This method is called before a test is executed.
59
     *
60
     * @return void
61
     * @see \PHPUnit_Framework_TestCase::setUp()
62
     */
63 View Code Duplication
    protected function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
66
        // initialize a mock processor instance
67
        $this->mockProductUrlRewriteProcessor = $this->getMockBuilder('TechDivision\Import\Product\UrlRewrite\Services\ProductUrlRewriteProcessorInterface')
68
                                                     ->setMethods(get_class_methods('TechDivision\Import\Product\UrlRewrite\Services\ProductUrlRewriteProcessorInterface'))
69
                                                     ->getMock();
70
71
        // initialize the observer
72
        $this->observer = new UrlRewriteObserver($this->mockProductUrlRewriteProcessor);
73
    }
74
75
    /**
76
     * Test's the handle() method with a successfull URL rewrite persist.
77
     *
78
     * @return void
79
     */
80
    public function testHandleWithSuccessfullCreateWithoutCategories()
81
    {
82
83
        // create a dummy CSV file header
84
        $headers = array(
85
            'sku'             => 0,
86
            'url_key'         => 1,
87
            'store_view_code' => 2,
88
            'visibility'      => 3,
89
            'categories'      => 4
90
        );
91
92
        // create a dummy CSV file row
93
        $row = array(
94
            0 => $sku = 'TEST-01',
95
            1 => 'bruno-compete-hoodie-test',
96
            2 => $storeViewCode = 'default',
97
            3 => 'Catalog, Search',
98
            4 => null
99
        );
100
101
        // initialize category and entity ID
102
        $categoryId = 2;
103
        $entityId = 61413;
104
105
        // create a mock subject
106
        $mockSubject = $this->getMockBuilder('TechDivision\Import\Product\UrlRewrite\Subjects\UrlRewriteSubject')
107
                            ->setMethods(
108
                                array(
109
                                    'hasHeader',
110
                                    'getHeader',
111
                                    'getHeaders',
112
                                    'getRootCategory',
113
                                    'getCategory',
114
                                    'getCoreConfigData',
115
                                    'getRowStoreId',
116
                                    'getRow',
117
                                    'hasBeenProcessed',
118
                                    'addEntityIdVisibilityIdMapping',
119
                                    'getEntityIdVisibilityIdMapping',
120
                                    'getStoreViewCode',
121
                                    'isDebugMode',
122
                                    'storeIsActive'
123
                                )
124
                            )
125
                            ->disableOriginalConstructor()
126
                            ->getMock();
127
128
        // mock the methods
129
        $mockSubject->expects($this->any())
130
                    ->method('isDebugMode')
131
                    ->willReturn(false);
132
        $mockSubject->expects($this->any())
133
                    ->method('getHeaders')
134
                    ->willReturn($headers);
135
        $mockSubject->expects($this->any())
136
                    ->method('getRow')
137
                    ->willReturn($row);
138
        $mockSubject->expects($this->any())
139
                    ->method('hasHeader')
140
                    ->willReturn(true);
141
        $mockSubject->expects($this->any())
142
                    ->method('getHeader')
143
                    ->withConsecutive(
144
                        array(ColumnKeys::SKU),
145
                        array(ColumnKeys::URL_KEY),
146
                        array(ColumnKeys::URL_KEY),
147
                        array(ColumnKeys::STORE_VIEW_CODE),
148
                        array(ColumnKeys::VISIBILITY),
149
                        array(ColumnKeys::CATEGORIES),
150
                        array(ColumnKeys::STORE_VIEW_CODE)
151
                    )
152
                    ->willReturnOnConsecutiveCalls(0, 1, 1, 2, 3, 4, 2);
153
        $mockSubject->expects($this->once())
154
                    ->method('hasBeenProcessed')
155
                    ->willReturn(false);
156
        $mockSubject->expects($this->once())
157
                    ->method('getEntityIdVisibilityIdMapping')
158
                    ->willReturn(VisibilityKeys::VISIBILITY_BOTH);
159
        $mockSubject->expects($this->exactly(1))
160
                    ->method('getRowStoreId')
161
                    ->willReturn($storeId = 1);
162
        $mockSubject->expects($this->exactly(1))
163
                    ->method('getCategory')
164
                    ->with($categoryId)
165
                    ->willReturn($category = array(MemberNames::ENTITY_ID => $categoryId, MemberNames::PARENT_ID => 1, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => null));
166
        $mockSubject->expects($this->exactly(4))
167
                    ->method('getRootCategory')
168
                    ->willReturn($category);
169
        $mockSubject->expects($this->once())
170
                    ->method('getStoreViewCode')
171
                    ->with(StoreViewCodes::ADMIN)
172
                    ->willReturn($storeViewCode);
173
        $mockSubject->expects($this->once())
174
                    ->method('storeIsActive')
175
                    ->with($storeViewCode)
176
                    ->willReturn(true);
177
        $mockSubject->expects($this->exactly(2))
178
                    ->method('getCoreConfigData')
179
                    ->withConsecutive(
180
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_USE_CATEGORIES, false),
181
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html')
182
                    )
183
                    ->willReturnOnConsecutiveCalls(true, '.html');
184
185
        // mock the processor methods
186
        $this->mockProductUrlRewriteProcessor->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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('loadProduct')
188
                    ->with($sku)
189
                    ->willReturn(array(MemberNames::ENTITY_ID => $entityId));
190
        $this->mockProductUrlRewriteProcessor->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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...
191
                    ->method('persistUrlRewrite')
192
                    ->with(
193
                        array(
194
                            MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
195
                            MemberNames::ENTITY_ID        => $entityId,
196
                            MemberNames::REQUEST_PATH     => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
197
                            MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s', $entityId),
198
                            MemberNames::REDIRECT_TYPE    => 0,
199
                            MemberNames::STORE_ID         => $storeId,
200
                            MemberNames::DESCRIPTION      => null,
201
                            MemberNames::IS_AUTOGENERATED => 1,
202
                            MemberNames::METADATA         => serialize(array()),
203
                            EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
204
                        )
205
                    )
206
                    ->willReturn($urlRewriteId = 1000);
207
        $this->mockProductUrlRewriteProcessor->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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...
208
                    ->method('persistUrlRewriteProductCategory')
209
                    ->with(
210
                        array(
211
                            MemberNames::URL_REWRITE_ID   => $urlRewriteId,
212
                            MemberNames::PRODUCT_ID       => $entityId,
213
                            MemberNames::CATEGORY_ID      => $categoryId,
214
                            EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
215
                        )
216
                    );
217
218
        // invoke the handle() method
219
        $this->assertSame($row, $this->observer->handle($mockSubject));
220
    }
221
222
    /**
223
     * Test's the handle() method with a successfull URL rewrite persist when using the same categories.
224
     *
225
     * @return void
226
     */
227
    public function testHandleWithSuccessfullUpdateAndSameCategories()
228
    {
229
230
        // initialize the entity ID to use
231
        $entityId = 61413;
232
233
        // create a dummy CSV file row
234
        $headers = array(
235
            'sku'                => 0,
236
            'url_key'            => 1,
237
            'categories'         => 2,
238
            'store_view_code'    => 3,
239
            'visibility'         => 4
240
        );
241
242
        // create a dummy CSV file header
243
        $row = array(
244
            0 => $sku = 'TEST-01',
245
            1 => 'bruno-compete-hoodie',
246
            2 => 'Default Category/Men/Tops/Hoodies & Sweatshirts,Default Category/Collections/Eco Friendly,Default Category',
247
            3 => $storeViewCode = 'default',
248
            4 => 'Catalog, Search'
249
        );
250
251
        // initialize the categories
252
        $categories = array(
253
             $path1 = 'Default Category'                                => array(MemberNames::ENTITY_ID => 2, MemberNames::PARENT_ID => 1, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => null, MemberNames::PATH => $path1),
254
             $path2 = 'Default Category/Men'                            => array(MemberNames::ENTITY_ID => 3, MemberNames::PARENT_ID => 2, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'men', MemberNames::PATH => $path2),
255
             $path3 = 'Default Category/Men/Tops'                       => array(MemberNames::ENTITY_ID => 4, MemberNames::PARENT_ID => 3, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'men/tops-men', MemberNames::PATH => $path3),
256
             $path4 = 'Default Category/Men/Tops/Hoodies & Sweatshirts' => array(MemberNames::ENTITY_ID => 5, MemberNames::PARENT_ID => 4, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'men/tops-men/hoodies-and-sweatshirts-men', MemberNames::PATH => $path4),
257
             $path5 = 'Default Category/Collections'                    => array(MemberNames::ENTITY_ID => 6, MemberNames::PARENT_ID => 3, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'collections', MemberNames::PATH => $path5),
258
             $path6 = 'Default Category/Collections/Eco Friendly'       => array(MemberNames::ENTITY_ID => 7, MemberNames::PARENT_ID => 6, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'collections/eco-friendly', MemberNames::PATH => $path6),
259
        );
260
261
        // create a mock configuration
262
        $mockSubjectConfiguration = $this->getMockBuilder('TechDivision\Import\Configuration\SubjectConfigurationInterface')
263
                                         ->setMethods(get_class_methods('TechDivision\Import\Configuration\SubjectConfigurationInterface'))
264
                                         ->getMock();
265
266
        // mock the methods
267
        $mockSubjectConfiguration->expects($this->once())
268
                                 ->method('getDelimiter')
269
                                 ->willReturn(',');
270
271
        // mock the system logger
272
        $mockSystemLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')
273
                                 ->setMethods(get_class_methods('Psr\Log\LoggerInterface'))
274
                                 ->getMock();
275
276
        // create a mock subject
277
        $mockSubject = $this->getMockBuilder('TechDivision\Import\Product\UrlRewrite\Subjects\UrlRewriteSubject')
278
                            ->setMethods(
279
                                array(
280
                                    'hasHeader',
281
                                    'getHeader',
282
                                    'getHeaders',
283
                                    'getRootCategory',
284
                                    'getRowStoreId',
285
                                    'getCategory',
286
                                    'getCoreConfigData',
287
                                    'getRow',
288
                                    'hasBeenProcessed',
289
                                    'addEntityIdVisibilityIdMapping',
290
                                    'getEntityIdVisibilityIdMapping',
291
                                    'getStoreViewCode',
292
                                    'isDebugMode',
293
                                    'storeIsActive',
294
                                    'getCategoryByPath',
295
                                    'getSystemLogger'
296
                                )
297
                            )
298
                            ->disableOriginalConstructor()
299
                            ->getMock();
300
301
        // set the mock configuration on the subject
302
        $mockSubject->setConfiguration($mockSubjectConfiguration);
303
304
        // mock the methods
305
        $mockSubject->expects($this->any())
306
                    ->method('getSystemLogger')
307
                    ->willReturn($mockSystemLogger);
308
        $mockSubject->expects($this->any())
309
                    ->method('isDebugMode')
310
                    ->willReturn(false);
311
        $mockSubject->expects($this->any())
312
                    ->method('getHeaders')
313
                    ->willReturn($headers);
314
        $mockSubject->expects($this->any())
315
                    ->method('getRow')
316
                    ->willReturn($row);
317
        $mockSubject->expects($this->any())
318
                    ->method('hasHeader')
319
                    ->willReturn(true);
320
        $mockSubject->expects($this->any())
321
                    ->method('getSystemLogger')
322
                    ->willReturn($mockSystemLogger);
323
        $mockSubject->expects($this->any())
324
                    ->method('getHeader')
325
                    ->withConsecutive(
326
                        array(ColumnKeys::SKU),
327
                        array(ColumnKeys::URL_KEY),
328
                        array(ColumnKeys::URL_KEY),
329
                        array(ColumnKeys::STORE_VIEW_CODE),
330
                        array(ColumnKeys::VISIBILITY),
331
                        array(ColumnKeys::CATEGORIES),
332
                        array(ColumnKeys::STORE_VIEW_CODE)
333
                    )
334
                    ->willReturnOnConsecutiveCalls(0, 1, 1, 3, 4, 2, 3);
335
        $mockSubject->expects($this->once())
336
                    ->method('hasBeenProcessed')
337
                    ->willReturn(false);
338
        $mockSubject->expects($this->exactly(3))
339
                    ->method('getCategoryByPath')
340
                    ->withConsecutive(
341
                        array($path4 /* Default Category/Men/Tops/Hoodies & Sweatshirts */),
342
                        array($path6 /* Default Category/Collections/Eco Friendly */),
343
                        array($path1 /* Default Category */)
344
                    )
345
                    ->willReturnOnConsecutiveCalls(
346
                        $categories[$path4],
347
                        $categories[$path6],
348
                        $categories[$path1]
349
                    );
350
        $mockSubject->expects($this->exactly(10))
351
                    ->method('getCategory')
352
                    ->withConsecutive(
353
                        array($categories[$path4][MemberNames::ENTITY_ID]),
354
                        array($categories[$path3][MemberNames::ENTITY_ID]),
355
                        array($categories[$path2][MemberNames::ENTITY_ID]),
356
                        array($categories[$path6][MemberNames::ENTITY_ID]),
357
                        array($categories[$path5][MemberNames::ENTITY_ID]),
358
                        array($categories[$path2][MemberNames::ENTITY_ID]),
359
                        array($categories[$path1][MemberNames::ENTITY_ID]),
360
                        array($categories[$path1][MemberNames::ENTITY_ID]),
361
                        array($categories[$path4][MemberNames::ENTITY_ID]),
362
                        array($categories[$path6][MemberNames::ENTITY_ID])
363
                    )
364
                    ->willReturnOnConsecutiveCalls(
365
                        $categories[$path4],
366
                        $categories[$path3],
367
                        $categories[$path2],
368
                        $categories[$path6],
369
                        $categories[$path5],
370
                        $categories[$path2],
371
                        $categories[$path1],
372
                        $categories[$path1],
373
                        $categories[$path4],
374
                        $categories[$path6]
375
                    );
376
        $mockSubject->expects($this->any())
377
                    ->method('getRootCategory')
378
                    ->willReturn($categories[$path1]);
379
        $mockSubject->expects($this->once())
380
                    ->method('getStoreViewCode')
381
                    ->with(StoreViewCodes::ADMIN)
382
                    ->willReturn($storeViewCode);
383
        $mockSubject->expects($this->once())
384
                    ->method('storeIsActive')
385
                    ->with($storeViewCode)
386
                    ->willReturn(true);
387
        $mockSubject->expects($this->once())
388
                    ->method('getEntityIdVisibilityIdMapping')
389
                    ->willReturn(VisibilityKeys::VISIBILITY_BOTH);
390
        $mockSubject->expects($this->any())
391
                    ->method('getRowStoreId')
392
                    ->willReturn($storeId = 1);
393
        $mockSubject->expects($this->exactly(4))
394
                    ->method('getCoreConfigData')
395
                    ->withConsecutive(
396
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_USE_CATEGORIES, false),
397
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
398
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
399
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html')
400
                    )
401
                    ->willReturnOnConsecutiveCalls(true, '.html', '.html', '.html');
402
403
        // mock the processor methods
404
        $this->mockProductUrlRewriteProcessor->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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...
405
                    ->method('loadProduct')
406
                    ->with($sku)
407
                    ->willReturn(array(MemberNames::ENTITY_ID => $entityId));
408
        $this->mockProductUrlRewriteProcessor->expects($this->exactly(3))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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...
409
                    ->method('persistUrlRewrite')
410
                    ->withConsecutive(
411
                        array(
412
                            array(
413
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
414
                                MemberNames::ENTITY_ID        => $entityId,
415
                                MemberNames::REQUEST_PATH     => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
416
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s', $entityId),
417
                                MemberNames::REDIRECT_TYPE    => 0,
418
                                MemberNames::STORE_ID         => $storeId,
419
                                MemberNames::DESCRIPTION      => null,
420
                                MemberNames::IS_AUTOGENERATED => 1,
421
                                MemberNames::METADATA         => serialize(array()),
422
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
423
                            )
424
                        ),
425
                        array(
426
                            array(
427
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
428
                                MemberNames::ENTITY_ID        => $entityId,
429
                                MemberNames::REQUEST_PATH     => sprintf('men/tops-men/hoodies-and-sweatshirts-men/%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
430
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/5', $entityId),
431
                                MemberNames::REDIRECT_TYPE    => 0,
432
                                MemberNames::STORE_ID         => $storeId,
433
                                MemberNames::DESCRIPTION      => null,
434
                                MemberNames::IS_AUTOGENERATED => 1,
435
                                MemberNames::METADATA         => serialize(array('category_id' => 5)),
436
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
437
                            )
438
                        ),
439
                        array(
440
                            array(
441
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
442
                                MemberNames::ENTITY_ID        => $entityId,
443
                                MemberNames::REQUEST_PATH     => sprintf('collections/eco-friendly/%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
444
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/7', $entityId),
445
                                MemberNames::REDIRECT_TYPE    => 0,
446
                                MemberNames::STORE_ID         => $storeId,
447
                                MemberNames::DESCRIPTION      => null,
448
                                MemberNames::IS_AUTOGENERATED => 1,
449
                                MemberNames::METADATA         => serialize(array('category_id' => 7)),
450
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
451
                            )
452
                        )
453
                    )
454
                    ->willReturnOnConsecutiveCalls(1000, 1001, 1002);
455
        $this->mockProductUrlRewriteProcessor->expects($this->exactly(3))
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<TechDivision\Impo...riteProcessorInterface>.

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...
456
                    ->method('persistUrlRewriteProductCategory')
457
                    ->withConsecutive(
458
                        array(
459
                            array(
460
                                MemberNames::URL_REWRITE_ID   => 1000,
461
                                MemberNames::PRODUCT_ID       => $entityId,
462
                                MemberNames::CATEGORY_ID      => 2,
463
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
464
                            )
465
                        ),
466
                        array(
467
                            array(
468
                                MemberNames::URL_REWRITE_ID   => 1001,
469
                                MemberNames::PRODUCT_ID       => $entityId,
470
                                MemberNames::CATEGORY_ID      => 5,
471
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
472
                            )
473
                        ),
474
                        array(
475
                            array(
476
                                MemberNames::URL_REWRITE_ID   => 1002,
477
                                MemberNames::PRODUCT_ID       => $entityId,
478
                                MemberNames::CATEGORY_ID      => 7,
479
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
480
                            )
481
                        )
482
                    );
483
484
        // invoke the handle() method
485
        $this->assertSame($row, $this->observer->handle($mockSubject));
486
    }
487
}
488