Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetDefaultSourceItemBySkuTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 use PHPUnit\Framework\TestCase;
13 
14 class GetDefaultSourceItemBySkuTest extends TestCase
15 {
19  private $getDefaultSourceItemBySku;
20 
21  protected function setUp()
22  {
23  parent::setUp();
24  $this->getDefaultSourceItemBySku = Bootstrap::getObjectManager()->get(GetDefaultSourceItemBySku::class);
25  }
26 
32  public function testExecuteOnDefaultSource()
33  {
34  self::assertNotNull(
35  $this->getDefaultSourceItemBySku->execute('SKU-1'),
36  'Unable to find default source_item for a product assigned to Default source only'
37  );
38  self::assertNotNull(
39  $this->getDefaultSourceItemBySku->execute('SKU-2'),
40  'Unable to find default source_item for a product assigned to Default source and others'
41  );
42  }
43 
50  {
51  self::assertNull(
52  $this->getDefaultSourceItemBySku->execute('SKU-1'),
53  'Returned a wrong default source_item for a product assigned elsewhere'
54  );
55  }
56 }