public function testAttachConditionToCollection()
 {
     $collection = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', ['getResource', 'getSelect'], [], '', false);
     $combine = $this->getMock('\\Magento\\Rule\\Model\\Condition\\Combine', ['getConditions'], [], '', false);
     $resource = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['getConnection'], [], '', false);
     $select = $this->getMock('\\Magento\\Framework\\DB\\Select', ['where'], [], '', false);
     $select->expects($this->never())->method('where');
     $connection = $this->getMockForAbstractClass('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], '', false);
     $collection->expects($this->once())->method('getResource')->will($this->returnValue($resource));
     $collection->expects($this->any())->method('getSelect')->will($this->returnValue($select));
     $resource->expects($this->once())->method('getConnection')->will($this->returnValue($connection));
     $combine->expects($this->any())->method('getConditions')->will($this->returnValue([]));
     $this->_builder->attachConditionToCollection($collection, $combine);
 }
 /**
  * Prepare and return product collection
  *
  * @return \Magento\Catalog\Model\Resource\Product\Collection
  */
 public function createCollection()
 {
     /** @var $collection \Magento\Catalog\Model\Resource\Product\Collection */
     $collection = $this->productCollectionFactory->create();
     $collection->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds());
     $collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter()->setPageSize($this->getProductsPerPage())->setCurPage($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1));
     $conditions = $this->getConditions();
     $conditions->collectValidatedAttributes($collection);
     $this->sqlBuilder->attachConditionToCollection($collection, $conditions);
     return $collection;
 }