Esempio n. 1
0
 public function testGetTransactionUrlTest()
 {
     $this->prepare();
     $expected = 'https://test.url';
     $methodInstance = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->getMockForAbstractClass();
     $methodInstance->expects($this->exactly(2))->method('getConfigData')->willReturnMap([['sandbox_flag', null, true], ['cgi_url_test_mode', null, $expected]]);
     $this->paymentDataMock->expects($this->exactly(2))->method('getMethodInstance')->willReturn($methodInstance);
     $block = new \Magento\Paypal\Block\Payflow\Link\Iframe($this->contextMock, $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, $this->paymentDataMock);
     $this->assertEquals($expected, $block->getTransactionUrl());
 }
 /**
  * @dataProvider methodAvailabilityDataProvider
  * @param bool $availability
  */
 public function testIsMethodQuoteAvailableWithQuoteMethodNotAvailable($availability)
 {
     $quote = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods([])->getMock();
     $isInCatalog = false;
     $paymentCode = 'code';
     $methodInstanceMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($paymentCode)->will($this->returnValue($methodInstanceMock));
     $methodInstanceMock->expects($this->once())->method('isAvailable')->with($quote)->will($this->returnValue($availability));
     $this->assertEquals($availability, $this->checkoutValidator->isMethodQuoteAvailable($paymentCode, $isInCatalog));
 }
Esempio n. 3
0
 public function testPrepareDataSource()
 {
     $itemName = 'itemName';
     $oldItemValue = 'oldItemValue';
     $newItemValue = 'newItemValue';
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
     $payment = $this->getMockForAbstractClass('Magento\\Payment\\Model\\MethodInterface');
     $payment->expects($this->once())->method('getTitle')->willReturn($newItemValue);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($oldItemValue)->willReturn($payment);
     $this->model->setData('name', $itemName);
     $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
 /**
  * @param int $customerId
  * @param bool $vaultEnabled
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $vaultPaymentCode = 'vault_payment';
     $expectedConfiguration = ['vault' => [$vaultPaymentCode => ['is_enabled' => $vaultEnabled]]];
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::exactly(2))->method('getStore')->willReturn($this->store);
     $this->store->expects(static::exactly(2))->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('getCode')->willReturn($vaultPaymentCode);
     $this->vaultPayment->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     static::assertEquals($expectedConfiguration, $this->vaultConfigProvider->getConfig());
 }
 public function testGetConfigAvailable()
 {
     $redirectUrl = 'http://redirect.url';
     $paytypes = ['paytypes'];
     $expectedConfig = ['payment' => ['orbaPayupl' => ['redirectUrl' => $redirectUrl, 'paytypes' => $paytypes]]];
     $paymentMethodMock = $this->getPaymentMethodMock();
     $paymentMethodMock->expects($this->once())->method('isAvailable')->willReturn(true);
     $paymentMethodMock->expects($this->once())->method('getCheckoutRedirectUrl')->willReturn($redirectUrl);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($this->equalTo('orba_payupl'))->willReturn($paymentMethodMock);
     $quote = $this->getMockBuilder(\Magento\Quote\Api\Data\CartInterface::class)->getMock();
     $this->checkoutSession->expects($this->once())->method('getQuote')->willReturn($quote);
     $this->paytypeHelper->expects($this->once())->method('getAllForQuote')->with($this->equalTo($quote))->willReturn($paytypes);
     $this->assertEquals($expectedConfig, $this->model->getConfig());
 }
 public function testToHtmlMethodSetBmlData()
 {
     $isInCatalog = true;
     $paymentMethodCode = '';
     $bmlMethodCode = '';
     $hash = 'hash';
     $this->shortcut->setIsInCatalogProduct($isInCatalog);
     $expressMethod = $this->getMockBuilder('Magento\\Paypal\\Model\\Express')->disableOriginalConstructor()->setMethods([])->getMock();
     $expectedData = ['is_in_catalog_product' => $isInCatalog, 'shortcut_html_id' => $hash, 'checkout_url' => null, 'image_url' => 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png', 'additional_link_image' => ['href' => 'https://www.securecheckout.billmelater.com/paycapture-content/' . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html', 'src' => 'https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png']];
     $this->paypalShortcutHelperMock->expects($this->once())->method('validate')->with($paymentMethodCode, $isInCatalog)->will($this->returnValue(true));
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($bmlMethodCode)->will($this->returnValue($expressMethod));
     $expressMethod->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
     $this->randomMock->expects($this->once())->method('getUniqueHash')->with('ec_shortcut_bml_')->will($this->returnValue($hash));
     $this->assertEmpty($this->shortcut->toHtml());
     $this->assertContains($expectedData, $this->shortcut->getData());
 }
Esempio n. 7
0
 public function testGetMethodInstanceRequestedMethod()
 {
     $code = 'real_method';
     $this->info->setData('method', $code);
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($code)->willReturn($this->methodInstanceMock);
     $this->methodInstanceMock->expects($this->once())->method('setInfoInstance')->with($this->info);
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
     // as the method is already stored at Info, check that it's not initialized again
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
 }
Esempio n. 8
0
 /**
  * @covers \Magento\Braintree\Block\Form::isVaultEnabled
  */
 public function testIsVaultEnabled()
 {
     $storeId = 1;
     $store = $this->getMockForAbstractClass(StoreInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->willReturn($store);
     $store->expects(static::once())->method('getId')->willReturn($storeId);
     $vaultPayment = $this->getMockForAbstractClass(VaultPaymentInterface::class);
     $this->paymentDataHelper->expects(static::once())->method('getMethodInstance')->with(ConfigProvider::CC_VAULT_CODE)->willReturn($vaultPayment);
     $vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     static::assertTrue($this->block->isVaultEnabled());
 }
Esempio n. 9
0
 public function testGetMethodInstanceRequestedMethod()
 {
     $code = 'unreal_method';
     $this->info->setData('method', $code);
     $methodInstance = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->disableOriginalConstructor()->setMethods(['setInfoInstance', 'getCode', 'getFormBlockType', 'getTitle'])->getMock();
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($code)->will($this->returnValue($methodInstance));
     $methodInstance->expects($this->once())->method('setInfoInstance')->with($this->info);
     $this->assertSame($methodInstance, $this->info->getMethodInstance());
     // as the method is already stored at Info, check that it's not initialized again
     $this->assertSame($methodInstance, $this->info->getMethodInstance());
 }
 public function testGetConfig()
 {
     $storeId = 1;
     $vaultProviderCode = 'vault_provider_code';
     $expectedConfig = ['payment' => ['vault' => [$vaultProviderCode . '_item_' . '0' => ['config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component']]]];
     $token = $this->getMockForAbstractClass(PaymentTokenInterface::class);
     $tokenUiComponentProvider = $this->getMockForAbstractClass(TokenUiComponentProviderInterface::class);
     $tokenUiComponent = $this->getMockForAbstractClass(TokenUiComponentInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     $this->vaultPayment->expects(static::once())->method('getProviderCode')->willReturn($vaultProviderCode);
     $this->customerTokenManagement->expects(static::once())->method('getCustomerSessionTokens')->willReturn([$token]);
     $token->expects(static::once())->method('getPaymentMethodCode')->willReturn($vaultProviderCode);
     $tokenUiComponentProvider->expects(static::once())->method('getComponentForToken')->with($token)->willReturn($tokenUiComponent);
     $tokenUiComponent->expects(static::once())->method('getConfig')->willReturn(['token_code' => 'code']);
     $tokenUiComponent->expects(static::once())->method('getName')->willReturn('Vendor_Module/js/vault_component');
     $configProvider = new TokensConfigProvider($this->storeManager, $this->customerTokenManagement, [$vaultProviderCode => $tokenUiComponentProvider]);
     $this->objectManager->setBackwardCompatibleProperty($configProvider, 'paymentDataHelper', $this->paymentDataHelper);
     static::assertEquals($expectedConfig, $configProvider->getConfig());
 }
 /**
  * @covers \Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider::getTokensComponents
  */
 public function testGetTokensComponentsEmptyComponentProvider()
 {
     $storeId = 1;
     $customerId = 2;
     $vaultPaymentCode = 'vault_payment';
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->initStoreMock();
     $this->paymentDataHelper->expects(static::once())->method('getMethodInstance')->with($vaultPaymentCode)->willReturn($this->vaultPayment);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(false);
     $this->paymentTokenRepository->expects(static::never())->method('getList');
     $configProvider = new TokensConfigProvider($this->session, $this->paymentTokenRepository, $this->filterBuilder, $this->searchCriteriaBuilder, $this->storeManager, $this->dateTimeFactory);
     $this->objectManager->setBackwardCompatibleProperty($configProvider, 'paymentDataHelper', $this->paymentDataHelper);
     static::assertEmpty($configProvider->getTokensComponents($vaultPaymentCode));
 }