Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SkuValidatorTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 use PHPUnit\Framework\TestCase;
14 
15 class SkuValidatorTest extends TestCase
16 {
20  private $importer;
21 
25  private $importDataMock;
26 
30  public function setUp()
31  {
32  $this->importDataMock = $this->getMockBuilder(ImportData::class)
33  ->disableOriginalConstructor()
34  ->getMock();
35 
36  $this->importer = Bootstrap::getObjectManager()->create(Sources::class, [
37  'importData' => $this->importDataMock
38  ]);
39  }
40 
47  {
48  // SKU-50000 is a non-existent SKU but should still pass Sku Validation
49  $rowData = $this->buildRowDataArray(
50  'default',
51  'SKU-50000',
52  10,
53  1
54  );
55  $result = $this->importer->validateRow($rowData, 1);
56  $this->assertTrue($result);
57  }
58 
65  {
66  $rowData = $this->buildRowDataArray(
67  'default',
68  'SKU-1',
69  10,
70  1
71  );
72  $result = $this->importer->validateRow($rowData, 1);
73  $this->assertTrue($result);
74  }
75 
84  private function buildRowDataArray($sourceCode, $sku, $qty, $status)
85  {
86  return [
88  Sources::COL_SKU => $sku,
89  Sources::COL_QTY => $qty,
91  ];
92  }
93 }
$sourceCode
Definition: inventory.phtml:11
$status
Definition: order_status.php:8