/**
  * @test
  */
 public function setIsTestForBooleanSetsIsTest()
 {
     $this->fixture->setIsTest(TRUE);
     $this->assertSame(TRUE, $this->fixture->getIsTest());
 }
 /**
  * Creates a new Newsletter and forwards to the list action.
  *
  * @param Tx_Newsletter_Domain_Model_Newsletter $newNewsletter a fresh Newsletter object which has not yet been added to the repository
  * @return void
  * @dontverifyrequesthash
  * @dontvalidate $newNewsletter
  * @ignorevalidation $newNewsletter
  */
 public function createAction(Tx_Newsletter_Domain_Model_Newsletter $newNewsletter = null)
 {
     $limitTestRecipientCount = 10;
     // This is a low limit, technically, but it does not make sense to test a newsletter for more people than that anyway
     $recipientList = $newNewsletter->getRecipientList();
     $recipientList->init();
     $count = $recipientList->getCount();
     $validatedContent = $newNewsletter->getValidatedContent($language);
     // If we attempt to create a newsletter as a test but it has too many recipient, reject it (we cannot safely send several emails wihtout slowing down respoonse and/or timeout issues)
     if ($newNewsletter->getIsTest() && $count > $limitTestRecipientCount) {
         $this->addFlashMessage(Tx_Extbase_Utility_Localization::translate('flashmessage_test_maximum_recipients', 'newsletter', array($count, $limitTestRecipientCount)), Tx_Extbase_Utility_Localization::translate('flashmessage_test_maximum_recipients_title', 'newsletter'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->view->assign('success', FALSE);
     } elseif (count($validatedContent['errors'])) {
         $this->addFlashMessage('The newsletter HTML content does not validate. See tab "Newsletter > Status" for details.', Tx_Extbase_Utility_Localization::translate('flashmessage_newsletter_invalid', 'newsletter'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->view->assign('success', FALSE);
     } else {
         // If it's a test newsletter, it's planned to be sent right now
         if ($newNewsletter->getIsTest()) {
             $newNewsletter->setPlannedTime(new DateTime());
         }
         // Save the new newsletter
         $this->newsletterRepository->add($newNewsletter);
         $this->persistenceManager->persistAll();
         $this->view->assign('success', TRUE);
         // If it is test newsletter, send it immediately
         if ($newNewsletter->getIsTest()) {
             try {
                 // Fill the spool and run the queue
                 Tx_Newsletter_Tools::createSpool($newNewsletter);
                 Tx_Newsletter_Tools::runSpoolOne($newNewsletter);
                 $this->addFlashMessage(Tx_Extbase_Utility_Localization::translate('flashmessage_test_newsletter_sent', 'newsletter'), Tx_Extbase_Utility_Localization::translate('flashmessage_test_newsletter_sent_title', 'newsletter'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
             } catch (Exception $exception) {
                 $this->addFlashMessage($exception->getMessage(), Tx_Extbase_Utility_Localization::translate('flashmessage_test_newsletter_error', 'newsletter'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
             }
         } else {
             $this->addFlashMessage(Tx_Extbase_Utility_Localization::translate('flashmessage_newsletter_queued', 'newsletter'), Tx_Extbase_Utility_Localization::translate('flashmessage_newsletter_queued_title', 'newsletter'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
         }
     }
     $this->view->setVariablesToRender(array('data', 'success', 'flashMessages'));
     $this->view->setConfiguration(array('data' => self::resolveJsonViewConfiguration()));
     $this->view->assign('data', $newNewsletter);
     $this->view->assign('flashMessages', $this->controllerContext->getFlashMessageQueue()->getAllMessagesAndFlush());
 }