/** * @dataProvider saveEntityIndexesDataProvider */ public function testSaveEntityIndexes($storeId, $entityIndexes, $expected) { if ($expected) { $this->connection->expects($this->once())->method('insertOnDuplicate')->with(null, $expected, ['data_index'])->willReturnSelf(); } $this->target->saveEntityIndexes($storeId, $entityIndexes); }
public function testReindexAll() { $this->engine->cleanIndex(); $this->indexer->reindexAll(); $products = $this->search('Apple'); $this->assertCount(1, $products); $this->assertEquals($this->productApple->getId(), $products[0]->getId()); $products = $this->search('Simple Product'); $this->assertCount(5, $products); $this->assertEquals($this->productApple->getId(), $products[0]->getId()); $this->assertEquals($this->productBanana->getId(), $products[1]->getId()); $this->assertEquals($this->productOrange->getId(), $products[2]->getId()); $this->assertEquals($this->productPapaya->getId(), $products[3]->getId()); $this->assertEquals($this->productCherry->getId(), $products[4]->getId()); }
/** * Retrieve attribute source value for search * * @param int $attributeId * @param mixed $valueId * @param int $storeId * @return mixed */ protected function getAttributeValue($attributeId, $valueId, $storeId) { $attribute = $this->getSearchableAttribute($attributeId); $value = $this->engine->processAttributeValue($attribute, $valueId); if ($attribute->getIsSearchable() && $attribute->usesSource() && $this->engine->allowAdvancedIndex()) { $attribute->setStoreId($storeId); $valueText = $attribute->getSource()->getIndexOptionText($valueId); if (is_array($valueText)) { $value .= $this->separator . implode($this->separator, $valueText); } else { $value .= $this->separator . $valueText; } } $value = preg_replace('/\\s+/siu', ' ', trim(strip_tags($value))); return $value; }
/** * @param null|string $expected * @param array $data * @dataProvider prepareEntityIndexDataProvider */ public function testPrepareEntityIndex($expected, array $data) { $this->assertEquals($expected, $this->target->prepareEntityIndex($data['index'], $data['separator'])); }