当前位置: 首页>>代码示例>>PHP>>正文


PHP Observer::setEvent方法代码示例

本文整理汇总了PHP中Magento\Framework\Event\Observer::setEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::setEvent方法的具体用法?PHP Observer::setEvent怎么用?PHP Observer::setEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Event\Observer的用法示例。


在下文中一共展示了Observer::setEvent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetEvent

 public function testSetEvent()
 {
     $event = 'someEvent';
     $this->observer->setEvent($event);
     $result = $this->observer->getData('event');
     $this->assertEquals($result, $this->observer->getEvent($event));
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\Object();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->_authorization = $this->getMockForAbstractClass('Magento\\Framework\\AuthorizationInterface');
     $this->_model = new \Magento\Paypal\Model\Observer\RestrictAdminBillingAgreementUsage($this->_authorization);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:8,代码来源:RestrictAdminBillingAgreementUsageTest.php

示例3: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\DataObject();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->paypalConfigMock = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Observer\\AddPaypalShortcutsObserver', ['paypalConfig' => $this->paypalConfigMock]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:AddPaypalShortcutsObserverTest.php

示例4: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\DataObject();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->paypalDataMock = $this->getMock('\\Magento\\Paypal\\Helper\\Data', ['getHtmlTransactionId'], [], '', false);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Observer\\HtmlTransactionIdObserver', ['paypalData' => $this->paypalDataMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:HtmlTransactionIdObserverTest.php

示例5: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\DataObject();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->_agreementFactory = $this->getMock('Magento\\Paypal\\Model\\Billing\\AgreementFactory', ['create'], [], '', false);
     $this->_checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Observer\\AddBillingAgreementToSessionObserver', ['agreementFactory' => $this->_agreementFactory, 'checkoutSession' => $this->_checkoutSession]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:AddBillingAgreementToSessionObserverTest.php

示例6: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\Object();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->_authorization = $this->getMockForAbstractClass('Magento\\Framework\\AuthorizationInterface');
     $this->_agreementFactory = $this->getMock('Magento\\Paypal\\Model\\Billing\\AgreementFactory', array('create'), array(), '', false);
     $this->_checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', array(), array(), '', false);
     $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Model\\Observer', array('authorization' => $this->_authorization, 'agreementFactory' => $this->_agreementFactory, 'checkoutSession' => $this->_checkoutSession));
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:11,代码来源:ObserverTest.php

示例7: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\DataObject();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->coreRegistryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->paypalHssMock = $this->getMock('Magento\\Paypal\\Helper\\Hss', ['getHssMethods'], [], '', false);
     $this->viewMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\ViewInterface', [], '', false, true, true, []);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Observer\\SetResponseAfterSaveOrderObserver', ['coreRegistry' => $this->coreRegistryMock, 'paypalHss' => $this->paypalHssMock, 'view' => $this->viewMock]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:SetResponseAfterSaveOrderObserverTest.php

示例8: setUp

 public function setUp()
 {
     $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_event = new \Magento\Framework\Event();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->_customerSession = $this->getMockBuilder('Magento\\Customer\\Model\\Session')->disableOriginalConstructor()->setMethods(array('isLoggedIn'))->getMock();
     $this->_persistentSession = $this->getMockBuilder('Magento\\Persistent\\Helper\\Session')->disableOriginalConstructor()->setMethods(array('isPersistent'))->getMock();
     $this->_messageManager = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->disableOriginalConstructor()->setMethods(array())->getMock();
     $this->_url = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->disableOriginalConstructor()->setMethods(array())->getMock();
     $this->_expressRedirectHelper = $this->getMockBuilder('Magento\\Checkout\\Helper\\ExpressRedirect')->disableOriginalConstructor()->setMethods(array('redirectLogin'))->getMock();
     $this->_model = $helper->getObject('Magento\\Persistent\\Model\\Observer', array('customerSession' => $this->_customerSession, 'persistentSession' => $this->_persistentSession, 'messageManager' => $this->_messageManager, 'url' => $this->_url, 'expressRedirectHelper' => $this->_expressRedirectHelper));
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例9: setUp

 protected function setUp()
 {
     $this->_event = new \Magento\Framework\Object();
     $this->_observer = new \Magento\Framework\Event\Observer();
     $this->_observer->setEvent($this->_event);
     $this->_authorization = $this->getMockForAbstractClass('Magento\\Framework\\AuthorizationInterface');
     $this->_agreementFactory = $this->getMock('Magento\\Paypal\\Model\\Billing\\AgreementFactory', ['create'], [], '', false);
     $this->_checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->coreRegistryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->paypalHssMock = $this->getMock('Magento\\Paypal\\Helper\\Hss', ['getHssMethods'], [], '', false);
     $this->paypalDataMock = $this->getMock('\\Magento\\Paypal\\Helper\\Data', ['getHtmlTransactionId'], [], '', false);
     $this->viewMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\ViewInterface', [], '', false, true, true, []);
     $this->paypalConfigMock = $this->getMock('Magento\\Paypal\\Model\\Config', ['isMethodAvailable'], [], '', false);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Paypal\\Model\\Observer', ['authorization' => $this->_authorization, 'agreementFactory' => $this->_agreementFactory, 'checkoutSession' => $this->_checkoutSession, 'coreRegistry' => $this->coreRegistryMock, 'paypalHss' => $this->paypalHssMock, 'view' => $this->viewMock, 'paypalConfig' => $this->paypalConfigMock, 'paypalData' => $this->paypalDataMock]);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:16,代码来源:ObserverTest.php

示例10: testAddShortcutsButtons

 /**
  * @param array $blocks
  *
  * @dataProvider dataProviderShortcutsButtons
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testAddShortcutsButtons(array $blocks)
 {
     /** @var ShortcutButtons|\PHPUnit_Framework_MockObject_MockObject $shortcutButtonsMock */
     $shortcutButtonsMock = $this->getMockBuilder(ShortcutButtons::class)->setMethods(['getLayout', 'addShortcut'])->disableOriginalConstructor()->getMock();
     /** @var ShortcutButtons|\PHPUnit_Framework_MockObject_MockObject $shortcutButtonsMock */
     $eventMock = $this->getMockBuilder(DataObject::class)->setMethods(['getContainer', 'getCheckoutSession', 'getIsCatalogProduct', 'getOrPosition'])->disableOriginalConstructor()->getMock();
     $eventMock->expects(self::once())->method('getContainer')->willReturn($shortcutButtonsMock);
     $observer = new Observer();
     $observer->setEvent($eventMock);
     /** @var Config|\PHPUnit_Framework_MockObject_MockObject $paypalConfigMock */
     $paypalConfigMock = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
     /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $shortcutFactoryMock */
     $shortcutFactoryMock = $this->getMockBuilder(Factory::class)->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $model = new AddPaypalShortcutsObserver($shortcutFactoryMock, $paypalConfigMock);
     /** @var Layout|\PHPUnit_Framework_MockObject_MockObject $layoutMock */
     $layoutMock = $this->getMockBuilder(Layout::class)->setMethods(['createBlock'])->disableOriginalConstructor()->getMock();
     $callIndexBlock = 0;
     $callIndexShortcutFactory = 0;
     $callIndexAvailable = 0;
     $callIndexSession = 0;
     foreach ($blocks as $instanceName => $blockData) {
         $params = [];
         $paypalConfigMock->expects(self::at($callIndexAvailable))->method('isMethodAvailable')->with($blockData[self::PAYMENT_CODE])->willReturn($blockData[self::PAYMENT_AVAILABLE]);
         ++$callIndexAvailable;
         if (!$blockData[self::PAYMENT_AVAILABLE]) {
             continue;
         }
         ++$callIndexSession;
         $params['shortcutValidator'] = 'test-shortcut-validator';
         $shortcutFactoryMock->expects(self::at($callIndexShortcutFactory))->method('create')->with('test-checkout-session')->willReturn('test-shortcut-validator');
         ++$callIndexShortcutFactory;
         if (!$blockData[self::PAYMENT_IS_BML]) {
             $params['checkoutSession'] = 'test-checkout-session';
             ++$callIndexSession;
         }
         $blockMock = $this->getMockBuilder(Button::class)->setMethods(['setIsInCatalogProduct', 'setShowOrPosition'])->disableOriginalConstructor()->getMockForAbstractClass();
         $blockMock->expects(self::once())->method('setIsInCatalogProduct')->willReturnSelf();
         $blockMock->expects(self::once())->method('setShowOrPosition')->willReturnSelf();
         $layoutMock->expects(self::at($callIndexBlock))->method('createBlock')->with($instanceName, '', $params)->willReturn($blockMock);
         ++$callIndexBlock;
     }
     $shortcutButtonsMock->expects(self::exactly($callIndexBlock))->method('addShortcut')->with(self::isInstanceOf(ShortcutInterface::class));
     $shortcutButtonsMock->expects(self::exactly($callIndexBlock))->method('getLayout')->willReturn($layoutMock);
     $eventMock->expects(self::exactly($callIndexSession))->method('getCheckoutSession')->willReturn('test-checkout-session');
     $model->execute($observer);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:53,代码来源:AddPaypalShortcutsObserverTest.php


注:本文中的Magento\Framework\Event\Observer::setEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。