public function testAddTypes() { $client = new Elastica_Client(); $search = new Elastica_Search($client); $index = $this->_createIndex(); $types = array(); $types[] = $index->getType('type1'); $types[] = $index->getType('type2'); $search->addTypes($types); $this->assertEquals(2, count($search->getTypes())); }
public function testAddType() { $client = new Elastica_Client(); $search = new Elastica_Search($client); $index = $client->getIndex('test1'); $index->create(array(), true); $type1 = $index->getType('type1'); $type2 = $index->getType('type2'); $this->assertEquals(array(), $search->getTypes()); $search->addType($type1); $types = $search->getTypes(); $this->assertEquals(1, count($types)); $search->addType($type2); $types = $search->getTypes(); $this->assertEquals(2, count($types)); $this->assertTrue(in_array($type1->getName(), $types)); $this->assertTrue(in_array($type2->getName(), $types)); // Add string $search->addType('test3'); $types = $search->getTypes(); $this->assertEquals(3, count($types)); $this->assertTrue(in_array('test3', $types)); }