Example #1
0
 /**
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($configData, $locale, $expectedResult)
 {
     foreach ($configData as $key => $value) {
         $this->configMock->expects($this->any())->method($key)->willReturn($value);
     }
     $this->localResolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
     $this->assertEquals($expectedResult, $this->model->getConfig());
 }
Example #2
0
 public function testDispatchButtonNotEnabled()
 {
     $resultRedirect = new \Magento\Framework\DataObject();
     $this->braintreePayPalConfigMock->expects($this->once())->method('isActive')->willReturn(true);
     $this->braintreePayPalConfigMock->expects($this->once())->method('isShortcutCheckoutEnabled')->willReturn(false);
     $this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($resultRedirect);
     $this->assertEquals($resultRedirect, $this->controller->execute($this->requestMock));
     $this->assertEquals('noRoute', $resultRedirect->getPath());
 }
 public function testAddPaypalShortcutsNotEnabled()
 {
     $orPosition = 'before';
     $containerMock = $this->getMockBuilder('\\Magento\\Catalog\\Block\\ShortcutButtons')->disableOriginalConstructor()->getMock();
     $event = new \Magento\Framework\DataObject(['is_catalog_product' => false, 'container' => $containerMock, 'or_position' => $orPosition]);
     $observer = new \Magento\Framework\Event\Observer(['event' => $event]);
     $this->paypalMethodMock->expects($this->once())->method('isActive')->willReturn(true);
     $this->paypalConfigMock->expects($this->once())->method('isShortcutCheckoutEnabled')->willReturn(false);
     $containerMock->expects($this->never())->method('getLayout');
     $this->addPaypalShortcutsObserver->execute($observer);
 }
Example #4
0
 public function testExecuteValidationFailure()
 {
     $paymentMethodNonce = 'nonce';
     $email = '*****@*****.**';
     $billingAddress = ['someAddress'];
     $details = ['email' => $email, 'billingAddress' => $billingAddress];
     $detailsEncoded = json_encode($details);
     $this->braintreePayPalConfigMock->expects($this->once())->method('isBillingAddressEnabled')->willReturn(true);
     $this->requestMock->expects($this->at(0))->method('getParam')->with('payment_method_nonce')->willReturn($paymentMethodNonce);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('details')->willReturn($detailsEncoded);
     $this->setupCart();
     $errorMessage = new \Magento\Framework\Phrase('Selected payment type is not allowed for billing country.');
     $this->paymentMethodInstanceMock->expects($this->once())->method('validate')->willThrowException(new \Magento\Framework\Exception\LocalizedException($errorMessage));
     $this->messageManagerMock->expects($this->once())->method('addError')->with(new \Magento\Framework\Phrase('Selected payment type is not allowed for billing country.'));
     $resultRedirect = $this->getMockBuilder('\\Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultRedirect->expects($this->once())->method('setPath')->with('checkout/cart')->willReturnSelf();
     $this->resultFactoryMock->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirect);
     $this->assertEquals($resultRedirect, $this->controller->execute());
 }
Example #5
0
 public function testGetConfigData()
 {
     $field = 'configFieldName';
     $storeId = '2';
     $configValue = 'configValue';
     $this->payPalConfigMock->expects($this->once())->method('getConfigData')->with($field, $storeId)->willReturn($configValue);
     $this->assertEquals($configValue, $this->model->getConfigData($field, $storeId));
 }
Example #6
0
 public function testEnableBillingAddress()
 {
     $flag = true;
     $this->paypalConfigMock->expects($this->once())->method('isBillingAddressEnabled')->willReturn($flag);
     $this->assertEquals($flag, $this->block->enableBillingAddress());
 }