/**
  * @param array $paymentMethodsAvailability
  * @param array $blocks
  * @dataProvider addAvailabilityOfMethodsDataProvider
  */
 public function testAddPaypalShortcuts($paymentMethodsAvailability, $blocks)
 {
     $this->paypalConfigMock->expects($this->any())->method('isMethodAvailable')->will($this->returnValueMap($paymentMethodsAvailability));
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->setMethods(['createBlock'])->disableOriginalConstructor()->getMock();
     $shortcutButtonsMock = $this->getMockBuilder('Magento\\Catalog\\Block\\ShortcutButtons')->setMethods(['getLayout', 'addShortcut'])->disableOriginalConstructor()->getMock();
     $blockInstances = [];
     $atPosition = 0;
     foreach ($blocks as $blockName => $blockInstance) {
         if ($this->paypalConfigMock->isMethodAvailable($blockInstance[1])) {
             $block = $this->getMockBuilder($blockInstance[0])->setMethods(null)->disableOriginalConstructor()->getMock();
             $blockInstances[$blockName] = $block;
             $layoutMock->expects(new MethodInvokedAtIndex($atPosition))->method('createBlock')->with($blockName)->will($this->returnValue($block));
             $atPosition++;
         }
     }
     $shortcutButtonsMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $atPosition = 0;
     foreach ($blocks as $blockName => $blockInstance) {
         if ($this->paypalConfigMock->isMethodAvailable($blockInstance[1])) {
             $shortcutButtonsMock->expects(new MethodInvokedAtIndex($atPosition))->method('addShortcut')->with($this->identicalTo($blockInstances[$blockName]));
             $atPosition++;
         }
     }
     $this->_event->setContainer($shortcutButtonsMock);
     $this->_model->execute($this->_observer);
 }
 /**
  * @expectedException \Magento\Framework\Model\Exception
  */
 public function testInitialize()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->infoInstance->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->paypalConfig->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('build notation code'));
     $this->payflowRequest->expects($this->once())->method('setData')->with('BNCODE', 'build notation code')->will($this->returnSelf());
     $this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, new \Magento\Framework\Object());
 }
 public function testInitialize()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->infoInstance->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->infoInstance->expects($this->any())->method('setAdditionalInformation')->will($this->returnSelf());
     $this->paypalConfig->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('build notation code'));
     $response = new \Magento\Framework\DataObject(['result' => '0', 'pnref' => 'V19A3D27B61E', 'respmsg' => 'Approved', 'authcode' => '510PNI', 'hostcode' => 'A', 'request_id' => 'f930d3dc6824c1f7230c5529dc37ae5e', 'result_code' => '0']);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($response);
     $this->payflowRequest->expects($this->exactly(3))->method('setData')->willReturnMap([['user' => null, 'vendor' => null, 'partner' => null, 'pwd' => null, 'verbosity' => null, 'BNCODE' => 'build notation code', 'tender' => 'C'], $this->returnSelf()], ['USER1', 1, $this->returnSelf()], ['USER2', 'a20d3dc6824c1f7780c5529dc37ae5e', $this->returnSelf()]);
     $stateObject = new \Magento\Framework\DataObject();
     $this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, $stateObject);
 }
 protected function setUp()
 {
     $this->paypalConfig = $this->getMock(Config::class, [], [], '', false);
     $this->paypalConfig->expects($this->once())->method('setMethod')->will($this->returnSelf());
     $this->paypalConfig->expects($this->once())->method('setMethod')->with(Config::METHOD_EXPRESS);
     $paypalConfigFactory = $this->getMock(ConfigFactory::class, ['create'], [], '', false);
     $paypalConfigFactory->expects($this->once())->method('create')->will($this->returnValue($this->paypalConfig));
     $customerId = 20;
     $this->currentCustomer = $this->getMock(CurrentCustomer::class, [], [], '', false);
     $this->currentCustomer->expects($this->any())->method('getCustomerId')->willReturn($customerId);
     $this->paypalData = $this->getMock(Data::class, [], [], '', false);
     $helper = new ObjectManager($this);
     $this->billingAgreement = $helper->getObject(BillingAgreement::class, ['paypalConfigFactory' => $paypalConfigFactory, 'paypalData' => $this->paypalData, 'currentCustomer' => $this->currentCustomer]);
 }
Example #5
0
 protected function setUp()
 {
     $this->_paypalConfig = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
     $this->_paypalConfig->expects($this->once())->method('setMethod')->will($this->returnSelf());
     $paypalConfigFactory = $this->getMock('Magento\\Paypal\\Model\\ConfigFactory', ['create'], [], '', false);
     $paypalConfigFactory->expects($this->once())->method('create')->will($this->returnValue($this->_paypalConfig));
     $mark = $this->getMock('Magento\\Framework\\View\\Element\\Template', [], [], '', false);
     $mark->expects($this->once())->method('setTemplate')->will($this->returnSelf());
     $mark->expects($this->any())->method('__call')->will($this->returnSelf());
     $layout = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface');
     $layout->expects($this->once())->method('createBlock')->with('Magento\\Framework\\View\\Element\\Template')->will($this->returnValue($mark));
     $localeResolver = $this->getMock('Magento\\Framework\\Locale\\ResolverInterface', [], [], '', false, false);
     $helper = new ObjectManager($this);
     $this->_model = $helper->getObject('Magento\\Paypal\\Block\\PayflowExpress\\Form', ['paypalConfigFactory' => $paypalConfigFactory, 'layout' => $layout, 'localeResolver' => $localeResolver]);
 }
Example #6
0
 protected function setUp()
 {
     $this->_paypalData = $this->getMock('Magento\\Paypal\\Helper\\Data', [], [], '', false);
     $this->_paypalConfig = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
     $this->_paypalConfig->expects($this->once())->method('setMethod')->will($this->returnSelf());
     $paypalConfigFactory = $this->getMock('Magento\\Paypal\\Model\\ConfigFactory', ['create'], [], '', false);
     $paypalConfigFactory->expects($this->once())->method('create')->will($this->returnValue($this->_paypalConfig));
     $mark = $this->getMock('Magento\\Framework\\View\\Element\\Template', array(), array(), '', false);
     $mark->expects($this->once())->method('setTemplate')->will($this->returnSelf());
     $mark->expects($this->any())->method('__call')->will($this->returnSelf());
     $layout = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface');
     $layout->expects($this->once())->method('createBlock')->with('Magento\\Framework\\View\\Element\\Template')->will($this->returnValue($mark));
     $this->currentCustomer = $this->getMockBuilder('\\Magento\\Customer\\Helper\\Session\\CurrentCustomer')->disableOriginalConstructor()->getMock();
     $localeResolver = $this->getMock('Magento\\Framework\\Locale\\ResolverInterface', array(), array(), '', false, false);
     $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $helper->getObject('Magento\\Paypal\\Block\\Express\\Form', array('paypalData' => $this->_paypalData, 'paypalConfigFactory' => $paypalConfigFactory, 'currentCustomer' => $this->currentCustomer, 'layout' => $layout, 'localeResolver' => $localeResolver));
 }