Esempio n. 1
0
 public function testConstructorCleanupRestoreDb()
 {
     $this->_db->expects($this->exactly(1))->method('restoreBackup')->with(Magento_Test_Bootstrap::DB_BACKUP_NAME);
     $this->_callBootstrapConstructor(null, Magento_Test_Bootstrap::CLEANUP_RESTORE_DB);
 }
Esempio n. 2
0
 /**
  * Install application using temporary directory and vendor-specific database settings
  */
 protected function _install()
 {
     $this->_ensureDirExists($this->_installDir);
     $this->_ensureDirExists($this->_installEtcDir);
     $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'media');
     $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'skin');
     /* Copy *.xml configuration files */
     $dirs = array($this->_installEtcDir => $this->_globalEtcFiles, $this->_installEtcDir . '/modules' => $this->_moduleEtcFiles);
     foreach ($dirs as $targetEtcDir => $sourceEtcFiles) {
         $this->_ensureDirExists($targetEtcDir);
         foreach ($sourceEtcFiles as $sourceEtcFile) {
             $targetEtcFile = $targetEtcDir . '/' . basename($sourceEtcFile);
             copy($sourceEtcFile, $targetEtcFile);
         }
     }
     /* Make sure that local.xml contains an invalid installation date */
     $installDate = (string) $this->_localXml->global->install->date;
     if ($installDate && strtotime($installDate)) {
         throw new Exception("Configuration file '{$this->_localXmlFile}' must contain an invalid installation date.");
     }
     /* Replace local.xml */
     $targetLocalXml = $this->_installEtcDir . '/local.xml';
     copy($this->_localXmlFile, $targetLocalXml);
     /* Initialize an application in non-installed mode */
     $this->initialize();
     /* Run all install and data-install scripts */
     Mage_Core_Model_Resource_Setup::applyAllUpdates();
     Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
     /* Enable configuration cache by default in order to improve tests performance */
     Mage::app()->getCacheInstance()->saveOptions(array('config' => 1));
     /* Fill installation date in local.xml to indicate that application is installed */
     $localXml = file_get_contents($targetLocalXml);
     $localXml = str_replace($installDate, date('r'), $localXml, $replacementCount);
     if ($replacementCount != 1) {
         throw new Exception("Unable to replace installation date properly in '{$targetLocalXml}' file.");
     }
     file_put_contents($targetLocalXml, $localXml, LOCK_EX);
     /* Make a database backup to be able to restore it to initial state any time */
     $this->_db->createBackup(self::DB_BACKUP_NAME);
     /* Switch an application to installed mode */
     $this->initialize();
     /**
      * Initialization of front controller with all routers.
      * Should be here as needed only once after installation process. 
      */
     Mage::app()->getFrontController();
 }
Esempio n. 3
0
 /**
  * Perform the application cleanup
  */
 protected function _cleanup()
 {
     $this->_db->cleanup();
     $this->_cleanupFilesystem();
 }
Esempio n. 4
0
 public function testConstructorCleanupEnabled()
 {
     $this->_db->expects($this->once())->method('cleanup');
     $this->_bootstrap->expects($this->once())->method('_cleanupFilesystem');
     $this->_callBootstrapConstructor(null, true);
 }