/** * 문서 휴지통 이동 * * @param ItemEntity $item board item entity * @param ConfigEntity $config destination board config entity * @return void */ public function trash(ItemEntity $item, ConfigEntity $config) { $item = $this->get($item->id, $item->instanceId); // 덧글이 있다면 덧글들을 모두 휴지통으로 옯긴다. if ($config->get('recursiveDelete') === true) { $rows = $this->document->getRepository()->getReplies($item->getDocument()); foreach ($rows as $row) { $item = $this->get($row['id'], $row['instanceId']); $item->setDocument($item->getDocument()->trash()); $this->put($item); } } else { $this->document->trash($item->getDocument()); } }
/** * test trash without config entity * * @expectedException \Xpressengine\Document\Exceptions\ConfigNotExistsException * @return void */ public function testTrashWithoutConfig() { $conn = $this->conn; $repo = $this->repo; $configHandler = $this->configHandler; $instanceManager = $this->instanceManager; $request = $this->request; $handler = new DocumentHandler($conn, $repo, $configHandler, $instanceManager, $request); $doc = $this->getDocumentEntity(); $doc->shouldReceive('trash'); $configHandler->shouldReceive('get')->andReturn(null); $handler->trash($doc); }