Пример #1
0
 public function testAddFiltersVerifyAddConditionsToRegistry()
 {
     $registry = new \Magento\Framework\Registry();
     $values = array('sku' => 'simple');
     $this->skuAttribute->expects($this->once())->method('getTable')->will($this->returnValue('catalog_product_entity'));
     $this->collection->expects($this->any())->method('addAttributeToSelect')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('setStore')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addMinimalPrice')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addTaxPercents')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addStoreFilter')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('setVisibility')->will($this->returnSelf());
     $this->resource->expects($this->any())->method('prepareCondition')->will($this->returnValue(array('like' => '%simple%')));
     $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('entity_id'));
     $this->engine->expects($this->any())->method('getResource')->will($this->returnValue($this->resource));
     $this->engine->expects($this->any())->method('getAdvancedResultCollection')->will($this->returnValue($this->collection));
     $this->engineProvider->expects($this->any())->method('get')->will($this->returnValue($this->engine));
     $this->attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue('sku'));
     $this->attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue('SKU'));
     $this->attribute->expects($this->any())->method('getFrontendInput')->will($this->returnValue('text'));
     $this->attribute->expects($this->any())->method('getBackend')->will($this->returnValue($this->skuAttribute));
     $this->attribute->expects($this->any())->method('getBackendType')->will($this->returnValue('static'));
     $this->dataCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator(array($this->attribute))));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     /** @var \Magento\CatalogSearch\Model\Advanced $instance */
     $instance = $objectManager->getObject('Magento\\CatalogSearch\\Model\\Advanced', array('registry' => $registry, 'engineProvider' => $this->engineProvider, 'data' => array('attributes' => $this->dataCollection)));
     $instance->addFilters($values);
     $this->assertNotNull($registry->registry('advanced_search_conditions'));
 }
Пример #2
0
 public function testReindexAll()
 {
     $this->engine->cleanIndex();
     $this->indexer->reindexAll();
     $products = $this->search('Simple Product First');
     $this->assertCount(1, $products);
     $this->assertEquals($this->productFirst->getId(), $products[0]->getId());
     $products = $this->search('Simple Product');
     $this->assertCount(2, $products);
     $this->assertEquals($this->productFirst->getId(), $products[0]->getId());
     $this->assertEquals($this->productSecond->getId(), $products[1]->getId());
 }