/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not * @return \MShop_Context_Item_Interface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \MShop_Context_Item_Default(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $mail = new \MW_Mail_Swift(function () { return app('mailer')->getSwiftMailer(); }); $context->setMail($mail); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = new \MAdmin_Cache_Proxy_Default($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n(app('\\Aimeos\\Shop\\Base\\I18n')->get(array($langid))); } $session = new \MW_Session_Laravel4($this->session); $context->setSession($session); $this->addUser($context); return $context; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \MShop_Context_Item_Interface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null) { if (self::$context === null) { $context = new \MShop_Context_Item_Default(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $mail = new \MW_Mail_Swift($this->mailer); $context->setMail($mail); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = $this->getCache($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($request !== null) { $localeItem = $this->getLocale($context, $request); $context->setLocale($localeItem); $i18n = $this->i18n->get(array($localeItem->getLanguageId())); $context->setI18n($i18n); } $session = new \MW_Session_Flow($this->session); $context->setSession($session); $this->addUser($context); return $context; }
public function testRun() { $config = $this->_context->getConfig(); $mock = $this->getMockBuilder('MAdmin_Log_Manager_Default')->setMethods(array('deleteItems'))->setConstructorArgs(array($this->_context))->getMock(); $mock->expects($this->atLeastOnce())->method('deleteItems'); $tmppath = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'tmp'; $name = 'ControllerJobsAdminLogDefaultRun'; $config->set('classes/log/manager/name', $name); $config->set('controller/jobs/admin/log/default/limit-days', 0); $config->set('controller/jobs/admin/log/default/path', $tmppath); MAdmin_Log_Manager_Factory::injectManager('MAdmin_Log_Manager_' . $name, $mock); if (!is_dir($tmppath) && mkdir($tmppath) === false) { throw new Exception(sprintf('Unable to create temporary path "%1$s"', $tmppath)); } $this->_object->run(); foreach (new DirectoryIterator($tmppath) as $file) { if ($file->isFile() && $file->getExtension() === 'zip') { $container = MW_Container_Factory::getContainer($file->getPathName(), 'Zip', 'CSV', array()); $container->get('unittest facility.csv'); unlink($file->getPathName()); return; } } $this->fail('Log archive file not found'); }
/** * Adds the log test data. * * @throws MW_Setup_Exception If a required ID is not available */ private function _addLogTestData() { $adminLogManager = MAdmin_Log_Manager_Factory::createManager($this->_additional, 'Default'); $ds = DIRECTORY_SEPARATOR; $path = dirname(__FILE__) . $ds . 'data' . $ds . 'log.php'; if (($testdata = (include $path)) == false) { throw new MShop_Exception(sprintf('No file "%1$s" found for log domain', $path)); } $log = $adminLogManager->createItem(); $this->_conn->begin(); foreach ($testdata['log'] as $dataset) { $log->setId(null); $log->setFacility($dataset['facility']); $log->setPriority($dataset['priority']); $log->setMessage($dataset['message']); $log->setRequest($dataset['request']); $adminLogManager->saveItem($log, false); } $this->_conn->commit(); }
/** * Returns the current context. * * @param \MW_Config_Interface Configuration object * @return MShop_Context_Item_Interface Context object */ public static function getContext(\MW_Config_Interface $config) { if (self::$context === null) { $context = new \MShop_Context_Item_Typo3(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = self::getCache($context); $context->setCache($cache); $mailer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage'); $context->setMail(new \MW_Mail_Typo3($mailer)); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords') && \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) { $object = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(); $context->setHasherTypo3($object); } if (isset($GLOBALS['TSFE']->fe_user)) { $session = new \MW_Session_Typo3($GLOBALS['TSFE']->fe_user); } else { $session = new \MW_Session_None(); } $context->setSession($session); self::$context = $context; } self::$context->setConfig($config); return self::$context; }
public function testCreateManagerNotExisting() { $this->setExpectedException('MShop_Exception'); MAdmin_Log_Manager_Factory::createManager(TestHelper::getContext(), 'notexist'); }
/** * Initializes the log controller. * * @param MShop_Context_Item_Interface $context MShop context object */ public function __construct(MShop_Context_Item_Interface $context) { parent::__construct($context, 'Admin_Log'); $this->_manager = MAdmin_Log_Manager_Factory::createManager($context); }