@@ -70,11 +70,6 @@ class AfterImportDataObserverTest extends \PHPUnit_Framework_TestCase
70
70
*/
71
71
protected $ storeManager ;
72
72
73
- /**
74
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
75
- */
76
- protected $ connection ;
77
-
78
73
/**
79
74
* @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory|\PHPUnit_Framework_MockObject_MockObject
80
75
*/
@@ -90,21 +85,6 @@ class AfterImportDataObserverTest extends \PHPUnit_Framework_TestCase
90
85
*/
91
86
protected $ storeViewService ;
92
87
93
- /**
94
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
95
- */
96
- protected $ eavConfig ;
97
-
98
- /**
99
- * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
100
- */
101
- protected $ resource ;
102
-
103
- /**
104
- * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
105
- */
106
- protected $ select ;
107
-
108
88
/**
109
89
* @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject
110
90
*/
@@ -214,66 +194,6 @@ public function setUp()
214
194
->disableOriginalConstructor ()
215
195
->getMock ();
216
196
217
- $ this ->eavConfig = $ this ->getMock (
218
- '\Magento\Eav\Model\Config ' ,
219
- [
220
- 'getAttribute ' ,
221
- ],
222
- [],
223
- '' ,
224
- false
225
- );
226
- $ attribute = $ this ->getMockBuilder ('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute ' )
227
- ->setMethods ([
228
- 'getBackendTable ' ,
229
- ])
230
- ->disableOriginalConstructor ()
231
- ->getMockForAbstractClass ();
232
- $ beTable = 'backend table ' ;
233
- $ attribute ->expects ($ this ->any ())
234
- ->method ('getBackendTable ' )
235
- ->willReturn ($ beTable );
236
- $ this ->eavConfig ->expects ($ this ->any ())
237
- ->method ('getAttribute ' )
238
- ->with (
239
- \Magento \Catalog \Model \Product::ENTITY ,
240
- \Magento \CatalogUrlRewrite \Observer \AfterImportDataObserver::URL_KEY_ATTRIBUTE_CODE
241
- )
242
- ->willReturn ($ attribute );
243
-
244
- $ this ->resource = $ this ->getMock (
245
- '\Magento\Framework\App\ResourceConnection ' ,
246
- [],
247
- [],
248
- '' ,
249
- false
250
- );
251
- $ this ->connection = $ this ->getMockBuilder ('\Magento\Framework\DB\Adapter\AdapterInterface ' )
252
- ->disableOriginalConstructor ()
253
- ->setMethods ([
254
- 'quoteInto ' ,
255
- 'select ' ,
256
- 'fetchAll ' ,
257
- ])
258
- ->getMockForAbstractClass ();
259
- $ this ->resource
260
- ->expects ($ this ->any ())
261
- ->method ('getConnection ' )
262
- ->willReturn ($ this ->connection );
263
- $ this ->select = $ this ->getMock (
264
- '\Magento\Framework\DB\Select ' ,
265
- [
266
- 'from ' ,
267
- 'where ' ,
268
- ],
269
- [],
270
- '' ,
271
- false
272
- );
273
- $ this ->connection
274
- ->expects ($ this ->any ())
275
- ->method ('select ' )
276
- ->willReturn ($ this ->select );
277
197
$ this ->objectRegistryFactory = $ this ->getMock (
278
198
'\Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory ' ,
279
199
[],
@@ -364,10 +284,8 @@ public function setUp()
364
284
'\Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver ' ,
365
285
[
366
286
'catalogProductFactory ' => $ this ->catalogProductFactory ,
367
- 'eavConfig ' => $ this ->eavConfig ,
368
287
'objectRegistryFactory ' => $ this ->objectRegistryFactory ,
369
288
'productUrlPathGenerator ' => $ this ->productUrlPathGenerator ,
370
- 'resource ' => $ this ->resource ,
371
289
'storeViewService ' => $ this ->storeViewService ,
372
290
'storeManager ' => $ this ->storeManager ,
373
291
'urlPersist ' => $ this ->urlPersist ,
@@ -471,7 +389,6 @@ public function testAfterImportData()
471
389
$ newSku [0 ]['entity_id ' ],
472
390
$ newSku [0 ]['entity_id ' ],
473
391
$ newSku [0 ]['entity_id ' ],
474
- $ newSku [0 ]['entity_id ' ],
475
392
$ newSku [1 ]['entity_id ' ],
476
393
$ newSku [1 ]['entity_id ' ],
477
394
$ newSku [1 ]['entity_id ' ]
@@ -501,33 +418,6 @@ public function testAfterImportData()
501
418
->expects ($ this ->exactly ($ productsCount ))
502
419
->method ('create ' )
503
420
->willReturn ($ product );
504
- $ this ->connection
505
- ->expects ($ this ->exactly (4 ))
506
- ->method ('quoteInto ' )
507
- ->withConsecutive (
508
- [
509
- '(store_id = ? ' ,
510
- $ storeIds [0 ],
511
- ],
512
- [
513
- ' AND entity_id = ?) ' ,
514
- $ newSku [0 ]['entity_id ' ],
515
- ],
516
- [
517
- '(store_id = ? ' ,
518
- $ storeIds [0 ],
519
- ],
520
- [
521
- ' AND entity_id = ?) ' ,
522
- $ newSku [1 ]['entity_id ' ],
523
- ]
524
- );
525
- $ this ->connection
526
- ->expects ($ this ->once ())
527
- ->method ('fetchAll ' )
528
- ->willReturn ([]);
529
- $ this ->select ->expects ($ this ->any ())->method ('from ' )->willReturnSelf ();
530
- $ this ->select ->expects ($ this ->any ())->method ('where ' )->willReturnSelf ();
531
421
532
422
$ this ->urlFinder ->expects ($ this ->any ())->method ('findAllByData ' )->willReturn ([]);
533
423
@@ -562,78 +452,6 @@ public function testAfterImportData()
562
452
$ this ->import ->execute ($ this ->observer );
563
453
}
564
454
565
- /**
566
- * Cover cleanOverriddenUrlKey().
567
- */
568
- public function testCleanOverriddenUrlKey ()
569
- {
570
- $ urlKeyAttributeBackendTable = 'table value ' ;
571
- $ urlKeyAttributeId = 'id value ' ;
572
- $ entityStoresToCheckOverridden = [1 ,2 ,3 ];
573
- $ this ->import ->urlKeyAttributeBackendTable = $ urlKeyAttributeBackendTable ;
574
- $ this ->import ->urlKeyAttributeId = $ urlKeyAttributeId ;
575
- $ this ->setPropertyValue ($ this ->import , 'entityStoresToCheckOverridden ' , $ entityStoresToCheckOverridden );
576
- $ this ->select
577
- ->expects ($ this ->once ())
578
- ->method ('from ' )
579
- ->with (
580
- $ urlKeyAttributeBackendTable ,
581
- ['store_id ' , 'entity_id ' ]
582
- )
583
- ->will ($ this ->returnSelf ());
584
- $ this ->select
585
- ->expects ($ this ->exactly (2 ))
586
- ->method ('where ' )
587
- ->withConsecutive (
588
- [
589
- 'attribute_id = ? ' ,
590
- $ urlKeyAttributeId ,
591
- ],
592
- [
593
- implode (' OR ' , $ entityStoresToCheckOverridden )
594
- ]
595
- )
596
- ->will ($ this ->returnSelf ());
597
-
598
- $ entityIdVal = 'entity id value ' ;
599
- $ storeIdVal = 'store id value ' ;
600
- $ entityStore = [
601
- 'entity_id ' => $ entityIdVal ,
602
- 'store_id ' => $ storeIdVal ,
603
- ];
604
- $ entityStoresToClean = [$ entityStore ];
605
- $ products = [
606
- $ entityIdVal => [
607
- $ storeIdVal => 'value ' ,
608
- ]
609
- ];
610
- $ this ->setPropertyValue ($ this ->import , 'products ' , $ products );
611
- $ this ->connection
612
- ->expects ($ this ->once ())
613
- ->method ('fetchAll ' )
614
- ->willReturn ($ entityStoresToClean );
615
-
616
- $ actualResult = $ this ->invokeMethod ($ this ->import , 'cleanOverriddenUrlKey ' );
617
- $ this ->assertEquals ($ this ->import , $ actualResult );
618
- }
619
-
620
- /**
621
- * Cover cleanOverriddenUrlKey() method with empty entityStoresToCheckOverridden property.
622
- */
623
- public function testCleanOverriddenUrlKeyEmptyEntityStoresToCheckOverridden ()
624
- {
625
- $ this ->setPropertyValue ($ this ->import , 'entityStoresToCheckOverridden ' , null );
626
- $ this ->select
627
- ->expects ($ this ->never ())
628
- ->method ('from ' );
629
- $ this ->select
630
- ->expects ($ this ->never ())
631
- ->method ('where ' );
632
-
633
- $ actualResult = $ this ->invokeMethod ($ this ->import , 'cleanOverriddenUrlKey ' );
634
- $ this ->assertEquals ($ this ->import , $ actualResult );
635
- }
636
-
637
455
/**
638
456
* Cover canonicalUrlRewriteGenerate().
639
457
*/
@@ -848,30 +666,6 @@ protected function invokeMethod($object, $methodName, array $parameters = [])
848
666
return $ method ->invokeArgs ($ object , $ parameters );
849
667
}
850
668
851
- /**
852
- * Get mock of Import class instance with defined methods and called constructor.
853
- */
854
- protected function getImportMock ($ methods = [])
855
- {
856
- return $ this ->getMock (
857
- '\Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver ' ,
858
- $ methods ,
859
- [
860
- $ this ->catalogProductFactory ,
861
- $ this ->eavConfig ,
862
- $ this ->objectRegistryFactory ,
863
- $ this ->productUrlPathGenerator ,
864
- $ this ->resource ,
865
- $ this ->storeViewService ,
866
- $ this ->storeManager ,
867
- $ this ->urlPersist ,
868
- $ this ->urlRewriteFactory ,
869
- $ this ->urlFinder ,
870
- ],
871
- ''
872
- );
873
- }
874
-
875
669
/**
876
670
* @param mixed $storeId
877
671
* @param mixed $productId
0 commit comments