Ejemplo n.º 1
0
 /**
  * @vcr DiscussionsTests/testDeleteComment.json
  * @link https://familysearch.org/developers/docs/api/discussions/Delete_Comment_usecase
  */
 public function testDeleteComment()
 {
     $factory = new FamilySearchStateFactory();
     $this->collectionState($factory);
     $userState = $this->collectionState()->readCurrentUser();
     $discussion = DiscussionBuilder::createDiscussion($userState->getUser()->getTreeUserId());
     /** @var DiscussionState $state */
     $state = $this->collectionState()->addDiscussion($discussion);
     $this->queueForDelete($state);
     $state = $state->get();
     $comment = DiscussionBuilder::createComment($userState);
     $addedCommentState = $state->addComment($comment);
     $this->assertAttributeEquals(HttpStatus::CREATED, "statusCode", $addedCommentState->getResponse(), $this->buildFailMessage(__METHOD__, $addedCommentState));
     $state = $state->get();
     $state->loadComments();
     $comments = $state->getDiscussion()->getComments();
     $this->assertEquals(1, count($comments));
     $deleted = $state->deleteComment($comments[0]);
     $this->assertAttributeEquals(HttpStatus::NO_CONTENT, "statusCode", $deleted->getResponse(), $this->buildFailMessage(__METHOD__, $deleted));
 }
Ejemplo n.º 2
0
 /**
  * @vcr PersonTests/testDeleteDiscussionReference.json
  * @link https://familysearch.org/developers/docs/api/tree/Delete_Discussion_Reference_usecase
  */
 public function testDeleteDiscussionReference()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     $userState = $this->collectionState()->readCurrentUser();
     $discussion = DiscussionBuilder::createDiscussion($userState->getUser()->getTreeUserId());
     /** @var DiscussionState $discussionState */
     $discussionState = $this->collectionState()->addDiscussion($discussion);
     $this->queueForDelete($discussionState);
     $ref = new DiscussionReference();
     $ref->setResource($discussionState->getSelfUri());
     /** @var FamilyTreePersonState $person */
     $person = $this->collectionState()->readPersonForCurrentUser();
     $newState = $person->deleteDiscussionReference($ref);
     $this->assertEquals(HttpStatus::NO_CONTENT, $newState->getStatus(), $this->buildFailMessage(__METHOD__, $newState));
 }