public function testBuildWithoutOutOfStock()
 {
     $tableSuffix = 'index_default';
     $index = 'test_index_name';
     $this->mockBuild($index, $tableSuffix);
     $this->config->expects($this->once())->method('isSetFlag')->with('cataloginventory/options/show_out_of_stock')->will($this->returnValue(false));
     $this->adapter->expects($this->once())->method('quoteInto')->with(' AND stock_index.website_id = ?', 1)->willReturn(' AND stock_index.website_id = 1');
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website);
     $this->select->expects($this->at(4))->method('joinLeft')->with(['stock_index' => 'cataloginventory_stock_status'], 'search_index.product_id = stock_index.product_id' . ' AND stock_index.website_id = 1', [])->will($this->returnSelf());
     $this->select->expects($this->once())->method('where')->with('stock_index.stock_status = ?', 1)->will($this->returnSelf());
     $result = $this->target->build($this->request);
     $this->assertSame($this->select, $result);
 }
Exemple #2
0
 public function testBuildWithoutOutOfStock()
 {
     $tableSuffix = '_table';
     $index = 'test_index_name';
     $this->request->expects($this->once())->method('getIndex')->will($this->returnValue($index));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($index) use($tableSuffix) {
         return $index . $tableSuffix;
     }));
     $this->select->expects($this->once())->method('from')->with(['search_index' => $index . $tableSuffix], ['entity_id' => 'search_index.product_id'])->will($this->returnSelf());
     $this->select->expects($this->at(1))->method('joinLeft')->with(['category_index' => 'catalog_category_product_index' . $tableSuffix], 'search_index.product_id = category_index.product_id' . ' AND search_index.store_id = category_index.store_id', [])->will($this->returnSelf());
     $this->config->expects($this->once())->method('isSetFlag')->with('cataloginventory/options/show_out_of_stock')->will($this->returnValue(false));
     $this->adapter->expects($this->once())->method('quoteInto')->with(' AND stock_index.website_id = ?', 1)->willReturn(' AND stock_index.website_id = 1');
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website);
     $this->select->expects($this->at(2))->method('joinLeft')->with(['stock_index' => 'cataloginventory_stock_status' . $tableSuffix], 'search_index.product_id = stock_index.product_id' . ' AND stock_index.website_id = 1', [])->will($this->returnSelf());
     $this->select->expects($this->once())->method('where')->with('stock_index.stock_status = ?', 1)->will($this->returnSelf());
     $result = $this->target->build($this->request);
     $this->assertSame($this->select, $result);
 }
Exemple #3
0
 public function testBuildWithoutOutOfStock()
 {
     $scopeId = '113';
     $tableSuffix = 'scope113_someNamesomeValue';
     $index = 'test_index_name';
     $dimensions = [$this->createDimension('scope', $scopeId), $this->createDimension('someName', 'someValue')];
     $this->request->expects($this->exactly(2))->method('getDimensions')->willReturn($dimensions);
     $this->mockBuild($index, $tableSuffix, false);
     $this->config->expects($this->once())->method('isSetFlag')->with('cataloginventory/options/show_out_of_stock')->will($this->returnValue(false));
     $this->adapter->expects($this->once())->method('quoteInto')->with(' AND stock_index.website_id = ?', 1)->willReturn(' AND stock_index.website_id = 1');
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website);
     $this->select->expects($this->at(2))->method('where')->with('(someName=someValue)')->willReturnSelf();
     $this->select->expects($this->at(3))->method('joinLeft')->with(['stock_index' => 'cataloginventory_stock_status'], 'search_index.entity_id = stock_index.product_id' . ' AND stock_index.website_id = 1', [])->willReturnSelf();
     $this->select->expects($this->at(4))->method('where')->with('stock_index.stock_status = ?', 1)->will($this->returnSelf());
     $result = $this->target->build($this->request);
     $this->assertSame($this->select, $result);
 }