本文整理匯總了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);
}
示例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);
}
示例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);
}