Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SuperProductsSkuTest.php
Go to the documentation of this file.
1 <?php
7 
10 use PHPUnit_Framework_MockObject_MockObject as Mock;
11 
17 class SuperProductsSkuTest extends \PHPUnit\Framework\TestCase
18 {
22  private $skuProcessorMock;
23 
27  private $model;
28 
29  protected function setUp()
30  {
31  $this->skuProcessorMock = $this->getMockBuilder(SkuProcessor::class)
32  ->disableOriginalConstructor()
33  ->getMock();
34 
35  $this->model = new SuperProductsSku($this->skuProcessorMock);
36  }
37 
45  public function testIsValid(array $value, array $oldSkus, $hasNewSku = false, $expectedResult = true)
46  {
47  $this->skuProcessorMock->expects($this->once())
48  ->method('getOldSkus')
49  ->willReturn($oldSkus);
50 
51  if ($hasNewSku) {
52  $this->skuProcessorMock->expects($this->once())
53  ->method('getNewSku')
54  ->willReturn('someNewSku');
55  }
56 
57  $this->assertEquals($expectedResult, $this->model->isValid($value));
58  }
59 
63  public function isValidDataProvider()
64  {
65  return [
66  [
67  [],
68  [],
69  ],
70  [
71  [],
72  ['sku1' => []]
73  ],
74  [
75  ['_super_products_sku' => 'SKU1'],
76  ['sku2' => []],
77  false,
78  false
79  ],
80  [
81  ['_super_products_sku' => 'SKU1'],
82  ['sku2' => []],
83  true,
84  true
85  ],
86  [
87  ['_super_products_sku' => 'SKU1'],
88  ['sku1' => []],
89  false,
90  true
91  ],
92  ];
93  }
94 }
return false
Definition: gallery.phtml:36
testIsValid(array $value, array $oldSkus, $hasNewSku=false, $expectedResult=true)
$value
Definition: gender.phtml:16