/**
  * @param int|Post $postId
  *
  * @return string
  *
  * @throws \UnexpectedValueException
  */
 public function getPermalink($postId)
 {
     $post = $postId instanceof Post ? $postId : $this->postManager->find($postId);
     if (!$post) {
         throw new \UnexpectedValueException(sprintf('No post with ID "%d"', $postId));
     }
     $permalinkStructure = $this->optionExtension->getOption('permalink_structure', '')->getValue();
     return $this->replacePostArguments($permalinkStructure, $post);
 }
 /**
  * @param array $context
  * @param Post  $post
  *
  * @return bool
  */
 public function isPostPasswordRequired(array $context, Post $post)
 {
     if (null === $this->cookieHash) {
         $this->cookieHash = '';
         if ($siteUrlOption = $this->optionExtension->getOption('siteurl')) {
             $this->cookieHash = md5($siteUrlOption->getValue());
         }
     }
     return $this->postManager->isPasswordRequired($post, $context['app']->getRequest(), $this->cookieHash);
 }
 /**
  * Check the usage of default return value for a non existing option
  */
 public function testGetOptionUndefined()
 {
     $this->optionManager->expects($this->once())->method('findOneByOptionName')->with($this->equalTo('test'))->will($this->returnValue(null));
     $result = $this->extension->getOption('test', 'poney');
     $this->assertEquals('poney', $result);
 }