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

UrlRewriteUpdateObserverTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 401
Duplicated Lines 2.74 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 11 11 1
B testHandleWithSuccessfullUpdateAndDifferentCategories() 0 359 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\UrlRewriteUpdateObserverTest
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 update 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 UrlRewriteUpdateObserverTest extends \PHPUnit_Framework_TestCase
40
{
41
42
    /**
43
     * The observer we want to test.
44
     *
45
     * @var \TechDivision\Import\Product\UrlRewrite\Observers\UrlRewriteUpdateObserver
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 UrlRewriteUpdateObserver($this->mockProductUrlRewriteProcessor);
73
    }
74
75
    /**
76
     * Test's the handle() method with a successfull URL rewrite persist when using different categories.
77
     *
78
     * @return void
79
     */
80
    public function testHandleWithSuccessfullUpdateAndDifferentCategories()
81
    {
82
83
        // initialize the entity ID to use
84
        $entityId = 61413;
85
86
        // create a dummy CSV file row
87
        $headers = array(
88
            'sku'             => 0,
89
            'url_key'         => 1,
90
            'categories'      => 2,
91
            'store_view_code' => 3,
92
            'visibility'      => 4
93
        );
94
95
        // create a dummy CSV file header
96
        $row = array(
97
            0 => $sku = 'TEST-01',
98
            1 => 'bruno-compete-hoodie',
99
            2 => 'Default Category/Men/Tops/Hoodies & Sweatshirts,Default Category/Collections/Eco Friendly,Default Category',
100
            3 => $storeViewCode = 'default',
101
            4 => 'Catalog, Search'
102
        );
103
104
        // initialize the categories
105
        $categories = array(
106
             $path1 = 'Default Category'                                => array(MemberNames::ENTITY_ID => 2, MemberNames::PARENT_ID => 1, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => null, MemberNames::PATH => $path1),
107
             $path2 = 'Default Category/Men'                            => array(MemberNames::ENTITY_ID => 3, MemberNames::PARENT_ID => 2, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'men', MemberNames::PATH => $path2),
108
             $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),
109
             $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),
110
             $path5 = 'Default Category/Collections'                    => array(MemberNames::ENTITY_ID => 6, MemberNames::PARENT_ID => 3, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'collections', MemberNames::PATH => $path5),
111
             $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),
112
             $path7 = 'Default Category/Collections/Old'                => array(MemberNames::ENTITY_ID => 8, MemberNames::PARENT_ID => 6, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'collections/old', MemberNames::PATH => $path7),
113
             $path8 = 'Default Category/Men/Old'                        => array(MemberNames::ENTITY_ID => 9, MemberNames::PARENT_ID => 3, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => 'men/old', MemberNames::PATH => $path8),
114
        );
115
116
        // create a mock configuration
117
        $mockSubjectConfiguration = $this->getMockBuilder('TechDivision\Import\Configuration\SubjectConfigurationInterface')
118
                                         ->setMethods(get_class_methods('TechDivision\Import\Configuration\SubjectConfigurationInterface'))
119
                                         ->getMock();
120
121
        // mock the methods
122
        $mockSubjectConfiguration->expects($this->once())
123
                                 ->method('getDelimiter')
124
                                 ->willReturn(',');
125
126
        // mock the system logger
127
        $mockSystemLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')
128
                                 ->setMethods(get_class_methods('Psr\Log\LoggerInterface'))
129
                                 ->getMock();
130
131
        // the found URL rewrites
132
        $urlRewrites = array(
133
            array(
134
                MemberNames::URL_REWRITE_ID   => 744,
135
                MemberNames::ENTITY_TYPE      => 'product',
136
                MemberNames::ENTITY_ID        => $entityId,
137
                MemberNames::REQUEST_PATH     => sprintf('%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
138
                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s', $entityId),
139
                MemberNames::REDIRECT_TYPE    => 0,
140
                MemberNames::STORE_ID         => 1,
141
                MemberNames::DESCRIPTION      => null,
142
                MemberNames::IS_AUTOGENERATED => 1,
143
                MemberNames::METADATA         => null
144
            ),
145
            array(
146
                MemberNames::URL_REWRITE_ID   => 745,
147
                MemberNames::ENTITY_TYPE      => 'product',
148
                MemberNames::ENTITY_ID        => $entityId,
149
                MemberNames::REQUEST_PATH     => sprintf('old/tops-old/hoodies/%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
150
                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/8', $entityId),
151
                MemberNames::REDIRECT_TYPE    => 0,
152
                MemberNames::STORE_ID         => 1,
153
                MemberNames::DESCRIPTION      => null,
154
                MemberNames::IS_AUTOGENERATED => 1,
155
                MemberNames::METADATA         => serialize(array('category_id' => 8))
156
            ),
157
            array(
158
                MemberNames::URL_REWRITE_ID   => 746,
159
                MemberNames::ENTITY_TYPE      => 'product',
160
                MemberNames::ENTITY_ID        => $entityId,
161
                MemberNames::REQUEST_PATH     => sprintf('collections-old/eco-friendly/%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
162
                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/9', $entityId),
163
                MemberNames::REDIRECT_TYPE    => 0,
164
                MemberNames::STORE_ID         => 1,
165
                MemberNames::DESCRIPTION      => null,
166
                MemberNames::IS_AUTOGENERATED => 1,
167
                MemberNames::METADATA         => serialize(array('category_id' => 9))
168
            )
169
        );
170
171
        // create a mock subject
172
        $mockSubject = $this->getMockBuilder('TechDivision\Import\Product\UrlRewrite\Subjects\UrlRewriteSubject')
173
                            ->setMethods(
174
                                    array(
175
                                        'hasHeader',
176
                                        'getHeader',
177
                                        'getHeaders',
178
                                        'getRootCategory',
179
                                        'getRowStoreId',
180
                                        'getCategory',
181
                                        'getCoreConfigData',
182
                                        'getRow',
183
                                        'hasBeenProcessed',
184
                                        'addEntityIdVisibilityIdMapping',
185
                                        'getEntityIdVisibilityIdMapping',
186
                                        'getStoreViewCode',
187
                                        'isDebugMode',
188
                                        'storeIsActive',
189
                                        'getCategoryByPath',
190
                                        'getSystemLogger'
191
                                    )
192
                                )
193
                                ->disableOriginalConstructor()
194
                                ->getMock();
195
196
        // set the mock configuration on the subject
197
        $mockSubject->setConfiguration($mockSubjectConfiguration);
198
199
        // mock the methods
200
        $mockSubject->expects($this->any())
201
                    ->method('isDebugMode')
202
                    ->willReturn(false);
203
        $mockSubject->expects($this->any())
204
                    ->method('getHeaders')
205
                    ->willReturn($headers);
206
        $mockSubject->expects($this->any())
207
                    ->method('getRow')
208
                    ->willReturn($row);
209
        $mockSubject->expects($this->any())
210
                    ->method('hasHeader')
211
                    ->willReturn(true);
212
        $mockSubject->expects($this->any())
213
                    ->method('getSystemLogger')
214
                    ->willReturn($mockSystemLogger);
215
        $mockSubject->expects($this->any())
216
                    ->method('getHeader')
217
                    ->withConsecutive(
218
                        array(ColumnKeys::SKU),
219
                        array(ColumnKeys::URL_KEY),
220
                        array(ColumnKeys::URL_KEY),
221
                        array(ColumnKeys::STORE_VIEW_CODE),
222
                        array(ColumnKeys::VISIBILITY),
223
                        array(ColumnKeys::CATEGORIES),
224
                        array(ColumnKeys::STORE_VIEW_CODE)
225
                    )
226
                    ->willReturnOnConsecutiveCalls(0, 1, 1, 3, 4, 2, 2);
227
        $mockSubject->expects($this->once())
228
                    ->method('hasBeenProcessed')
229
                    ->willReturn(false);
230
        $mockSubject->expects($this->exactly(3))
231
                    ->method('getCategoryByPath')
232
                    ->withConsecutive(
233
                        array($path4 /* Default Category/Men/Tops/Hoodies & Sweatshirts */),
234
                        array($path6 /* Default Category/Collections/Eco Friendly */),
235
                        array($path1 /* Default Category */)
236
                    )
237
                    ->willReturnOnConsecutiveCalls(
238
                        $categories[$path4],
239
                        $categories[$path6],
240
                        $categories[$path1]
241
                    );
242
        $mockSubject->expects($this->exactly(11))
243
                    ->method('getCategory')
244
                    ->withConsecutive(
245
                        array($categories[$path4][MemberNames::ENTITY_ID]),
246
                        array($categories[$path3][MemberNames::ENTITY_ID]),
247
                        array($categories[$path2][MemberNames::ENTITY_ID]),
248
                        array($categories[$path6][MemberNames::ENTITY_ID]),
249
                        array($categories[$path5][MemberNames::ENTITY_ID]),
250
                        array($categories[$path2][MemberNames::ENTITY_ID]),
251
                        array($categories[$path1][MemberNames::ENTITY_ID]),
252
                        array($categories[$path1][MemberNames::ENTITY_ID]),
253
                        array($categories[$path4][MemberNames::ENTITY_ID]),
254
                        array($categories[$path6][MemberNames::ENTITY_ID]),
255
                        array($categories[$path1][MemberNames::ENTITY_ID])
256
                    )
257
                    ->willReturnOnConsecutiveCalls(
258
                        $categories[$path4],
259
                        $categories[$path3],
260
                        $categories[$path2],
261
                        $categories[$path6],
262
                        $categories[$path5],
263
                        $categories[$path2],
264
                        $categories[$path1],
265
                        $categories[$path1],
266
                        $categories[$path4],
267
                        $categories[$path6],
268
                        $categories[$path1]
269
                    );
270
        $mockSubject->expects($this->any())
271
                    ->method('getRootCategory')
272
                    ->willReturn(array(MemberNames::ENTITY_ID =>  2, MemberNames::PARENT_ID => 1, MemberNames::IS_ANCHOR => null, MemberNames::URL_PATH => null));
273
        $mockSubject->expects($this->once())
274
                    ->method('getStoreViewCode')
275
                    ->with(StoreViewCodes::ADMIN)
276
                    ->willReturn($storeViewCode);
277
        $mockSubject->expects($this->once())
278
                    ->method('storeIsActive')
279
                    ->with($storeViewCode)
280
                    ->willReturn(true);
281
        $mockSubject->expects($this->exactly(4))
282
                    ->method('getEntityIdVisibilityIdMapping')
283
                    ->willReturn(VisibilityKeys::VISIBILITY_BOTH);
284
        $mockSubject->expects($this->any())
285
                    ->method('getRowStoreId')
286
                    ->willReturn($storeId = 1);
287
        $mockSubject->expects($this->exactly(10))
288
                    ->method('getCoreConfigData')
289
                    ->withConsecutive(
290
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_USE_CATEGORIES, false),
291
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
292
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
293
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
294
                        array(CoreConfigDataKeys::CATALOG_SEO_SAVE_REWRITES_HISTORY, true),
295
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
296
                        array(CoreConfigDataKeys::CATALOG_SEO_SAVE_REWRITES_HISTORY, true),
297
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html'),
298
                        array(CoreConfigDataKeys::CATALOG_SEO_SAVE_REWRITES_HISTORY, true),
299
                        array(CoreConfigDataKeys::CATALOG_SEO_PRODUCT_URL_SUFFIX, '.html')
300
                    )
301
                    ->willReturnOnConsecutiveCalls(true, '.html', '.html', '.html', true, '.html', true, '.html', true, '.html', '.html');
302
303
        // mock the processor methods
304
        $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...
305
                    ->method('loadProduct')
306
                    ->with($sku)
307
                    ->willReturn(array(MemberNames::ENTITY_ID => $entityId));
308
        $this->mockProductUrlRewriteProcessor->expects($this->any())
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...
309
                    ->method('loadUrlRewriteProductCategory')
310
                    ->willReturn(array());
311
        $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...
312
                    ->method('getUrlRewritesByEntityTypeAndEntityIdAndStoreId')
313
                    ->with(UrlRewriteObserver::ENTITY_TYPE, $entityId, $storeId)
314
                    ->willReturn($urlRewrites);
315
       $this->mockProductUrlRewriteProcessor->expects($this->exactly(6))
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...
316
                    ->method('persistUrlRewrite')
317
                    ->withConsecutive(
318
                        array(
319
                            array(
320
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE,
321
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
322
                                MemberNames::ENTITY_ID        => $entityId,
323
                                MemberNames::REQUEST_PATH     => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
324
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s', $entityId),
325
                                MemberNames::REDIRECT_TYPE    => 0,
326
                                MemberNames::STORE_ID         => $storeId,
327
                                MemberNames::DESCRIPTION      => null,
328
                                MemberNames::IS_AUTOGENERATED => 1,
329
                                MemberNames::METADATA         => serialize(array())
330
                            )
331
                        ),
332
                        array(
333
                            array(
334
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
335
                                MemberNames::ENTITY_ID        => $entityId,
336
                                MemberNames::REQUEST_PATH     => sprintf('men/tops-men/hoodies-and-sweatshirts-men/%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
337
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/5', $entityId),
338
                                MemberNames::REDIRECT_TYPE    => 0,
339
                                MemberNames::STORE_ID         => $storeId,
340
                                MemberNames::DESCRIPTION      => null,
341
                                MemberNames::IS_AUTOGENERATED => 1,
342
                                MemberNames::METADATA         => serialize(array('category_id' => 5)),
343
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
344
                            )
345
                        ),
346
                        array(
347
                            array(
348
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
349
                                MemberNames::ENTITY_ID        => $entityId,
350
                                MemberNames::REQUEST_PATH     => sprintf('collections/eco-friendly/%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
351
                                MemberNames::TARGET_PATH      => sprintf('catalog/product/view/id/%s/category/7', $entityId),
352
                                MemberNames::REDIRECT_TYPE    => 0,
353
                                MemberNames::STORE_ID         => $storeId,
354
                                MemberNames::DESCRIPTION      => null,
355
                                MemberNames::IS_AUTOGENERATED => 1,
356
                                MemberNames::METADATA         => serialize(array('category_id' => 7)),
357
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
358
                            )
359
                        ),
360
                        array(
361
                            array(
362
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_UPDATE,
363
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
364
                                MemberNames::URL_REWRITE_ID   => 744,
365
                                MemberNames::ENTITY_ID        => $entityId,
366
                                MemberNames::REQUEST_PATH     => sprintf('%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
367
                                MemberNames::TARGET_PATH      => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
368
                                MemberNames::REDIRECT_TYPE    => 301,
369
                                MemberNames::STORE_ID         => $storeId,
370
                                MemberNames::DESCRIPTION      => null,
371
                                MemberNames::IS_AUTOGENERATED => 1,
372
                                MemberNames::METADATA         => serialize(array())
373
                            )
374
                        ),
375
                        array(
376
                            array(
377
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_UPDATE,
378
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
379
                                MemberNames::URL_REWRITE_ID   => 745,
380
                                MemberNames::ENTITY_ID        => $entityId,
381
                                MemberNames::REQUEST_PATH     => sprintf('old/tops-old/hoodies/%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
382
                                MemberNames::TARGET_PATH      => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
383
                                MemberNames::REDIRECT_TYPE    => 301,
384
                                MemberNames::STORE_ID         => $storeId,
385
                                MemberNames::DESCRIPTION      => null,
386
                                MemberNames::IS_AUTOGENERATED => 1,
387
                                MemberNames::METADATA         => serialize(array())
388
                            )
389
                        ),
390
                        array(
391
                            array(
392
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_UPDATE,
393
                                MemberNames::ENTITY_TYPE      => UrlRewriteObserver::ENTITY_TYPE,
394
                                MemberNames::URL_REWRITE_ID   => 746,
395
                                MemberNames::ENTITY_ID        => $entityId,
396
                                MemberNames::REQUEST_PATH     => sprintf('collections-old/eco-friendly/%s-old.html', $row[$headers[ColumnKeys::URL_KEY]]),
397
                                MemberNames::TARGET_PATH      => sprintf('%s.html', $row[$headers[ColumnKeys::URL_KEY]]),
398
                                MemberNames::REDIRECT_TYPE    => 301,
399
                                MemberNames::STORE_ID         => $storeId,
400
                                MemberNames::DESCRIPTION      => null,
401
                                MemberNames::IS_AUTOGENERATED => 1,
402
                                MemberNames::METADATA         => serialize(array())
403
                            )
404
                        )
405
                    )
406
                    ->willReturnOnConsecutiveCalls(1000, 1001, 1002, 1003, 1004, 1005);
407
        $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...
408
                    ->method('persistUrlRewriteProductCategory')
409
                    ->withConsecutive(
410
                        array(
411
                            array(
412
                                MemberNames::URL_REWRITE_ID   => 1000,
413
                                MemberNames::PRODUCT_ID       => $entityId,
414
                                MemberNames::CATEGORY_ID      => 2,
415
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
416
                            )
417
                        ),
418
                        array(
419
                            array(
420
                                MemberNames::URL_REWRITE_ID   => 1001,
421
                                MemberNames::PRODUCT_ID       => $entityId,
422
                                MemberNames::CATEGORY_ID      => 5,
423
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
424
                            )
425
                        ),
426
                        array(
427
                            array(
428
                                MemberNames::URL_REWRITE_ID   => 1002,
429
                                MemberNames::PRODUCT_ID       => $entityId,
430
                                MemberNames::CATEGORY_ID      => 7,
431
                                EntityStatus::MEMBER_NAME     => EntityStatus::STATUS_CREATE
432
                            )
433
                        )
434
                    );
435
436
        // invoke the handle() method
437
        $this->assertSame($row, $this->observer->handle($mockSubject));
438
    }
439
}
440