示例#1
0
 /**
  * @param mixed $data
  * @param array $map
  * @dataProvider constructorDataProvider
  */
 public function testConstructor($data, $map)
 {
     //TODO: We should not use mocks in integration tests
     /** @var Magento_ObjectManager_Zend|PHPUnit_Framework_MockObject_MockObject $objectManagerMock */
     $objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create', 'get'), array(), '', false);
     $objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap(array($map, array('Mage_Core_Model_Config_Base', array(), true, new Mage_Core_Model_Config_Base()))));
     $this->_model = new Mage_Core_Model_Config($objectManagerMock, $data);
     $this->assertInstanceOf('Mage_Core_Model_Config_Options', $this->_model->getOptions());
 }
示例#2
0
 /**
  * Add a logger by specified key
  *
  * Second argument is a file name (relative to log directory) or a PHP "wrapper"
  *
  * @param string $loggerKey
  * @param string $fileOrWrapper
  * @return Mage_Core_Model_Logger
  * @link http://php.net/wrappers
  */
 public function addStreamLog($loggerKey, $fileOrWrapper = '')
 {
     $file = $fileOrWrapper ?: "{$loggerKey}.log";
     if (!preg_match('#^[a-z][a-z0-9+.-]*\\://#i', $file)) {
         $file = $this->_config->getOptions()->getLogDir() . DIRECTORY_SEPARATOR . $file;
     }
     $writerClass = (string) $this->_config->getNode('global/log/core/writer_model');
     if (!$writerClass || !is_subclass_of($writerClass, 'Zend_Log_Writer_Stream')) {
         $writerClass = 'Zend_Log_Writer_Stream';
     }
     /** @var $writer Zend_Log_Writer_Stream */
     $writer = $writerClass::factory(array('stream' => $file));
     $writer->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL));
     $this->_loggers[$loggerKey] = new Zend_Log($writer);
     return $this;
 }
示例#3
0
 /**
  * Execute command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  *
  * @throws InvalidArgumentException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     if (false === $this->initMagento()) {
         throw new RuntimeException('Magento could not be loaded');
     }
     $this->config = \Mage::getConfig();
     $this->modulesDir = $this->config->getOptions()->getEtcDir() . DS . 'modules' . DS;
     if ($codePool = $input->getOption('codepool')) {
         $output->writeln('<info>' . ($this->commandName == 'enable' ? 'Enabling' : 'Disabling') . ' modules in <comment>' . $codePool . '</comment> codePool...</info>');
         $this->enableCodePool($codePool, $output);
     } elseif ($module = $input->getArgument('moduleName')) {
         $this->enableModule($module, $output);
     } else {
         throw new InvalidArgumentException('No code-pool option nor module-name argument');
     }
 }
示例#4
0
 /**
  * Get captcha image directory
  *
  * @param mixed $website
  * @return string
  */
 public function getImgDir($website = null)
 {
     $mediaDir = $this->_config->getOptions()->getDir('media');
     $captchaDir = Magento_Filesystem::getPathFromArray(array($mediaDir, 'captcha', $this->_app->getWebsite($website)->getCode()));
     $this->_filesystem->setWorkingDirectory($mediaDir);
     $this->_filesystem->setIsAllowCreateDirectories(true);
     $this->_filesystem->ensureDirectoryExists($captchaDir, 0755);
     return $captchaDir . Magento_Filesystem::DIRECTORY_SEPARATOR;
 }
示例#5
0
 /**
  * Get theme file name, using fallback mechanism
  *
  * @param string $file
  * @param string|null $module
  * @return string
  */
 public function getViewFile($file, $module = null)
 {
     $dir = $this->_appConfig->getOptions()->getDesignDir();
     $moduleDir = $module ? $this->_appConfig->getModuleDir('view', $module) : '';
     $dirs = array();
     $themeModel = $this->_theme;
     while ($themeModel) {
         list($package, $theme) = $this->_getInheritedTheme($themeModel);
         $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}/locale/{$this->_locale}";
         $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}";
         $themeModel = $themeModel->getParentTheme();
     }
     $extraDirs = array($this->_appConfig->getOptions()->getJsDir(), Mage::getDesign()->getCustomizationDir());
     return $this->_fallback($file, $dirs, $module, array("{$moduleDir}/{$this->_area}/locale/{$this->_locale}", "{$moduleDir}/{$this->_area}"), $extraDirs);
 }
示例#6
0
 /**
  * Get skin file name, using fallback mechanism
  *
  * @param string $file
  * @param string|null $module
  * @return string
  */
 public function getSkinFile($file, $module = null)
 {
     $dir = $this->_appConfig->getOptions()->getDesignDir();
     $moduleDir = $module ? $this->_appConfig->getModuleDir('view', $module) : '';
     $defaultSkin = Mage_Core_Model_Design_Package::DEFAULT_SKIN_NAME;
     $dirs = array();
     $theme = $this->_theme;
     $package = $this->_package;
     while ($theme) {
         $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}/skin/{$this->_skin}/locale/{$this->_locale}";
         $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}/skin/{$this->_skin}";
         if ($this->_skin != $defaultSkin) {
             $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}/skin/{$defaultSkin}/locale/{$this->_locale}";
             $dirs[] = "{$dir}/{$this->_area}/{$package}/{$theme}/skin/{$defaultSkin}";
         }
         list($package, $theme) = $this->_getInheritedTheme($package, $theme);
     }
     return $this->_fallback($file, $dirs, $module, array("{$moduleDir}/{$this->_area}/locale/{$this->_locale}", "{$moduleDir}/{$this->_area}"), array($this->_appConfig->getOptions()->getJsDir()));
 }
示例#7
0
 /**
  * Initialize cache types options
  *
  * @return Mage_Core_Model_Cache
  */
 protected function _initOptions()
 {
     $options = $this->load(self::OPTIONS_CACHE_ID);
     if ($options === false) {
         $options = $this->_getResource()->getAllOptions();
         if (is_array($options)) {
             $this->_allowedCacheOptions = $options;
             $this->save(serialize($this->_allowedCacheOptions), self::OPTIONS_CACHE_ID);
         } else {
             $this->_allowedCacheOptions = array();
         }
     } else {
         $this->_allowedCacheOptions = unserialize($options);
     }
     if ($this->_config->getOptions()->getData('global_ban_use_cache')) {
         foreach ($this->_allowedCacheOptions as $key => $val) {
             $this->_allowedCacheOptions[$key] = false;
         }
     }
     return $this;
 }
 /**
  * Get file name with cache configuration settings
  *
  * @deprecated after 1.4.0.0-alpha3, functionality implemented in Mage_Core_Model_Cache
  * @return string
  */
 public function getUseCacheFilename()
 {
     return $this->_config->getOptions()->getEtcDir() . DS . 'use_cache.ser';
 }
 /**
  * @return array List of all "etc" folders
  */
 private function _collectConfigFolders()
 {
     $folders = array($this->_config->getOptions()->getEtcDir());
     return $this->_addModuleFolders($folders);
 }
示例#10
0
 /**
  * @dataProvider constructorDataProvider
  */
 public function testConstructor($data)
 {
     $this->_model = new Mage_Core_Model_Config($data);
     $this->assertInstanceOf('Mage_Core_Model_Config_Options', $this->_model->getOptions());
 }