Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ApplyStockConditionToSelectWithDefaultStockTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider\SelectBuilderForAttribute\
11 ApplyStockConditionToSelect;
14 use PHPUnit\Framework\TestCase;
15 
17 {
21  private $applyStockConditionToSelect;
22 
26  private $resource;
27 
31  protected function setUp()
32  {
33  parent::setUp();
34 
35  $this->resource = Bootstrap::getObjectManager()->get(ResourceConnection::class);
36  $this->applyStockConditionToSelect = Bootstrap::getObjectManager()->get(ApplyStockConditionToSelect::class);
37  }
38 
45  public function testExecute()
46  {
47  $connection = $this->resource->getConnection();
48  $select = $connection->select();
49  $select->from(
50  ['main_table' => $this->resource->getTableName('catalog_product_index_eav')],
51  ['main_table.entity_id', 'main_table.value']
52  )->distinct();
53 
54  $this->applyStockConditionToSelect->execute($select);
55  self::assertEquals(3, count($select->query()->fetchAll()));
56  }
57 }
$connection
Definition: bulk.php:13