16 private $storeManager;
31 private $paymentMethodList;
36 private $layoutProcessor;
48 $this->storeManager = $this
49 ->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
50 ->disableOriginalConstructor()
51 ->setMethods([
'getStore'])
52 ->getMockForAbstractClass();
54 ->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
55 ->disableOriginalConstructor()
56 ->setMethods([
'getId'])
57 ->getMockForAbstractClass();
58 $this->vaultList = $this
59 ->getMockBuilder(\
Magento\Vault\Api\PaymentMethodListInterface::class)
60 ->disableOriginalConstructor()
61 ->setMethods([
'getActiveList'])
62 ->getMockForAbstractClass();
63 $this->paymentMethodList = $this
64 ->getMockBuilder(\
Magento\Payment\Api\PaymentMethodListInterface::class)
65 ->disableOriginalConstructor()
66 ->setMethods([
'getActiveList'])
67 ->getMockForAbstractClass();
68 $this->layoutProcessor = $this
69 ->getMockBuilder(\
Magento\Checkout\Block\Checkout\LayoutProcessor::class)
70 ->disableOriginalConstructor()
71 ->setMethods([
'process'])
72 ->getMockForAbstractClass();
74 $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
75 $this->plugin = $objectManagerHelper->getObject(
76 \
Magento\Vault\Plugin\PaymentVaultConfigurationProcess::class,
78 'vaultPaymentList' => $this->vaultList,
79 'paymentMethodList' => $this->paymentMethodList,
80 'storeManager' => $this->storeManager
92 public function testBeforeProcess($jsLayout, $activeVaultList, $activePaymentList, $expectedResult)
94 $this->store->expects($this->once())->method(
'getId')->willReturn(1);
95 $this->storeManager->expects($this->once())->method(
'getStore')->willReturn($this->store);
96 $this->vaultList->expects($this->once())->method(
'getActiveList')->with(1)->willReturn($activeVaultList);
97 $this->paymentMethodList->expects($this->once())
98 ->method(
'getActiveList')
100 ->willReturn($activePaymentList);
101 $result = $this->plugin->beforeProcess($this->layoutProcessor, $jsLayout);
102 $this->assertEquals(
$result[0], $expectedResult);
112 $jsLayout[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step']
113 [
'children'][
'payment'][
'children'][
'renders'][
'children'] = [
119 'braintree_paypal' => [],
123 'paypal-payments' => [
130 $result1[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step']
131 [
'children'][
'payment'][
'children'][
'renders'][
'children'] = [];
132 $result2[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step']
133 [
'children'][
'payment'][
'children'][
'renders'][
'children'] = [
139 'braintree_paypal' => []
144 $vaultPaymentMethod = $this
145 ->getMockBuilder(\
Magento\Vault\Api\PaymentMethodListInterface::class)
146 ->disableOriginalConstructor()
147 ->setMethods([
'getCode',
'getProviderCode'])
148 ->getMockForAbstractClass();
150 $vaultPaymentMethod->expects($this->any())->method(
'getCode')->willReturn(
'braintree_paypal_vault');
151 $vaultPaymentMethod->expects($this->any())->method(
'getProviderCode')->willReturn(
'braintree_paypal');
154 [$jsLayout, [], [], $result1],
155 [$jsLayout, [$vaultPaymentMethod], [$vaultPaymentMethod], $result2]
beforeProcessDataProvider()
testBeforeProcess($jsLayout, $activeVaultList, $activePaymentList, $expectedResult)