/**
  * 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());
 }
 /**
  * Test entity getters & setters.
  */
 public function testGettersSetters()
 {
     $entity = new Post();
     $user = new User();
     $user->setDisplayName('author name');
     $entity->setAuthor($user);
     $entity->setCommentCount(5);
     $entity->setCommentStatus('approved');
     $entity->setContent('post content');
     $entity->setContentFiltered('post content filtered');
     $date = new \DateTime();
     $entity->setDate($date);
     $entity->setDateGmt($date);
     $entity->setExcerpt('excerpt');
     $entity->setGuid('guid');
     $entity->setMenuOrder(2);
     $meta1 = new PostMeta();
     $meta1->setKey('meta key');
     $meta1->setValue('meta value');
     $meta1->setPost($entity);
     $collection = new ArrayCollection();
     $collection->add($meta1);
     $entity->setMetas($collection);
     $entity->setMimeType('text/html');
     $entity->setModified($date);
     $entity->setModifiedGmt($date);
     $entity->setName('post name');
     $parent = new Post();
     $parent->setTitle('parent post title');
     $entity->setParent($parent);
     $entity->setPassword('password');
     $entity->setPinged('pinged');
     $entity->setPingStatus('done');
     $entity->setStatus('published');
     $entity->setTitle('post title');
     $entity->setToPing('to ping');
     $entity->setType('post type');
     $this->assertEquals('author name', $entity->getAuthor()->getDisplayName());
     $this->assertEquals(5, $entity->getCommentCount());
     $this->assertEquals('approved', $entity->getCommentStatus());
     $this->assertEquals('post content', $entity->getContent());
     $this->assertEquals('post content filtered', $entity->getContentFiltered());
     $this->assertEquals($date, $entity->getDate());
     $this->assertEquals($date, $entity->getDateGmt());
     $this->assertEquals('excerpt', $entity->getExcerpt());
     $this->assertEquals('guid', $entity->getGuid());
     $this->assertEquals(2, $entity->getMenuOrder());
     $this->assertEquals($collection, $entity->getMetas());
     $this->assertEquals('text/html', $entity->getMimeType());
     $this->assertEquals($date, $entity->getModified());
     $this->assertEquals($date, $entity->getModifiedGmt());
     $this->assertEquals('post name', $entity->getName());
     $this->assertEquals('parent post title', $entity->getParent()->getTitle());
     $this->assertEquals('password', $entity->getPassword());
     $this->assertEquals('pinged', $entity->getPinged());
     $this->assertEquals('done', $entity->getPingStatus());
     $this->assertEquals('published', $entity->getStatus());
     $this->assertEquals('post title', $entity->getTitle());
     $this->assertEquals('to ping', $entity->getToPing());
     $this->assertEquals('post type', $entity->getType());
 }
 /**
  * @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();
 }