示例#1
0
 /**
  * Ensure reports directory exists, empty, and has write permissions
  *
  * @throws Magento_Exception
  */
 public function cleanupReports()
 {
     $reportDir = $this->_config->getReportDir();
     if (file_exists($reportDir) && !Varien_Io_File::rmdirRecursive($reportDir)) {
         throw new Magento_Exception("Cannot cleanup reports directory '{$reportDir}'.");
     }
     mkdir($reportDir, 0777, true);
 }
示例#2
0
 public static function setUpBeforeClass()
 {
     $fixtureDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files';
     Mage::app()->getConfig()->getOptions()->setDesignDir($fixtureDir . DIRECTORY_SEPARATOR . 'design');
     Varien_Io_File::rmdirRecursive(Mage::app()->getConfig()->getOptions()->getMediaDir() . '/skin');
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->cp(Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.js', Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.min.js');
     self::$_developerMode = Mage::getIsDeveloperMode();
 }
示例#3
0
 protected function tearDown()
 {
     /** @var $config Mage_Core_Model_Config */
     $config = Mage::getObjectManager()->get('Mage_Core_Model_Config');
     $generationDirectory = $config->getVarDir() . '/generation';
     Varien_Io_File::rmdirRecursive($generationDirectory);
     set_include_path($this->_includePath);
     unset($this->_generator);
 }
示例#4
0
 protected function setUp()
 {
     Mage::app()->getConfig()->getOptions()->setDesignDir(dirname(__DIR__) . '/_files/design');
     Varien_Io_File::rmdirRecursive(Mage::app()->getConfig()->getOptions()->getMediaDir() . '/skin');
     $this->_model = new Mage_Core_Model_Design_Package();
     //$this->_model->setArea('frontend')->setDesignTheme('package/default/theme');
     $pub = Mage::getBaseDir('media');
     $this->_pubMerged = "{$pub}/skin/_merged";
     $this->_pubLib = Mage::getBaseDir('js');
     // emulate source skin
     $this->_skinFixture = dirname(__DIR__) . '/_files/skin';
 }
示例#5
0
 public function testRmdirRecursive()
 {
     try {
         $this->_prepare();
         $this->assertFileExists($this->_file);
         Varien_Io_File::rmdirRecursive($this->_dir);
         $this->assertFileNotExists($this->_dir);
     } catch (Exception $e) {
     }
     $this->_cleanup();
     if (isset($e)) {
         throw $e;
     }
 }
示例#6
0
 protected function _initMergerCssDir($dirRelativeName, $cleanup = false)
 {
     $skinDir = Mage::getBaseDir('skin');
     try {
         $dir = Mage::getBaseDir('skin') . DS . $dirRelativeName;
         if ($cleanup) {
             Varien_Io_File::rmdirRecursive($dir);
             Mage::helper('core/file_storage_database')->deleteFolder($dir);
         }
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         return is_writeable($dir) ? $dir : false;
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return false;
 }
示例#7
0
 public function testCleanupReports()
 {
     $fixtureDir = $this->_getBaseFixtureDir() . '/config_dist';
     $reportDir = $fixtureDir . '/report';
     mkdir($reportDir, 0777);
     try {
         $reportFile = $reportDir . '/a.jtl';
         touch($reportFile);
         $this->assertFileExists($reportFile);
         $bootstrap = new Magento_Performance_Bootstrap($fixtureDir, $fixtureDir);
         $bootstrap->cleanupReports();
         $this->assertFileNotExists($reportFile);
         $this->assertFileExists($reportDir);
         Varien_Io_File::rmdirRecursive($reportDir);
     } catch (Exception $e) {
         Varien_Io_File::rmdirRecursive($reportDir);
         throw $e;
     }
 }
示例#8
0
 /**
  * Remove all merged js/css files
  *
  * @return  bool
  */
 public function cleanMergedJsCss()
 {
     $dir = $this->_buildPublicSkinFilename(self::PUBLIC_MERGE_DIR);
     $result = Varien_Io_File::rmdirRecursive($dir);
     $result = $result && Mage::helper('Mage_Core_Helper_File_Storage_Database')->deleteFolder($dir);
     return $result;
 }
示例#9
0
 public static function tearDownAfterClass()
 {
     $config = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config');
     Varien_Io_File::rmdirRecursive($config->getBaseMediaPath());
     Varien_Io_File::rmdirRecursive($config->getBaseTmpMediaPath());
 }
示例#10
0
 public static function setUpBeforeClass()
 {
     $fixtureDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files';
     Mage::app()->getConfig()->getOptions()->setDesignDir($fixtureDir . DIRECTORY_SEPARATOR . 'design');
     Varien_Io_File::rmdirRecursive(Mage::app()->getConfig()->getOptions()->getMediaDir() . '/skin');
 }
示例#11
0
 /**
  * Clear old log files and folders
  *
  * @param Mage_Cron_Model_Schedule $schedule
  * @param bool $forceRun
  * @return bool
  */
 public function scheduledLogClean($schedule, $forceRun = false)
 {
     $result = false;
     if (!Mage::getStoreConfig(self::CRON_STRING_PATH) && (!$forceRun || !Mage::getStoreConfig(self::LOG_CLEANING_ENABLE_PATH))) {
         return;
     }
     try {
         $logPath = Mage::getConfig()->getOptions()->getVarDir() . DS . Enterprise_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY;
         if (!file_exists($logPath) || !is_dir($logPath)) {
             if (!mkdir($logPath, 0777, true)) {
                 Mage::throwException(Mage::helper('enterprise_importexport')->__('Unable to create directory "%s".', $logPath));
             }
         }
         if (!is_dir($logPath) || !is_writable($logPath)) {
             Mage::throwException(Mage::helper('enterprise_importexport')->__('Directory "%s" is not writable.', $logPath));
         }
         $saveTime = (int) Mage::getStoreConfig(self::SAVE_LOG_TIME_PATH) + 1;
         $dateCompass = new DateTime('-' . $saveTime . ' days');
         foreach ($this->_getDirectoryList($logPath) as $directory) {
             $separator = str_replace('\\', '\\\\', DS);
             if (!preg_match("~(\\d{4}){$separator}(\\d{2}){$separator}(\\d{2})\$~", $directory, $matches)) {
                 continue;
             }
             $direcotryDate = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3]);
             if ($forceRun || $direcotryDate < $dateCompass) {
                 $fs = new Varien_Io_File();
                 if (!$fs->rmdirRecursive($directory, true)) {
                     $directory = str_replace(Mage::getBaseDir() . DS, '', $directory);
                     Mage::throwException(Mage::helper('enterprise_importexport')->__('Unable to delete "%s". Directory is not writable.', $directory));
                 }
             }
         }
         $result = true;
     } catch (Exception $e) {
         $this->_sendEmailNotification(array('warnings' => $e->getMessage()));
     }
     return $result;
 }
示例#12
0
 public static function tearDownAfterClass()
 {
     Varien_Io_File::rmdirRecursive(self::$_mediaTmpDir);
     Varien_Io_File::rmdirRecursive(self::$_mediaDir);
 }
示例#13
0
 /**
  * createTmpDir
  * 
  * @return Ambigous <boolean, string>|boolean
  * @author "Justus Krapp <*****@*****.**>"
  */
 private function createTmpDir()
 {
     try {
         $dir = $this->getTmpDir();
         Varien_Io_File::rmdirRecursive($dir);
         Mage::helper('core/file_storage_database')->deleteFolder($dir);
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         return is_writeable($dir) ? $dir : false;
     } catch (Exception $e) {
         Mage::getSingleton('ecocode_minify/log')->logError($e->getMessage(), $e->getTraceAsString());
     }
     return false;
 }
示例#14
0
$baseDir = realpath(__DIR__ . '/../../../');
$configFile = $args['build_properties_file'];
$configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist";
$config = (require $configFile);
$installOptions = isset($config['install_options']) ? $config['install_options'] : array();
$reportDir = __DIR__ . '/' . $config['report_dir'];
/* Install application */
if ($installOptions) {
    $installCmd = sprintf('php -f %s --', escapeshellarg("{$baseDir}/dev/shell/install.php"));
    foreach ($installOptions as $optionName => $optionValue) {
        $installCmd .= sprintf(' --%s %s', $optionName, escapeshellarg($optionValue));
    }
    passthru($installCmd, $exitCode);
    if ($exitCode) {
        exit($exitCode);
    }
}
/* Initialize Magento application */
require_once __DIR__ . '/../../../app/bootstrap.php';
Mage::app();
/* Clean reports */
Varien_Io_File::rmdirRecursive($reportDir);
/* Run all indexer processes */
/** @var $indexer Mage_Index_Model_Indexer */
$indexer = Mage::getModel('Mage_Index_Model_Indexer');
/** @var $process Mage_Index_Model_Process */
foreach ($indexer->getProcessesCollection() as $process) {
    if ($process->getIndexer()->isVisible()) {
        $process->reindexEverything();
    }
}
示例#15
0
 public static function tearDownAfterClass()
 {
     Varien_Io_File::rmdirRecursive(self::$_pubJslib);
 }
示例#16
0
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     unit_tests
 * @copyright   Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require __DIR__ . '/../../../../app/code/core/Mage/Core/functions.php';
require __DIR__ . '/../../../../app/autoload.php';
Magento_Autoload_IncludePath::addIncludePath(array(__DIR__, realpath(__DIR__ . '/../testsuite'), realpath(__DIR__ . '/../../../../app'), realpath(__DIR__ . '/../../../../app/code/core'), realpath(__DIR__ . '/../../../../lib')));
define('TESTS_TEMP_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tmp');
if (is_dir(TESTS_TEMP_DIR)) {
    Varien_Io_File::rmdirRecursive(TESTS_TEMP_DIR);
}
mkdir(TESTS_TEMP_DIR);
Mage::setIsSerializable(false);
示例#17
0
 */
$testsBaseDir = realpath(__DIR__ . '/..');
$magentoBaseDir = realpath($testsBaseDir . '/../../../');
require_once "{$magentoBaseDir}/app/bootstrap.php";
Magento_Autoload::getInstance()->addIncludePath("{$testsBaseDir}/framework");
$configFile = "{$testsBaseDir}/config.php";
$configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist";
$configData = (require $configFile);
$config = new Magento_Config($configData, $testsBaseDir);
$installOptions = $config->getInstallOptions();
if ($installOptions) {
    // Populate install options with global options
    $baseUrl = 'http://' . $config->getApplicationUrlHost() . $config->getApplicationUrlPath();
    $installOptions = array_merge($installOptions, array('url' => $baseUrl, 'secure_base_url' => $baseUrl));
    $adminOptions = $config->getAdminOptions();
    foreach ($adminOptions as $key => $val) {
        $installOptions['admin_' . $key] = $val;
    }
    // Install application
    $installer = new Magento_Installer($magentoBaseDir . '/dev/shell/install.php', new Magento_Shell(true));
    echo 'Uninstalling application' . PHP_EOL;
    $installer->uninstall();
    echo "Installing application at '{$baseUrl}'" . PHP_EOL;
    $installer->install($installOptions, $config->getFixtureFiles());
    echo PHP_EOL;
}
$reportDir = $config->getReportDir();
if (file_exists($reportDir) && !Varien_Io_File::rmdirRecursive($reportDir)) {
    throw new Magento_Exception("Cannot cleanup reports directory '{$reportDir}'.");
}
return $config;
示例#18
0
文件: Data.php 项目: nemphys/magento2
 /**
  * Delete all service folders from var directory
  */
 public function cleanVarFolder()
 {
     foreach ($this->getVarSubFolders() as $folder) {
         Varien_Io_File::rmdirRecursive($folder);
     }
 }
示例#19
0
 /**
  * Cleanup media import and catalog directories
  */
 public static function mediaImportImageFixtureRollback()
 {
     $media = Mage::getBaseDir('media');
     Varien_Io_File::rmdirRecursive("{$media}/import");
     Varien_Io_File::rmdirRecursive("{$media}/catalog");
 }
示例#20
0
 public function testRmdirRecursive()
 {
     $this->assertFileExists($this->_file);
     Varien_Io_File::rmdirRecursive($this->_dir);
     $this->assertFileNotExists($this->_dir);
 }
示例#21
0
 protected function tearDown()
 {
     Varien_Io_File::rmdirRecursive(self::$_skinPublicDir);
     $this->_model = null;
 }
示例#22
0
 /**
  * Make sure merger dir exists and writeable
  * Also can clean it up
  *
  * @param string $dirRelativeName
  * @param bool $cleanup
  */
 protected function _initMergerDir($dirRelativeName, $cleanup = false)
 {
     $mediaDir = Mage::getBaseDir('media');
     try {
         $dir = Mage::getBaseDir('media') . DS . $dirRelativeName;
         if ($cleanup) {
             Varien_Io_File::rmdirRecursive($dir);
         }
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         return is_writeable($dir) ? $dir : false;
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return false;
 }
示例#23
0
 public static function tearDownAfterClass()
 {
     Varien_Io_File::rmdirRecursive(self::$_fixtureMediaDir);
     Varien_Io_File::rmdirRecursive(Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config')->getBaseTmpMediaPath());
 }
示例#24
0
        fwrite($fh, "  - " . $file . PHP_EOL);
    }
}
fwrite($fh, "test:" . PHP_EOL);
foreach ($testFiles as $file) {
    fwrite($fh, "  - " . $file . PHP_EOL);
}
if (count($serveFiles) > 0) {
    fwrite($fh, "serve:" . PHP_EOL);
    foreach ($serveFiles as $file) {
        fwrite($fh, "  - " . $file . PHP_EOL);
    }
}
fclose($fh);
$testOutput = __DIR__ . '/test-output';
Varien_Io_File::rmdirRecursive($testOutput);
mkdir($testOutput);
$command = 'java -jar ' . $jsTestDriver . ' --config ' . $jsTestDriverConf . ' --port ' . $port . ' --browser "' . $browser . '" --tests all --testOutput ' . $testOutput;
echo $command . PHP_EOL;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    system($command);
} else {
    $shellCommand = '#!/bin/bash
        LSOF=`/usr/sbin/lsof -i :' . $port . ' -t`
        if [ "$LSOF" != "" ];
        then
            kill -9 $LSOF
        fi

        pkill Xvfb
        XVFB=`which Xvfb`
示例#25
0
 /**
  * Make sure merger dir exists and writeable
  * Also can clean it up
  *
  * @param string $dirRelativeName
  * @param bool   $cleanup
  * @return bool
  */
 protected function _initMergerDir($dirRelativeName, $cleanup = false)
 {
     $mediaDir = Mage::getBaseDir('media');
     //inCase its warm up mode change dir
     if ($this->isWarmUp()) {
         $mediaDir = Mage::getBaseDir('tmp') . DS . Ecocode_Minify_Model_Observer::$tmpFolder;
         if (!is_dir($mediaDir)) {
             mkdir($mediaDir);
         }
     }
     try {
         $dir = $mediaDir . DS . $dirRelativeName;
         if ($cleanup) {
             Varien_Io_File::rmdirRecursive($dir);
             Mage::helper('core/file_storage_database')->deleteFolder($dir);
         }
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         return is_writeable($dir) ? $dir : false;
     } catch (Exception $e) {
         Mage::getSingleton('ecocode_minify/log')->logError($e->getMessage(), $e->getTraceAsString());
     }
     return false;
 }
示例#26
0
<?php

/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  integration_tests
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$config = Mage::getSingleton('Mage_Catalog_Model_Product_Media_Config');
Varien_Io_File::rmdirRecursive($config->getBaseMediaPath());
Varien_Io_File::rmdirRecursive($config->getBaseTmpMediaPath());
示例#27
0
 public function tearDown()
 {
     // Delete a directory, where tests do some temporary work
     $tmpDir = $this->_getBaseFixtureDir() . '/config_dist/tmp';
     Varien_Io_File::rmdirRecursive($tmpDir);
 }
示例#28
0
 /**
  * Uninstall the application
  *
  * @return bool
  */
 public function uninstall()
 {
     if (!Mage::isInstalled()) {
         return false;
     }
     $this->_cleanUpDatabase();
     /* Remove temporary directories */
     $configOptions = Mage::app()->getConfig()->getOptions();
     $dirsToRemove = array($configOptions->getCacheDir(), $configOptions->getSessionDir(), $configOptions->getExportDir(), $configOptions->getLogDir(), $configOptions->getVarDir() . '/report');
     foreach ($dirsToRemove as $dir) {
         Varien_Io_File::rmdirRecursive($dir);
     }
     /* Remove local configuration */
     unlink($configOptions->getEtcDir() . '/local.xml');
     return true;
 }
示例#29
0
 public function tearDown()
 {
     Varien_Io_File::rmdirRecursive(self::$_tmpMediaDir);
     parent::tearDown();
 }
示例#30
0
 /**
  * Rmdir cache directory.
  */
 protected function rmdir($dirname)
 {
     $dirname = $this->cacheDir . '/' . $dirname;
     return Varien_Io_File::rmdirRecursive($dirname);
 }