當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::addSharedInstance方法代碼示例

本文整理匯總了PHP中Magento\TestFramework\ObjectManager::addSharedInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::addSharedInstance方法的具體用法?PHP ObjectManager::addSharedInstance怎麽用?PHP ObjectManager::addSharedInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\TestFramework\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::addSharedInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testThemeRegistration

 /**
  * Theme registration test
  *
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  */
 public function testThemeRegistration()
 {
     $themeRegistration = $this->getMock('Magento\\Theme\\Model\\Theme\\Registration', ['register'], [$this->_objectManager->create('Magento\\Theme\\Model\\ResourceModel\\Theme\\Data\\CollectionFactory'), $this->_objectManager->create('Magento\\Theme\\Model\\Theme\\Data\\Collection'), $this->_objectManager->create('Magento\\Framework\\Filesystem')]);
     $themeRegistration->expects($this->once())->method('register');
     $this->_objectManager->addSharedInstance($themeRegistration, 'Magento\\Theme\\Model\\Theme\\Registration');
     /** @var $observer \Magento\Theme\Observer\ThemeRegistrationObserver */
     $observer = $this->_objectManager->create('Magento\\Theme\\Observer\\ThemeRegistrationObserver');
     $observer->execute($this->_eventObserver);
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:15,代碼來源:ThemeRegistrationObserverTest.php

示例2: testThemeRegistration

 /**
  * Theme registration test
  *
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  */
 public function testThemeRegistration()
 {
     $pattern = 'path_pattern';
     $this->_eventObserver->getEvent()->setPathPattern($pattern);
     $themeRegistration = $this->getMock('Magento\\Theme\\Model\\Theme\\Registration', ['register'], [$this->_objectManager->create('Magento\\Theme\\Model\\Resource\\Theme\\Data\\CollectionFactory'), $this->_objectManager->create('Magento\\Theme\\Model\\Theme\\Data\\Collection'), $this->_objectManager->create('Magento\\Framework\\Filesystem')]);
     $themeRegistration->expects($this->once())->method('register')->with($this->equalTo($pattern));
     $this->_objectManager->addSharedInstance($themeRegistration, 'Magento\\Theme\\Model\\Theme\\Registration');
     /** @var $observer \Magento\Theme\Model\Observer */
     $observer = $this->_objectManager->create('Magento\\Theme\\Model\\Observer');
     $observer->themeRegistration($this->_eventObserver);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:17,代碼來源:ObserverTest.php

示例3: testTransDirective

 /**
  * @param $directive
  * @param $translations
  * @param $expectedResult
  * @internal param $translatorData
  * @dataProvider transDirectiveDataProvider
  */
 public function testTransDirective($directive, $translations, $expectedResult)
 {
     $renderer = Phrase::getRenderer();
     $translator = $this->getMockBuilder('\\Magento\\Framework\\Translate')->disableOriginalConstructor()->setMethods(['getData'])->getMock();
     $translator->expects($this->atLeastOnce())->method('getData')->will($this->returnValue($translations));
     $this->_objectManager->addSharedInstance($translator, 'Magento\\Framework\\Translate');
     $this->_objectManager->removeSharedInstance('Magento\\Framework\\Phrase\\Renderer\\Translate');
     Phrase::setRenderer($this->_objectManager->create('Magento\\Framework\\Phrase\\RendererInterface'));
     $this->assertEquals($expectedResult, $this->_model->filter($directive));
     Phrase::setRenderer($renderer);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:18,代碼來源:FilterTest.php


注:本文中的Magento\TestFramework\ObjectManager::addSharedInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。