Beispiel #1
0
 public function testAddIndices()
 {
     $client = new Elastica_Client();
     $search = new Elastica_Search($client);
     $indices = array();
     $indices[] = $client->getIndex('elastica_test1');
     $indices[] = $client->getIndex('elastica_test2');
     $search->addIndices($indices);
     $this->assertEquals(2, count($search->getIndices()));
 }
 public function testAddIndex()
 {
     $client = new Elastica_Client();
     $search = new Elastica_Search($client);
     $index1 = $client->getIndex('test1');
     $index1->create(array(), true);
     $index2 = $client->getIndex('test2');
     $index2->create(array(), true);
     $search->addIndex($index1);
     $indices = $search->getIndices();
     $this->assertEquals(1, count($indices));
     $search->addIndex($index2);
     $indices = $search->getIndices();
     $this->assertEquals(2, count($indices));
     $this->assertTrue(in_array($index1->getName(), $indices));
     $this->assertTrue(in_array($index2->getName(), $indices));
     // Add string
     $search->addIndex('test3');
     $indices = $search->getIndices();
     $this->assertEquals(3, count($indices));
     $this->assertTrue(in_array('test3', $indices));
 }