本文整理汇总了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));
}
示例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);
}
示例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]);
}
示例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]);
}
示例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]);
}
示例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));
}
示例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]);
}
示例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));
}
示例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]);
}
示例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);
}