/**
  * set up
  *
  * @return void
  */
 public function setUp()
 {
     $repo = m::mock('Xpressengine\\Document\\RepositoryInterface');
     $configHandler = m::mock('Xpressengine\\Document\\ConfigHandler');
     $this->repo = $repo;
     $this->configHandler = $configHandler;
     $conn = m::mock('Xpressengine\\Database\\VirtualConnectionInterface');
     $conn->shouldReceive('beginTransaction');
     $conn->shouldReceive('commit');
     $this->repo->shouldReceive('connection')->andReturn($conn);
 }
 /**
  * drop instance
  *
  * @param ConfigEntity $config     현재 설정 되어 있는 config
  * @param int          $fetchCount fetch count
  * @return void
  */
 public function remove(ConfigEntity $config, $fetchCount = 10)
 {
     $this->repo->connection()->beginTransaction();
     $this->repo->dropDivisionTable($config);
     $this->configHandler->remove($config);
     // division table 은 drop 했으므로 처리하지 않는다.
     $config->set('division', false);
     while ($docs = $this->repo->fetch(['instanceId' => $config->get('instanceId')], null, $config, $fetchCount)) {
         foreach ($docs as $doc) {
             $this->repo->delete(new DocumentEntity($doc), $config);
         }
     }
     $this->repo->connection()->commit();
 }
 /**
  * 덧글의 depth 반환
  *
  * @param DocumentEntity $doc document entity
  * @return float
  */
 public function getDepth(DocumentEntity $doc)
 {
     return strlen($doc->reply) / $this->repo->getReplyHelper()->getReplyCharLen();
 }