public function testMoveByTarget() { list($member, $auth, $repo, $cfg) = $this->getMocks(); $instance = new CommentHandler($member, $auth, $repo, $cfg); $mockComment1 = m::mock('Xpressengine\\Comment\\CommentEntity'); $mockComment2 = m::mock('Xpressengine\\Comment\\CommentEntity'); $repo->shouldReceive('fetch')->once()->with(['targetId' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'])->andReturn([$mockComment1, $mockComment2]); $repo->shouldReceive('moveTo')->once()->with($mockComment1, 'instanceId'); $repo->shouldReceive('moveTo')->once()->with($mockComment2, 'instanceId'); $instance->moveByTarget('instanceId', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'); }
/** * 게시판 이동 * Document Package 에서 comment 를 지원하지 않아서 사용할 수 있는 인터페이스가 없음 * * @param string $id document id * @param ConfigEntity $config destination board config entity * @param CommentHandler $commentHandler comment handler */ public function move($id, ConfigEntity $config, CommentHandler $commentHandler) { if ($config === null) { throw new InvalidConfigException(); } $item = $this->get($id); $doc = $item->getDocument(); $dstInstanceId = $config->get('boardId'); // 덧글이 있다면 덧글들을 모두 옯긴다. // 이거 document 인터페이스 있으멶 좋을까?? 사용 할 일 없어 보이는데. $rows = $this->document->getRepository()->getReplies($doc); foreach ($rows as $row) { $item = $this->get($row['id'], $row['instanceId']); $item->instanceId = $dstInstanceId; $item->getSlug()->instanceId = $dstInstanceId; if ($item->userId == '') { $item->userId = ''; } $this->put($item); $commentHandler->moveByTarget($dstInstanceId, $item->id); } }