Пример #1
0
 public function testSetEvent()
 {
     $event = 'someEvent';
     $this->observer->setEvent($event);
     $result = $this->observer->getData('event');
     $this->assertEquals($result, $this->observer->getEvent($event));
 }
 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);
 }
 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]);
 }
 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]);
 }
 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
0
 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));
 }
 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
0
 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
0
 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]);
 }
 /**
  * @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);
 }