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_CancelEventMailForm($this->eventUid); $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); }
protected function setUp() { $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $this->subject = new tx_seminars_EmailSalutation(); $configuration = new Tx_Oelib_Configuration(); $configuration->setAsString('salutation', 'formal'); Tx_Oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_seminars', $configuration); $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']; $this->t3VarBackup = $GLOBALS['T3_VAR']['getUserObj']; }
protected function setUp() { $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $this->configuration = new Tx_Oelib_Configuration(); $this->configuration->setAsString('timeFormat', self::TIME_FORMAT); Tx_Oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_seminars', $this->configuration); $this->translator = Tx_Oelib_TranslatorRegistry::getInstance()->get('seminars'); $this->translatedHours = ' ' . $this->translator->translate('label_hours'); $this->subject = new tx_seminars_ViewHelper_TimeRange(); }
protected function setUp() { $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('seminars') . 'locallang_db.xml'); $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('lang') . 'locallang_general.xml'); $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('plugin', new Tx_Oelib_Configuration()); $this->configuration = new Tx_Oelib_Configuration(); $this->configuration->setData(array('charsetForCsv' => 'utf-8')); $configurationRegistry->set('plugin.tx_seminars', $this->configuration); $this->subject = new Tx_Seminars_Csv_EventListView(); }
protected function setUp() { $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('config', new Tx_Oelib_Configuration()); $configurationRegistry->set('page.config', new Tx_Oelib_Configuration()); $configurationRegistry->set('plugin.tx_seminars._LOCAL_LANG.default', new Tx_Oelib_Configuration()); tx_oelib_configurationProxy::getInstance('seminars')->setAsBoolean('enableConfigCheck', FALSE); $this->testingFramework = new tx_oelib_testingFramework('tx_seminars'); $this->testingFramework->createFakeFrontEnd(); $this->mapper = $this->getMock('tx_seminars_Mapper_Event', array('findNextUpcoming')); $this->fixture = new tx_seminars_FrontEnd_Countdown(array('isStaticTemplateLoaded' => 1, 'templateFile' => 'EXT:seminars/Resources/Private/Templates/FrontEnd/FrontEnd.html'), $GLOBALS['TSFE']->cObj); }
protected function setUp() { $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('seminars') . 'locallang_db.xml'); $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('lang') . 'locallang_general.xml'); $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('plugin', new Tx_Oelib_Configuration()); $this->configuration = new Tx_Oelib_Configuration(); $this->configuration->setData(array('charsetForCsv' => 'utf-8')); $configurationRegistry->set('plugin.tx_seminars', $this->configuration); $this->pageUid = $this->testingFramework->createSystemFolder(); $this->eventUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('pid' => $this->pageUid, 'begin_date' => $GLOBALS['SIM_EXEC_TIME'])); $this->subject = new Tx_Seminars_Csv_EmailRegistrationListView(); $this->subject->setEventUid($this->eventUid); }
/** * Checks whether the logged-in user (if any) in the current environment has access to a CSV export. * * @return bool whether the logged-in user (if any) in the current environment has access to a CSV export. * * @throws BadMethodCallException */ public function hasAccess() { if ($this->getEvent() === NULL) { throw new BadMethodCallException('Please set an event first.', 1389096647); } if (!Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn()) { return FALSE; } $configuration = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars_pi1'); if (!$configuration->getAsBoolean('allowCsvExportOfRegistrationsInMyVipEventsView')) { return FALSE; } $user = Tx_Oelib_FrontEndLoginManager::getInstance()->getLoggedInUser('tx_seminars_Mapper_FrontEndUser'); $vipsGroupUid = $configuration->getAsInteger('defaultEventVipsFeGroupID'); return $this->getEvent()->isUserVip($user->getUid(), $vipsGroupUid); }
/** * 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(); }
protected function setUp() { $pluginConfiguration = new Tx_Oelib_Configuration(); $pluginConfiguration->setAsString('dateFormatYMD', '%d.%m.%Y'); $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('plugin.tx_seminars', $pluginConfiguration); $configurationRegistry->set('config', new Tx_Oelib_Configuration()); $configurationRegistry->set('page.config', new Tx_Oelib_Configuration()); $configurationRegistry->set('plugin.tx_seminars._LOCAL_LANG.default', new Tx_Oelib_Configuration()); tx_oelib_configurationProxy::getInstance('seminars')->setAsBoolean('enableConfigCheck', FALSE); $this->testingFramework = new tx_oelib_testingFramework('tx_seminars'); $this->testingFramework->createFakeFrontEnd(); // just picked some random date (2001-01-01 00:00:00) $this->eventDate = 978303600; $this->mapper = new tx_seminars_Mapper_Event(); $event = $this->mapper->getLoadedTestingModel(array('pid' => 0, 'title' => 'Test event', 'begin_date' => $this->eventDate)); $this->eventId = $event->getUid(); $this->fixture = new tx_seminars_FrontEnd_EventHeadline(array('isStaticTemplateLoaded' => 1, 'templateFile' => 'EXT:seminars/Resources/Private/Templates/FrontEnd/FrontEnd.html'), $GLOBALS['TSFE']->cObj); $this->fixture->injectEventMapper($this->mapper); }
protected function setUp() { if (t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) < 4007000) { $this->backEndConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['BE']; $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] = 'utf-8'; } $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('seminars') . 'locallang_db.xml'); $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('lang') . 'locallang_general.xml'); tx_oelib_headerProxyFactory::getInstance()->enableTestMode(); $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $this->pid = $this->testingFramework->createSystemFolder(); $this->eventUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('pid' => $this->pid, 'begin_date' => $GLOBALS['SIM_EXEC_TIME'])); $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('plugin', new Tx_Oelib_Configuration()); $this->configuration = new Tx_Oelib_Configuration(); $this->configuration->setData(array('charsetForCsv' => 'utf-8')); $configurationRegistry->set('plugin.tx_seminars', $this->configuration); $this->fixture = new tx_seminars_pi2(); $this->fixture->init(array()); }
/** * Creates the salutation for the given user. * * The salutation is localized and gender-specific and contains the name of * the user. * * @param tx_seminars_Model_FrontEndUser $user * the user to create the salutation for * * @return string the localized, gender-specific salutation with a trailing comma, will not be empty */ public function getSalutation(tx_seminars_Model_FrontEndUser $user) { $salutationParts = array(); $salutationMode = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars')->getAsString('salutation'); switch ($salutationMode) { case 'informal': $salutationParts['dear'] = $this->translator->translate('email_hello_informal'); $salutationParts['name'] = $user->getFirstOrFullName(); break; default: $gender = $user->getGender(); $salutationParts['dear'] = $this->translator->translate('email_hello_formal_' . $gender); $salutationParts['title'] = $this->translator->translate('email_salutation_title_' . $gender); $salutationParts['name'] = $user->getLastOrFullName(); } foreach ($this->getHooks() as $hook) { if (method_exists($hook, 'modifySalutation')) { $hook->modifySalutation($salutationParts); } } return implode(' ', $salutationParts) . ','; }
protected function setUp() { $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('seminars') . 'locallang_db.xml'); $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('lang') . 'locallang_general.xml'); $this->testingFramework = new Tx_Oelib_TestingFramework('tx_seminars'); $configurationRegistry = Tx_Oelib_ConfigurationRegistry::getInstance(); $configurationRegistry->set('plugin', new Tx_Oelib_Configuration()); $this->configuration = new Tx_Oelib_Configuration(); $this->configuration->setData(array('charsetForCsv' => 'utf-8')); $configurationRegistry->set('plugin.tx_seminars', $this->configuration); $this->pageUid = $this->testingFramework->createSystemFolder(); $this->eventUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('pid' => $this->pageUid, 'begin_date' => $GLOBALS['SIM_EXEC_TIME'])); $this->subject = $this->getMockForAbstractClass('Tx_Seminars_Csv_AbstractRegistrationListView'); $this->subject->expects(self::any())->method('shouldAlsoContainRegistrationsOnQueue')->will(self::returnValue(TRUE)); $testCase = $this; $this->subject->expects(self::any())->method('getFrontEndUserFieldKeys')->will(self::returnCallback(function () use($testCase) { return $testCase->frontEndUserFieldKeys; })); $this->subject->expects(self::any())->method('getRegistrationFieldKeys')->will(self::returnCallback(function () use($testCase) { return $testCase->registrationFieldKeys; })); $this->subject->setEventUid($this->eventUid); }
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'); $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('organizers' => 1, 'begin_date' => $GLOBALS['SIM_EXEC_TIME'] + 42, 'title' => 'Dummy Event', 'registrations' => 1)); $this->testingFramework->createRelationAndUpdateCounter('tx_seminars_seminars', $this->eventUid, $this->organizerUid, 'organizers'); $this->fixture = new tx_seminars_BackEnd_GeneralEventMailForm($this->eventUid); }
protected function tearDown() { Tx_Oelib_ConfigurationRegistry::purgeInstance(); Tx_Oelib_FrontEndLoginManager::purgeInstance(); }
/** * Purges the current instance so that getInstance will create a new * instance. * * @return void */ public static function purgeInstance() { self::$instance = NULL; }
/** * Returns the default country as localized string. * * @return string the default country's localized name, will be empty if there is no default country */ private function getDefaultCountry() { $defaultCountryCode = tx_oelib_ConfigurationRegistry::get('plugin.tx_staticinfotables_pi1')->getAsString('countryCode'); if ($defaultCountryCode === '') { return ''; } $this->initStaticInfo(); if (class_exists('SJBR\\StaticInfoTables\\Utility\\LocalizationUtility', TRUE)) { $currentLanguageCode = Tx_Oelib_ConfigurationRegistry::get('config')->getAsString('language'); $identifiers = array('iso' => $defaultCountryCode); $result = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue($identifiers, 'static_countries', $currentLanguageCode, TRUE); } else { $result = tx_staticinfotables_div::getTitleFromIsoCode('static_countries', $defaultCountryCode, $this->staticInfo->getCurrentLanguage(), TRUE); } return $result; }
/** * The constructor. */ public function __construct() { $this->configuration = Tx_Oelib_ConfigurationRegistry::getInstance()->get('plugin.tx_seminars'); $this->translator = Tx_Oelib_TranslatorRegistry::getInstance()->get('seminars'); }
/** * @test */ public function getAfterSetReturnsManuallySetConfigurationEvenIfThereIsAPage() { $pageUid = $this->testingFramework->createFrontEndPage(); $this->testingFramework->createTemplate($pageUid, array('config' => 'plugin.tx_oelib.bar = 42')); Tx_Oelib_PageFinder::getInstance()->setPageUid($pageUid); $configuration = new Tx_Oelib_Configuration(); Tx_Oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_oelib', $configuration); self::assertSame($configuration, Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib')); }
/** * @test */ public function getByExtensionNameDoesNotDeleteLanguageLabelsNotAffectedByTypoScript() { $testingFramework = new Tx_Oelib_TestingFramework('oelib'); $testingFramework->createFakeFrontEnd(); $this->getFrontEndController()->initLLvars(); Tx_Oelib_ConfigurationRegistry::get('config')->set('language', 'default'); Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib._LOCAL_LANG')->setData(array('default.' => array())); Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib._LOCAL_LANG.default')->set('label_test_2', 'I am from TypoScript.'); self::assertSame('I am from file.', Tx_Oelib_TranslatorRegistry::get('oelib')->translate('label_test')); $testingFramework->discardFakeFrontEnd(); }
/** * The constructor. */ public function __construct() { $this->configuration = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars'); }
/** * Returns the localized labels from an extension's TypoScript setup. * * Returns only the labels set for the language stored in $this->languageKey * * @param string $extensionName * the extension name to get the localized labels from TypoScript setup for, * must not be empty, the corresponding extension must be loaded * * @return string[] the localized labels from the extension's TypoScript setup, will be empty if there are none */ private function getLocalizedLabelsFromTypoScript($extensionName) { if ($extensionName === '') { throw new InvalidArgumentException('The parameter $extensionName must not be empty.', 1331489630); } $result = array(); $namespace = 'plugin.tx_' . $extensionName . '._LOCAL_LANG.' . $this->languageKey; $configuration = Tx_Oelib_ConfigurationRegistry::get($namespace); foreach ($configuration->getArrayKeys() as $key) { // Converts the label from the source charset to the render // charset. $result[$key] = $this->charsetConversion->conv($configuration->getAsString($key), 'utf-8', $this->renderCharset, TRUE); } return $result; }