initMagento() 공개 메소드

Loads and initializes the Magento application
public initMagento ( boolean $soft = false ) : boolean
$soft boolean
리턴 boolean false if magento root folder is not set, true otherwise
예제 #1
0
 /**
  * @return PHPUnit_Framework_MockObject_MockObject|Application
  */
 public function getApplication()
 {
     if ($this->application === null) {
         $root = $this->getTestMagentoRoot();
         $this->application = $this->getMock('N98\\Magento\\Application', array('getMagentoRootFolder'));
         $loader = (require __DIR__ . '/../../../../../vendor/autoload.php');
         $this->application->setAutoloader($loader);
         $this->application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
         $this->application->init();
         $this->application->initMagento();
         if ($this->application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
             spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         }
     }
     return $this->application;
 }
예제 #2
0
 /**
  * @throws \RuntimeException
  * @return PHPUnit_Framework_MockObject_MockObject|\N98\Magento\Application
  */
 public function getApplication()
 {
     if ($this->application === null) {
         $root = getenv('N98_MAGERUN_TEST_MAGENTO_ROOT');
         if (empty($root)) {
             throw new \RuntimeException('Please specify environment variable N98_MAGERUN_TEST_MAGENTO_ROOT with path to your test
                 magento installation!');
         }
         $this->application = $this->getMock('N98\\Magento\\Application', array('getMagentoRootFolder'));
         $loader = (require __DIR__ . '/../../../../../vendor/autoload.php');
         $this->application->setAutoloader($loader);
         $this->application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
         $this->application->init();
         $this->application->initMagento();
         if ($this->application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
             spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         }
     }
     return $this->application;
 }