Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InStockOptionSelectBuilderTest.php
Go to the documentation of this file.
1 <?php
8 
14 
15 class InStockOptionSelectBuilderTest extends \PHPUnit\Framework\TestCase
16 {
20  private $model;
21 
25  private $objectManagerHelper;
26 
30  private $stockStatusResourceMock;
31 
35  private $optionSelectBuilderMock;
36 
40  private $selectMock;
41 
42  protected function setUp()
43  {
44  $this->stockStatusResourceMock = $this->getMockBuilder(Status::class)
45  ->disableOriginalConstructor()
46  ->getMock();
47 
48  $this->selectMock = $this->getMockBuilder(Select::class)
49  ->disableOriginalConstructor()
50  ->getMock();
51 
52  $this->optionSelectBuilderMock = $this->getMockBuilder(OptionSelectBuilder::class)
53  ->setMethods([])
54  ->disableOriginalConstructor()
55  ->getMock();
56 
57  $this->objectManagerHelper = new ObjectManager($this);
58  $this->model = $this->objectManagerHelper->getObject(
59  InStockOptionSelectBuilder::class,
60  [
61  'stockStatusResource' => $this->stockStatusResourceMock,
62  ]
63  );
64  }
65 
69  public function testAfterGetSelect()
70  {
71  $this->stockStatusResourceMock->expects($this->once())
72  ->method('getMainTable')
73  ->willReturn('stock_table_name');
74 
75  $this->selectMock->expects($this->once())
76  ->method('joinInner')
77  ->willReturnSelf();
78  $this->selectMock->expects($this->once())
79  ->method('where')
80  ->willReturnSelf();
81 
82  $this->assertEquals(
83  $this->selectMock,
84  $this->model->afterGetSelect($this->optionSelectBuilderMock, $this->selectMock)
85  );
86  }
87 }