public function testProductThatWasIndexedIsUnindexedEvenIfChangedButNotFlushed() { $product = new Entity\ProductWithConditionalIndexing(); $product->setName('I\'m a pathological case.')->setPrice(10)->setShortDescription('Aww\'right'); $this->persistAndFlush($product); // Check we indexed the product OK. $this->assertNotEmpty($this->getIndexer()->creations); // This would normally prevent indexing $product->setPrice(0); $this->getIndexer()->reset(); $objectID = $this->getObjectID(['id' => $product->getId()]); $this->removeAndFlush($product); // But since the engine is clever, it should notice that // even though the condition for indexing is now false, // it was true when the object was last synced with the DB, // so it will unindex it. $this->assertEquals(array(metaenv('ProductWithConditionalIndexing_dev') => array($objectID)), $this->getIndexer()->deletions); }
public function testNonAutoIndexedProductIsManuallyIndexed() { $indexer = $this->getIndexer(); $product = new Entity\ProductWithoutAutoIndex(); $product->setName('This Product Is Not Auto Indexed, But I\'ll Index It')->setDescription('Yes, I\'m clever like that.'); $indexer->reset(); $this->assertEquals(array(), $indexer->updates); $this->persistAndFlush($product); $this->assertEquals(array(), $indexer->updates); $id = $product->getId(); $indexer->getManualIndexer($this->getEntityManager())->index($product); $this->assertEquals(array(), $indexer->deletions); $this->assertEquals(array(), $indexer->updates); $this->assertEquals(array(metaenv('ProductWithoutAutoIndex_dev') => array(array('name' => 'This Product Is Not Auto Indexed, But I\'ll Index It', 'objectID' => $this->getObjectID(['id' => $id])))), $indexer->creations); $indexer->reset(); $indexer->getManualIndexer($this->getEntityManager())->unIndex($product); $this->assertEquals(array(metaenv('ProductWithoutAutoIndex_dev') => array($this->getObjectID(['id' => $id]))), $indexer->deletions); $this->assertEquals(array(), $indexer->updates); }
public function testIndexWouldBeCreated() { $output = $this->runCommand(); $this->assertContains('We found 1 index(es) that may need updating.', $output); $this->assertContains('Found a new local index ' . metaenv('ProductForAlgoliaIntegrationTest_dev'), $output); }
public function makeEnvIndexName($indexName, $perEnvironment) { return metaenv(parent::makeEnvIndexName($indexName, $perEnvironment)); }
public function testCustomAlgoliaNamesAreTakenIntoAccount() { $product = new Entity\ProductWithCustomAttributeNames(); $product->setName('Hello World.'); $this->persistAndFlush($product); $this->assertEquals([metaenv('nonDefaultIndexName_dev') => [['objectID' => $this->getObjectID(['id' => $product->getId()]), 'nonDefaultAttributeName' => 'Hello World.']]], $this->getIndexer()->creations); }