Exemplo n.º 1
0
 protected function setUp()
 {
     tx_oelib_configurationProxy::getInstance('seminars')->setAsBoolean('enableConfigCheck', FALSE);
     $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'];
     $this->t3VarBackup = $GLOBALS['T3_VAR']['getUserObj'];
     $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seminars'] = array();
     $this->testingFramework = new tx_oelib_testingFramework('tx_seminars');
     $this->testingFramework->createFakeFrontEnd();
     tx_oelib_headerProxyFactory::getInstance()->enableTestMode();
     $configuration = new tx_oelib_Configuration();
     $configuration->setAsString('currency', 'EUR');
     tx_oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_seminars', $configuration);
     $this->systemFolderPid = $this->testingFramework->createSystemFolder();
     $this->seminarUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('pid' => $this->systemFolderPid, 'title' => 'Test & event', 'subtitle' => 'Something for you & me', 'accreditation_number' => '1 & 1', 'room' => 'Rooms 2 & 3'));
     $this->fixture = new tx_seminars_FrontEnd_DefaultController();
     $this->fixture->init(array('isStaticTemplateLoaded' => 1, 'enableRegistration' => 1, 'templateFile' => 'EXT:seminars/Resources/Private/Templates/FrontEnd/FrontEnd.html', 'what_to_display' => 'seminar_list', 'pidList' => $this->systemFolderPid, 'pages' => $this->systemFolderPid, 'recursive' => 1, 'listView.' => array('orderBy' => 'data', 'descFlag' => 0, 'results_at_a_time' => 999, 'maxPages' => 5), 'eventFieldsOnRegistrationPage' => 'title,price_regular,price_special,vacancies,accreditation_number', 'linkToSingleView' => 'always'));
     $this->fixture->getTemplateCode();
     $this->fixture->setLabels();
     $this->fixture->createHelperObjects();
     tx_oelib_templatehelper::setCachedConfigurationValue('dateFormatYMD', '%d.%m.%Y');
     tx_oelib_templatehelper::setCachedConfigurationValue('timeFormat', '%H:%M');
     $this->linkBuilder = $this->getMock('tx_seminars_Service_SingleViewLinkBuilder', array('createRelativeUrlForEvent'));
     $this->linkBuilder->expects(self::any())->method('createRelativeUrlForEvent')->will(self::returnValue('index.php?id=42&tx_seminars_pi1%5BshowUid%5D=1337'));
     $this->fixture->injectLinkBuilder($this->linkBuilder);
     /** @var $content tslib_cObj|PHPUnit_Framework_MockObject_MockObject */
     $content = $this->getMock('tslib_cObj', array('IMAGE'));
     $content->expects(self::any())->method('IMAGE')->will(self::returnValue('<img src="foo.jpg" alt="bar"/>'));
     $this->fixture->cObj = $content;
 }
 protected function setUp()
 {
     $configuration = new Tx_Oelib_Configuration();
     Tx_Oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_seminars', $configuration);
     $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'];
     $this->t3VarBackup = $GLOBALS['T3_VAR']['getUserObj'];
     $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seminars'] = array();
     $this->languageBackup = $GLOBALS['LANG']->lang;
     $GLOBALS['LANG']->lang = 'default';
     // Loads the locallang file for properly working localization in the tests.
     $GLOBALS['LANG']->includeLLFile('EXT:seminars/BackEnd/locallang.xml');
     tx_oelib_headerProxyFactory::getInstance()->enableTestMode();
     /** @var Tx_Oelib_MailerFactory $mailerFactory */
     $mailerFactory = t3lib_div::makeInstance('Tx_Oelib_MailerFactory');
     $mailerFactory->enableTestMode();
     $this->mailer = $mailerFactory->getMailer();
     $this->testingFramework = new tx_oelib_testingFramework('tx_seminars');
     tx_oelib_MapperRegistry::getInstance()->activateTestingMode($this->testingFramework);
     $this->dummySysFolderUid = $this->testingFramework->createSystemFolder();
     tx_oelib_PageFinder::getInstance()->setPageUid($this->dummySysFolderUid);
     $this->organizerUid = $this->testingFramework->createRecord('tx_seminars_organizers', array('title' => 'Dummy Organizer', 'email' => '*****@*****.**'));
     $this->eventUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('pid' => $this->dummySysFolderUid, 'title' => 'Dummy event', 'object_type' => tx_seminars_Model_Event::TYPE_DATE, 'begin_date' => $GLOBALS['SIM_EXEC_TIME'] + 86400, 'organizers' => 0));
     $this->testingFramework->createRelationAndUpdateCounter('tx_seminars_seminars', $this->eventUid, $this->organizerUid, 'organizers');
     $this->fixture = new tx_seminars_BackEnd_ConfirmEventMailForm($this->eventUid);
 }
Exemplo n.º 3
0
 /**
  * Cleans up oelib after running a test.
  *
  * @return void
  */
 public function cleanUp()
 {
     Tx_Oelib_ConfigurationProxy::purgeInstances();
     Tx_Oelib_BackEndLoginManager::purgeInstance();
     Tx_Oelib_ConfigurationRegistry::purgeInstance();
     Tx_Oelib_FrontEndLoginManager::purgeInstance();
     tx_oelib_Geocoding_Google::purgeInstance();
     tx_oelib_headerProxyFactory::purgeInstance();
     Tx_Oelib_MapperRegistry::purgeInstance();
     Tx_Oelib_PageFinder::purgeInstance();
     Tx_Oelib_Session::purgeInstances();
     Tx_Oelib_TemplateHelper::purgeCachedConfigurations();
     Tx_Oelib_TranslatorRegistry::purgeInstance();
     /** @var Tx_Oelib_MailerFactory $mailerFactory */
     $mailerFactory = t3lib_div::makeInstance('Tx_Oelib_MailerFactory');
     $mailerFactory->cleanUp();
 }
Exemplo n.º 4
0
 /**
  * Redirects to the current URL.
  *
  * @return void
  */
 protected function redirectToCurrentUrl()
 {
     $currentUrl = t3lib_div::locationHeaderUrl(t3lib_div::getIndpEnv('REQUEST_URI'));
     tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Location: ' . $currentUrl);
 }
Exemplo n.º 5
0
 /**
  * @test
  */
 public function getHeaderProxyNotReturnsTheSameObjectWhenCalledInTheSameClassInAnotherMode()
 {
     // new instances always have a disabled test mode
     tx_oelib_headerProxyFactory::purgeInstance();
     self::assertNotSame($this->subject, tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy());
 }
Exemplo n.º 6
0
 /**
  * @test
  */
 public function renderWithLoggedInAndRegisteredFrontEndUserDoesNotReturnHeader403()
 {
     $this->createLogInAndRegisterFrontEndUser();
     $this->fixture->render();
     self::assertNotContains('403', tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->getLastAddedHeader());
 }
Exemplo n.º 7
0
 /**
  * Creates a list of registered participants for an event.
  * If there are no registrations yet, a localized message is displayed instead.
  *
  * @return string HTML code for the list, will not be empty
  */
 public function render()
 {
     $errorMessage = '';
     $isOkay = FALSE;
     if ($this->seminar->isOk()) {
         // Okay, at least the seminar UID is valid so we can show the
         // seminar title and date.
         $this->setMarker('title', htmlspecialchars($this->seminar->getTitleAndDate()));
         // Lets warnings from the seminar bubble up to us.
         $this->setErrorMessage($this->seminar->checkConfiguration(TRUE));
         if ($this->seminar->canViewRegistrationsList($this->whatToDisplay, 0, 0, $this->getConfValueInteger('defaultEventVipsFeGroupID', 's_template_special'))) {
             $isOkay = TRUE;
         } else {
             $errorMessage = $this->seminar->canViewRegistrationsListMessage($this->whatToDisplay);
             tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 403 Forbidden');
         }
     } else {
         $errorMessage = $this->translate('message_wrongSeminarNumber');
         tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 404 Not Found');
         $this->setMarker('title', '');
     }
     if ($isOkay) {
         $this->hideSubparts('error', 'wrapper');
         $this->createRegistrationsList();
     } else {
         $this->setMarker('error_text', $errorMessage);
         $this->setMarker('registrations_list_view_content', '');
     }
     $this->setMarker('backlink', $this->cObj->getTypoLink($this->translate('label_back'), $this->getConfValueInteger('listPID')));
     $result = $this->getSubpart('REGISTRATIONS_LIST_VIEW');
     $this->checkConfiguration();
     $result .= $this->getWrappedConfigCheckMessage();
     return $result;
 }
 /**
  * Checks whether a seminar UID is valid, ie., a non-deleted and non-hidden seminar with the given number exists.
  *
  * This method can be called even if no seminar object exists.
  *
  * For invalid or inexistent UIDs, this method also send a 404 HTTP header.
  *
  * @param string $seminarUid a given seminar UID (needs not necessarily be an int)
  *
  * @return string an empty string if the UID is valid, otherwise a localized error message
  */
 public function existsSeminarMessage($seminarUid)
 {
     if ($seminarUid <= 0) {
         tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 404 Not Found');
         return $this->translate('message_missingSeminarNumber');
     }
     if (!tx_seminars_OldModel_Abstract::recordExists($seminarUid, 'tx_seminars_seminars')) {
         tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 404 Not Found');
         return $this->translate('message_wrongSeminarNumber');
     }
     return '';
 }
Exemplo n.º 9
0
 /**
  * Adds a status header and returns an error message.
  *
  * @param int $errorCode
  *        the type of error message, must be tx_seminars_pi2::ACCESS_DENIED or tx_seminars_pi2::NOT_FOUND
  *
  * @return string the error message belonging to the error code, will not be empty
  *
  * @throws InvalidArgumentException
  */
 private function addErrorHeaderAndReturnMessage($errorCode)
 {
     switch ($errorCode) {
         case self::ACCESS_DENIED:
             tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 403 Forbidden');
             $result = $this->translate('message_403');
             break;
         case self::NOT_FOUND:
             tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 404 Not Found');
             $result = $this->translate('message_404');
             break;
         default:
             throw new InvalidArgumentException('"' . $errorCode . '" is no legal error code.', 1333292523);
     }
     return $result;
 }
Exemplo n.º 10
0
 protected function setUp()
 {
     $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'];
     $this->t3VarBackup = $GLOBALS['T3_VAR']['getUserObj'];
     $this->testingFramework = new tx_oelib_testingFramework('tx_seminars');
     $this->testingFramework->createFakeFrontEnd();
     /** @var Tx_Oelib_MailerFactory $mailerFactory */
     $mailerFactory = t3lib_div::makeInstance('Tx_Oelib_MailerFactory');
     $mailerFactory->enableTestMode();
     $this->mailer = $mailerFactory->getMailer();
     tx_seminars_registrationchild::purgeCachedSeminars();
     tx_oelib_configurationProxy::getInstance('seminars')->setAsInteger('eMailFormatForAttendees', tx_seminars_registrationmanager::SEND_TEXT_MAIL);
     $configurationRegistry = tx_oelib_ConfigurationRegistry::getInstance();
     $configurationRegistry->set('plugin.tx_seminars', new Tx_Oelib_Configuration());
     $configurationRegistry->set('plugin.tx_seminars._LOCAL_LANG.default', new Tx_Oelib_Configuration());
     $configurationRegistry->set('config', new Tx_Oelib_Configuration());
     $configurationRegistry->set('page.config', new Tx_Oelib_Configuration());
     $organizerUid = $this->testingFramework->createRecord('tx_seminars_organizers', array('title' => 'test organizer', 'email' => '*****@*****.**', 'email_footer' => 'organizer footer'));
     $this->seminarUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('title' => 'test event', 'begin_date' => $GLOBALS['SIM_EXEC_TIME'] + 1000, 'end_date' => $GLOBALS['SIM_EXEC_TIME'] + 2000, 'attendees_min' => 1, 'attendees_max' => 10, 'needs_registration' => 1, 'organizers' => 1));
     $this->testingFramework->createRelation('tx_seminars_seminars_organizers_mm', $this->seminarUid, $organizerUid);
     tx_oelib_templateHelper::setCachedConfigurationValue('templateFile', 'EXT:seminars/Resources/Private/Templates/Mail/e-mail.html');
     $headerProxyFactory = tx_oelib_headerProxyFactory::getInstance();
     $headerProxyFactory->enableTestMode();
     $this->headerCollector = $headerProxyFactory->getHeaderProxy();
     $this->seminar = new tx_seminars_seminarchild($this->seminarUid);
     $this->fixture = tx_seminars_registrationmanager::getInstance();
     $this->linkBuilder = $this->getMock('tx_seminars_Service_SingleViewLinkBuilder', array('createAbsoluteUrlForEvent'));
     $this->linkBuilder->expects(self::any())->method('createAbsoluteUrlForEvent')->will(self::returnValue('http://singleview.example.com/'));
     $this->fixture->injectLinkBuilder($this->linkBuilder);
 }
Exemplo n.º 11
0
 /**
  * @test
  */
 public function createAndOutputListOfRegistrationsForNoEventUidGivenSetsPageContentTypeToCsv()
 {
     $this->fixture->piVars['pid'] = $this->pid;
     $this->fixture->createAndOutputListOfRegistrations();
     self::assertTrue(in_array('Content-type: text/csv; header=present; charset=utf-8', tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->getAllAddedHeaders()));
 }
Exemplo n.º 12
0
 /**
  * Redirects to the list view.
  *
  * @return void
  */
 private function redirectToListView()
 {
     $url = t3lib_BEfunc::getModuleUrl(self::MODULE_NAME, array('id' => tx_oelib_PageFinder::getInstance()->getPageUid()), FALSE, TRUE);
     tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Location: ' . $url);
 }
Exemplo n.º 13
0
 /**
  * Checks whether logged-in FE user has access to the event editor and then
  * either creates the event editor HTML or a localized error message.
  *
  * @return string HTML code for the event editor, or an error message if the
  *                FE user doesn't have access to the editor
  */
 protected function createEventEditorHtml()
 {
     $result = '';
     $eventEditor = $this->createEventEditorInstance();
     $hasAccessMessage = $eventEditor->hasAccessMessage();
     if ($hasAccessMessage == '') {
         $result = $eventEditor->render();
     } else {
         $result = $hasAccessMessage;
         tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Status: 403 Forbidden');
     }
     return $result;
 }
Exemplo n.º 14
0
 /**
  * Processes the registration that should be removed.
  *
  * @return void
  */
 public function processUnregistration()
 {
     if ($this->getFormCreator()->aORenderlets['button_cancel']->hasThrown('click')) {
         $redirectUrl = t3lib_div::locationHeaderUrl($this->pi_getPageLink($this->getConfValueInteger('myEventsPID')));
         tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Location:' . $redirectUrl);
         exit;
     }
     $this->getRegistrationManager()->removeRegistration($this->getRegistration()->getUid(), $this);
 }
Exemplo n.º 15
0
 /**
  * Purges the current instance so that getInstance will create a new instance.
  *
  * @return void
  */
 public static function purgeInstance()
 {
     self::$instance = NULL;
 }