예제 #1
0
 /**
  * Get the currentType
  *
  * @param      $type
  * @param bool $createNew
  *
  * @return \Elastica\Type
  */
 public function getType($type, $createNew = false)
 {
     $this->_type = $this->_index->getType($type);
     if ($createNew == true && $this->_type->exists() == true) {
         $this->_type->delete();
     }
     return $this->_type;
 }
예제 #2
0
 /**
  * @test
  */
 public function doFlush()
 {
     $this->type->delete()->shouldBeCalled();
     self::assertTrue($this->cache->flushAll());
     $refClass = new \ReflectionClass($this->cache);
     $typeProp = $refClass->getProperty('type');
     $typeProp->setAccessible(true);
     $typeVal = $typeProp->getValue($this->cache);
     self::assertNull($typeVal);
 }
 /**
  * @param string $typeName
  * @return \Elastica\Type
  * @throws \Exception
  */
 protected function deleteMapping($typeName)
 {
     $type = new Elastica\Type($this->index, $typeName);
     if ($type->exists()) {
         try {
             $type->delete();
         } catch (\Exception $e) {
             throw new \Exception('Could not delete type ' . $type->getName() . '');
         }
     }
     $type = new Elastica\Type($this->index, $typeName);
     return $type;
 }
예제 #4
0
 /**
  * Test that Delete of index type throw deprecated exception.
  *
  * @group unit
  * @expectedException \Elastica\Exception\DeprecatedException
  */
 public function testDeleteType()
 {
     $type = new Type($this->getMockBuilder('Elastica\\Index')->disableOriginalConstructor()->getMock(), 'test');
     $type->delete();
 }
예제 #5
0
파일: TypeTest.php 프로젝트: kskod/Elastica
 /**
  * Test Delete of index type.  After delete will check for type mapping.
  * @expectedException \Elastica\Exception\ResponseException
  * @expectedExceptionMessage TypeMissingException[[elastica_test] type[test] missing]
  */
 public function testDeleteType()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'test');
     $type->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
     $type->addDocument(new Document(2, array('name' => 'ruflin')));
     $index->refresh();
     $type->delete();
     $type->getMapping();
 }
예제 #6
0
 /**
  * Test Delete of index type.  After delete will check for type mapping.
  *
  * @group functional
  */
 public function testDeleteType()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'test');
     $type->addDocuments(array(new Document(1, array('name' => 'ruflin nicolas')), new Document(2, array('name' => 'ruflin'))));
     $index->refresh();
     // sleep a moment to be sure that all nodes in cluster has new type
     sleep(5);
     $type->delete();
     $index->optimize();
     $this->assertFalse($type->exists());
 }