/**
  * Test entity getters & setters.
  */
 public function testGettersSetters()
 {
     $entity = new PostMeta();
     $post = new Post();
     $post->setTitle('post title');
     $entity->setPost($post);
     $entity->setKey('fake key');
     $entity->setValue('fake value');
     $this->assertEquals('post title', $entity->getPost()->getTitle());
     $this->assertEquals('fake key', $entity->getKey());
     $this->assertEquals('fake value', $entity->getValue());
 }
 /**
  * @param Post    $post
  * @param Request $request
  * @param string  $cookieHash
  *
  * @return bool
  */
 public function isPasswordRequired(Post $post, Request $request, $cookieHash)
 {
     if (!$post->getPassword()) {
         return false;
     }
     $cookies = $request->cookies;
     if (!$cookies->has('wp-postpass_' . $cookieHash)) {
         return true;
     }
     $hash = stripslashes($cookies->get('wp-postpass_' . $cookieHash));
     if (0 !== strpos($hash, '$P$B')) {
         return true;
     }
     $wpHasher = new PasswordHash(8, true);
     return !$wpHasher->CheckPassword($post->getPassword(), $hash);
 }
 /**
  * Test entity getters & setters.
  */
 public function testGettersSetters()
 {
     $entity = new Comment();
     $entity->setAgent('agent');
     $entity->setApproved('approved');
     $entity->setAuthor('author');
     $entity->setAuthorEmail('*****@*****.**');
     $entity->setAuthorIp('1.2.3.4');
     $entity->setAuthorUrl('http://author.com');
     $entity->setContent('content');
     $date = new \DateTime();
     $entity->setDate($date);
     $entity->setDateGmt($date);
     $entity->setKarma(2);
     $parent = new Comment();
     $parent->setContent('parent content');
     $entity->setParent($parent);
     $post = new Post();
     $post->setTitle('post title');
     $entity->setPost($post);
     $entity->setType('type');
     $user = new User();
     $user->setDisplayName('author name');
     $entity->setUser($user);
     $this->assertEquals('agent', $entity->getAgent());
     $this->assertEquals('approved', $entity->getApproved());
     $this->assertEquals('author', $entity->getAuthor());
     $this->assertEquals('*****@*****.**', $entity->getAuthorEmail());
     $this->assertEquals('1.2.3.4', $entity->getAuthorIp());
     $this->assertEquals('http://author.com', $entity->getAuthorUrl());
     $this->assertEquals('content', $entity->getContent());
     $this->assertEquals($date, $entity->getDate());
     $this->assertEquals($date, $entity->getDateGmt());
     $this->assertEquals(2, $entity->getKarma());
     $this->assertEquals('parent content', $entity->getParent()->getContent());
     $this->assertEquals('post title', $entity->getPost()->getTitle());
     $this->assertEquals('type', $entity->getType());
     $this->assertEquals('author name', $entity->getUser()->getDisplayName());
 }
 /**
  * @param Post $post
  *
  * @return PostMeta|null
  */
 public function getThumbnailPostId(Post $post)
 {
     return $this->getPostMeta($post->getId(), '_thumbnail_id', true);
 }
 /**
  * @param Post $post
  *
  * @return bool
  */
 public function haveComments(Post $post)
 {
     return 0 < $post->getCommentCount();
 }