Exemple #1
0
 public function testCreateDirIfNotExistsNegativeResult()
 {
     $checkDir = __DIR__ . DIRECTORY_SEPARATOR . 'dirNotExists';
     $this->_sourceData['io']->expects($this->at(0))->method('checkAndCreateFolder')->with($this->equalTo($this->_varDir))->will($this->returnValue(true));
     $this->_sourceData['io']->expects($this->at(1))->method('checkAndCreateFolder')->will($this->throwException(new Exception()));
     $this->_model = new Mage_Core_Model_Config_Options($this->_sourceData);
     $result = $this->_model->createDirIfNotExists($checkDir);
     $this->assertEquals(false, $result);
 }
Exemple #2
0
 public function testCreateDirIfNotExists()
 {
     $var = $this->_model->getVarDir();
     $sampleDir = uniqid($var);
     $this->assertTrue($this->_model->createDirIfNotExists($sampleDir));
     $this->assertTrue($this->_model->createDirIfNotExists($sampleDir));
     rmdir($sampleDir);
     $sampleFile = "{$var}/" . uniqid('file') . '.txt';
     file_put_contents($sampleFile, '1');
     $this->assertFalse($this->_model->createDirIfNotExists($sampleFile));
     unlink($sampleFile);
 }
Exemple #3
0
 /**
  * Retrieve logo image URL
  *
  * @return string
  */
 protected function _getLogoUrl()
 {
     $folderName = Mage_Backend_Model_Config_Backend_Image_Logo::UPLOAD_DIR;
     $storeLogoPath = $this->_storeConfig->getConfig('design/header/logo_src');
     $logoUrl = $this->_urlBuilder->getBaseUrl(array('_type' => Mage_Core_Model_Store::URL_TYPE_MEDIA)) . $folderName . '/' . $storeLogoPath;
     $absolutePath = $this->_configOptions->getDir('media') . DIRECTORY_SEPARATOR . $folderName . DIRECTORY_SEPARATOR . $storeLogoPath;
     if (!is_null($storeLogoPath) && $this->_isFile($absolutePath)) {
         $url = $logoUrl;
     } else {
         $url = $this->getViewFileUrl('images::logo.gif');
     }
     return $url;
 }
Exemple #4
0
 /**
  * @TODO Move logic into "EventSubscriber"
  *
  * @param OutputInterface $output
  * @return bool
  */
 public function checkVarDir(OutputInterface $output)
 {
     if (OutputInterface::VERBOSITY_NORMAL <= $output->getVerbosity()) {
         $tempVarDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'magento' . DIRECTORY_SEPARATOR . 'var';
         if (is_dir($tempVarDir)) {
             $this->detectMagento(null, $output);
             /* If magento is not installed yet, don't check */
             if ($this->_magentoRootFolder === null || !file_exists($this->_magentoRootFolder . '/app/etc/local.xml')) {
                 return;
             }
             try {
                 $this->initMagento();
             } catch (\Exception $e) {
                 $message = 'Cannot initialize Magento. Please check your configuration. ' . 'Some n98-magerun command will not work. Got message: ';
                 if (OutputInterface::VERBOSITY_VERY_VERBOSE <= $output->getVerbosity()) {
                     $message .= $e->getTraceAsString();
                 } else {
                     $message .= $e->getMessage();
                 }
                 $output->writeln($message);
                 return;
             }
             $configOptions = new \Mage_Core_Model_Config_Options();
             $currentVarDir = $configOptions->getVarDir();
             if ($currentVarDir == $tempVarDir) {
                 $output->writeln(sprintf('<warning>Fallback folder %s is used in n98-magerun</warning>', $tempVarDir));
                 $output->writeln('');
                 $output->writeln('n98-magerun is using the fallback folder. If there is another folder configured for Magento, this can cause serious problems.');
                 $output->writeln('Please refer to https://github.com/netz98/n98-magerun/wiki/File-system-permissions for more information.');
                 $output->writeln('');
             } else {
                 $output->writeln(sprintf('<warning>Folder %s found, but not used in n98-magerun</warning>', $tempVarDir));
                 $output->writeln('');
                 $output->writeln(sprintf('This might cause serious problems. n98-magerun is using the configured var-folder <comment>%s</comment>', $currentVarDir));
                 $output->writeln('Please refer to https://github.com/netz98/n98-magerun/wiki/File-system-permissions for more information.');
                 $output->writeln('');
                 return false;
             }
         }
     }
 }