/** * @test * * @return void */ public function testIsExpired() { $this->fixture->setPublishDate(new \DateTime('now')); $this->fixture->getPublishDate()->modify('-6 months'); $this->assertTrue($this->fixture->isExpired('+5 months')); $this->assertFalse($this->fixture->isExpired('+7 months')); }
/** * Checks if a new comment could be created * * @param Post $post The post the comment is related to * * @return void */ protected function checkIfCommentIsAllowed(Post $post) { $settings = $this->settings['blogsystem']['comments']; if (!$settings['allowed'] || $post->getAllowComments() === 1) { $this->addFlashMessageByKey('notAllowed', FlashMessage::ERROR); $this->errorAction(); } if ($post->getAllowComments() === 2 && empty(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->loginUser)) { $this->addFlashMessageByKey('notLoggedIn', FlashMessage::ERROR); $this->errorAction(); } if ($settings['allowedUntil']) { if ($post->isExpired(trim($settings['allowedUntil']))) { $this->addFlashMessageByKey('commentsClosed', FlashMessage::ERROR); $this->errorAction(); } } }