private function setUpIndex() { $indexName = $this->indexName; $schema = $this->getSchemaType(); $index = new YokozunaIndex($indexName, $schema); $store = StoreIndex::builder()->withIndex($index)->build(); $fetch = FetchIndex::builder()->withIndexName($indexName)->build(); try { $this->client->execute($fetch); } catch (\Exception $exc) { $this->client->execute($store); TestHelper::retryCommand($this->client, $fetch, 20); } }
/** * @deprecated * * not worth functional testing * Riak will fail to fetch the index for a couple seconds after store */ public function testStoreAndFetchIndex() { $indexName = 'schedule_' . uniqid(); $index = new YokozunaIndex($indexName, '_yz_default'); $index->setNVal(3); $store = StoreIndex::builder()->withIndex($index)->build(); $fetch = FetchIndex::builder()->withIndexName($indexName)->build(); $delete = DeleteIndex::builder()->withIndexName($indexName)->build(); $storeResponse = $this->client->execute($store); $fetchResponse = $this->retryCommand($fetch, 10); $deleteResponse = $this->client->execute($delete); $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreIndexResponse', $storeResponse); $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchIndexResponse', $fetchResponse); $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\DeleteIndexResponse', $deleteResponse); }
public function testExecuteCommand() { $response = new GetIndexResponse(); $command = FetchIndex::builder()->withIndexName('index-name')->build(); $response->nVal = 10; $response->name = 'index-name'; $response->schema = 'schema-name'; $callback = function ($subject) { $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\GetIndexRequest', $subject); $this->assertEquals('index-name', $subject->name); return true; }; $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response)); $result = $this->client->execute($command); $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchIndexResponse', $result); $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Search\\YokozunaIndex', $result->getIndex()); $this->assertEquals('schema-name', $result->getIndex()->getSchema()); $this->assertEquals('index-name', $result->getIndex()->getName()); $this->assertEquals(10, $result->getIndex()->getNVal()); }