當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。