Пример #1
0
 /**
  * @covers Mage_Core_Model_App_Emulation::startEnvironmentEmulation
  * @covers Mage_Core_Model_App_Emulation::stopEnvironmentEmulation
  */
 public function testEnvironmentEmulation()
 {
     $this->_model = Mage::getModel('Mage_Core_Model_App_Emulation');
     Mage::getDesign()->setArea(Mage_Core_Model_App_Area::AREA_ADMINHTML);
     $initialEnvInfo = $this->_model->startEnvironmentEmulation(1);
     $initialDesign = $initialEnvInfo->getInitialDesign();
     $this->assertEquals(Mage_Core_Model_App_Area::AREA_ADMINHTML, $initialDesign['area']);
     $this->assertEquals(Mage_Core_Model_App_Area::AREA_FRONTEND, Mage::getDesign()->getArea());
     $this->_model->stopEnvironmentEmulation($initialEnvInfo);
     $this->assertEquals(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage::getDesign()->getArea());
 }
Пример #2
0
 /**
  * rewrite class to bring back previous behaviour
  * to always reload locale on app emulation
  * since it can cause a bug when app emulation is triggered via
  * a cron job not loading non-english translations
  *
  * Apply locale of the specified store
  *
  * @param integer $storeId
  * @param string  $area
  *
  * @return string initial locale code
  */
 protected function _emulateLocale($storeId, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
 {
     if (php_sapi_name() == 'cli' && property_exists($this, '_app')) {
         $initialLocaleCode = $this->_app->getLocale()->getLocaleCode();
         $newLocaleCode = $this->_getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId);
         $this->_app->getLocale()->setLocaleCode($newLocaleCode);
         $this->_factory->getSingleton('core/translate')->setLocale($newLocaleCode)->init($area, true);
         return $initialLocaleCode;
     } else {
         return parent::_emulateLocale($storeId, $area);
     }
 }