Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExpressConfigProviderTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ExpressConfigProviderTest extends \PHPUnit\Framework\TestCase
11 {
12  public function testGetConfig()
13  {
14  $localeResolver = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class);
15  $localeResolver->expects($this->once())->method('getLocale');
16 
17  $configFactory = $this->createPartialMock(\Magento\Paypal\Model\ConfigFactory::class, ['create']);
18 
19  $currentCustomer = $this->createMock(\Magento\Customer\Helper\Session\CurrentCustomer::class);
20  $currentCustomer->expects($this->atLeastOnce())->method('getCustomerId')->willReturn(12);
21 
22  $paymentHelper= $this->createMock(\Magento\Payment\Helper\Data::class);
23 
24  $paypalHelper = $this->createMock(\Magento\Paypal\Helper\Data::class);
25  $paypalHelper->expects($this->atLeastOnce())->method('shouldAskToCreateBillingAgreement')->willReturn(false);
26 
27  $config = $this->createMock(\Magento\Paypal\Model\Config::class);
28  $config->expects($this->once())->method('getPaymentMarkWhatIsPaypalUrl');
29  $config->expects($this->once())->method('getPaymentMarkImageUrl');
30  $config->expects($this->atLeastOnce())->method('setMethod');
31 
32  $configFactory->expects($this->once())->method('create')->willReturn($config);
33 
34  $payment = $this->getMockBuilder(\Magento\Paypal\Model\Payflowpro::class)
35  ->setMethods(['isAvailable', 'getCheckoutRedirectUrl'])
36  ->setMockClassName('paymentInstance')
37  ->disableOriginalConstructor()
38  ->getMock();
39  $payment->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);
40  $payment->expects($this->atLeastOnce())->method('getCheckoutRedirectUrl')->willReturn('http://redirect.url');
41  $paymentHelper->expects($this->atLeastOnce())->method('getMethodInstance')->willReturn($payment);
42 
44  $urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
45 
46  $configProvider = new ExpressConfigProvider(
48  $localeResolver,
49  $currentCustomer,
50  $paypalHelper,
51  $paymentHelper,
52  $urlBuilderMock
53  );
54  $configProvider->getConfig();
55  }
56 }
$config
Definition: fraud_order.php:17
$payment
Definition: order.php:17
$configFactory
Definition: config_data.php:43