6
6
7
7
namespace Magento \DownloadableImportExport \Test \Unit \Model \Import \Product \Type ;
8
8
9
+ use Magento \Downloadable \Model \Url \DomainValidator ;
9
10
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManager ;
10
11
11
12
/**
@@ -39,6 +40,11 @@ class DownloadableTest extends \Magento\ImportExport\Test\Unit\Model\Import\Abst
39
40
*/
40
41
protected $ prodAttrColFacMock ;
41
42
43
+ /**
44
+ * @var DomainValidator
45
+ */
46
+ private $ domainValidator ;
47
+
42
48
/**
43
49
* @var \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection|\PHPUnit_Framework_MockObject_MockObject
44
50
*/
@@ -498,7 +504,7 @@ public function dataForSave()
498
504
/**
499
505
* @dataProvider isRowValidData
500
506
*/
501
- public function testIsRowValid (array $ rowData , $ rowNum , $ isNewProduct = true )
507
+ public function testIsRowValid (array $ rowData , $ rowNum , $ isNewProduct, $ isDomainValid , $ expectedResult )
502
508
{
503
509
$ this ->connectionMock ->expects ($ this ->any ())->method ('fetchAll ' )->with (
504
510
$ this ->select
@@ -514,6 +520,13 @@ public function testIsRowValid(array $rowData, $rowNum, $isNewProduct = true)
514
520
],
515
521
]
516
522
);
523
+
524
+ $ this ->domainValidator = $ this ->createMock (DomainValidator::class);
525
+ $ this ->domainValidator
526
+ ->expects ($ this ->any ())->method ('isValid ' )
527
+ ->withAnyParameters ()
528
+ ->willReturn ($ isDomainValid );
529
+
517
530
$ this ->downloadableModelMock = $ this ->objectManagerHelper ->getObject (
518
531
\Magento \DownloadableImportExport \Model \Import \Product \Type \Downloadable::class,
519
532
[
@@ -522,11 +535,12 @@ public function testIsRowValid(array $rowData, $rowNum, $isNewProduct = true)
522
535
'resource ' => $ this ->resourceMock ,
523
536
'params ' => $ this ->paramsArray ,
524
537
'uploaderHelper ' => $ this ->uploaderHelper ,
525
- 'downloadableHelper ' => $ this ->downloadableHelper
538
+ 'downloadableHelper ' => $ this ->downloadableHelper ,
539
+ 'domainValidator ' => $ this ->domainValidator
526
540
]
527
541
);
528
542
$ result = $ this ->downloadableModelMock ->isRowValid ($ rowData , $ rowNum , $ isNewProduct );
529
- $ this ->assertNotNull ( $ result );
543
+ $ this ->assertEquals ( $ expectedResult , $ result );
530
544
}
531
545
532
546
/**
@@ -550,6 +564,8 @@ public function isRowValidData()
550
564
. 'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0 ' ,
551
565
],
552
566
0 ,
567
+ true ,
568
+ true ,
553
569
true
554
570
],
555
571
[
@@ -564,15 +580,8 @@ public function isRowValidData()
564
580
. ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0 ' ,
565
581
],
566
582
1 ,
567
- true
568
- ],
569
- [
570
- [
571
- 'sku ' => 'downloadablesku12 ' ,
572
- 'product_type ' => 'downloadable ' ,
573
- 'name ' => 'Downloadable Product 2 ' ,
574
- ],
575
- 2 ,
583
+ true ,
584
+ true ,
576
585
true
577
586
],
578
587
[
@@ -587,20 +596,24 @@ public function isRowValidData()
587
596
. ' url=media/file2.mp4,sortorder=0 ' ,
588
597
],
589
598
3 ,
599
+ true ,
600
+ true ,
590
601
true
591
602
],
592
603
[
593
604
[
594
605
'sku ' => 'downloadablesku12 ' ,
595
606
'product_type ' => 'downloadable ' ,
596
607
'name ' => 'Downloadable Product 2 ' ,
597
- 'downloadable_samples ' => 'file=media/file.mp4,sortorder=1|group_title=Group Title, '
598
- . ' url=media/file2.mp4,sortorder=0 ' ,
608
+ 'downloadable_samples ' => 'title=Title 1, file=media/file.mp4,sortorder=1|title= Title 2, ' .
609
+ ' group_title=Group Title, url=media/file2.mp4,sortorder=0 ' ,
599
610
'downloadable_links ' => 'title=Title 1, price=10, downloads=unlimited, file=media/file.mp4, '
600
611
. 'sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads=unlimited, '
601
612
. ' url=media/file2.mp4,sortorder=0 ' ,
602
613
],
603
614
4 ,
615
+ true ,
616
+ true ,
604
617
true
605
618
],
606
619
[ //empty group title samples
@@ -615,6 +628,8 @@ public function isRowValidData()
615
628
. ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0 ' ,
616
629
],
617
630
5 ,
631
+ true ,
632
+ true ,
618
633
true
619
634
],
620
635
[ //empty group title links
@@ -629,6 +644,19 @@ public function isRowValidData()
629
644
. 'downloads=unlimited, url=media/file2.mp4,sortorder=0 ' ,
630
645
],
631
646
6 ,
647
+ true ,
648
+ true ,
649
+ true
650
+ ],
651
+ [
652
+ [
653
+ 'sku ' => 'downloadablesku12 ' ,
654
+ 'product_type ' => 'downloadable ' ,
655
+ 'name ' => 'Downloadable Product 2 ' ,
656
+ ],
657
+ 2 ,
658
+ false ,
659
+ true ,
632
660
true
633
661
],
634
662
[
@@ -640,7 +668,9 @@ public function isRowValidData()
640
668
'downloadable_links ' => '' ,
641
669
],
642
670
7 ,
643
- true
671
+ true ,
672
+ true ,
673
+ false
644
674
],
645
675
];
646
676
}
0 commit comments