Skip to content

Commit e8b29c7

Browse files
committed
MAGETWO-53238: Vault Provider field contains Payflow Pro option in countries which don't have such solution
- Fixed failed unit tests
1 parent fd7f15a commit e8b29c7

File tree

8 files changed

+300
-260
lines changed

8 files changed

+300
-260
lines changed

app/code/Magento/Braintree/Test/Unit/Block/FormTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
use Magento\Braintree\Model\Adminhtml\Source\CcType;
1212
use Magento\Braintree\Model\Ui\ConfigProvider;
1313
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use Magento\Payment\Helper\Data;
1415
use Magento\Payment\Model\Config;
15-
use Magento\Vault\Model\Ui\VaultConfigProvider;
16+
use Magento\Store\Api\Data\StoreInterface;
17+
use Magento\Store\Model\StoreManagerInterface;
1618
use Magento\Vault\Model\VaultPaymentInterface;
1719
use OAuthTest\Mocks\Common\Service\Mock;
1820
use PHPUnit_Framework_MockObject_MockObject as MockObject;
19-
use Magento\Store\Model\StoreManagerInterface;
20-
use Magento\Store\Api\Data\StoreInterface;
21-
use Magento\Payment\Helper\Data;
2221

2322
/**
2423
* Class FormTest

app/code/Magento/Vault/Model/Ui/TokensConfigProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ final class TokensConfigProvider implements ConfigProviderInterface
2323
*/
2424
private static $vaultCode = 'vault';
2525

26-
/**
27-
* @var VaultPaymentInterface
28-
*/
29-
private $vaultPayment;
30-
3126
/**
3227
* @var StoreManagerInterface
3328
*/
@@ -52,17 +47,14 @@ final class TokensConfigProvider implements ConfigProviderInterface
5247
* Constructor
5348
*
5449
* @param StoreManagerInterface $storeManager
55-
* @param VaultPaymentInterface $vaultPayment
5650
* @param CustomerTokenManagement $customerTokenManagement
5751
* @param TokenUiComponentProviderInterface[] $tokenUiComponentProviders
5852
*/
5953
public function __construct(
6054
StoreManagerInterface $storeManager,
61-
VaultPaymentInterface $vaultPayment,
6255
CustomerTokenManagement $customerTokenManagement,
6356
array $tokenUiComponentProviders = []
6457
) {
65-
$this->vaultPayment = $vaultPayment;
6658
$this->storeManager = $storeManager;
6759
$this->tokenUiComponentProviders = $tokenUiComponentProviders;
6860
$this->customerTokenManagement = $customerTokenManagement;

app/code/Magento/Vault/Test/Unit/Model/CustomerTokenManagementTest.php

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,22 @@
66
namespace Magento\Vault\Test\Unit\Model;
77

88
use Magento\Customer\Model\Session;
9-
use Magento\Store\Api\Data\StoreInterface;
10-
use Magento\Store\Model\StoreManagerInterface;
119
use Magento\Vault\Api\Data\PaymentTokenInterface;
1210
use Magento\Vault\Model\CustomerTokenManagement;
1311
use Magento\Vault\Model\PaymentTokenManagement;
14-
use Magento\Vault\Model\VaultPaymentInterface;
12+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1513

1614
class CustomerTokenManagementTest extends \PHPUnit_Framework_TestCase
1715
{
1816
/**
19-
* @var PaymentTokenManagement|\PHPUnit_Framework_MockObject_MockObject
17+
* @var PaymentTokenManagement|MockObject
2018
*/
21-
private $paymentTokenManagementMock;
19+
private $paymentTokenManagement;
2220

2321
/**
24-
* @var Session|\PHPUnit_Framework_MockObject_MockObject
22+
* @var Session|MockObject
2523
*/
26-
private $customerSessionMock;
27-
28-
/**
29-
* @var VaultPaymentInterface|\PHPUnit_Framework_MockObject_MockObject
30-
*/
31-
private $vaultPayment;
32-
33-
/**
34-
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
35-
*/
36-
private $storeManager;
37-
38-
/**
39-
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
40-
*/
41-
private $store;
24+
private $customerSession;
4225

4326
/**
4427
* @var CustomerTokenManagement
@@ -47,57 +30,38 @@ class CustomerTokenManagementTest extends \PHPUnit_Framework_TestCase
4730

4831
protected function setUp()
4932
{
50-
$this->paymentTokenManagementMock = $this->getMockBuilder(PaymentTokenManagement::class)
33+
$this->paymentTokenManagement = $this->getMockBuilder(PaymentTokenManagement::class)
5134
->disableOriginalConstructor()
5235
->getMock();
53-
$this->customerSessionMock = $this->getMockBuilder(Session::class)
36+
$this->customerSession = $this->getMockBuilder(Session::class)
5437
->disableOriginalConstructor()
5538
->getMock();
56-
$this->vaultPayment = $this->getMock(VaultPaymentInterface::class);
57-
$this->storeManager = $this->getMock(StoreManagerInterface::class);
58-
$this->store = $this->getMock(StoreInterface::class);
5939

6040
$this->tokenManagement = new CustomerTokenManagement(
61-
$this->vaultPayment,
62-
$this->paymentTokenManagementMock,
63-
$this->customerSessionMock,
64-
$this->storeManager
41+
$this->paymentTokenManagement,
42+
$this->customerSession
6543
);
6644
}
6745

6846
public function testGetCustomerSessionTokensNonRegisteredCustomer()
6947
{
70-
$this->customerSessionMock->expects(self::once())
48+
$this->customerSession->expects(self::once())
7149
->method('getCustomerId')
7250
->willReturn(null);
7351

74-
$this->paymentTokenManagementMock->expects(static::never())
52+
$this->paymentTokenManagement->expects(static::never())
7553
->method('getVisibleAvailableTokens');
7654

7755
$this->tokenManagement->getCustomerSessionTokens();
7856
}
7957

80-
public function testGetCustomerSessionTokensNoActiveVaultProvider()
58+
public function testGetCustomerSessionTokensForNotExistsCustomer()
8159
{
82-
$customerId = 1;
83-
$storeId = 1;
84-
$this->customerSessionMock->expects(self::once())
60+
$this->customerSession->expects(static::once())
8561
->method('getCustomerId')
86-
->willReturn($customerId);
62+
->willReturn(null);
8763

88-
$this->storeManager->expects(static::once())
89-
->method('getStore')
90-
->with(null)
91-
->willReturn($this->store);
92-
$this->store->expects(static::once())
93-
->method('getId')
94-
->willReturn($storeId);
95-
$this->vaultPayment->expects(static::once())
96-
->method('isActive')
97-
->with($storeId)
98-
->willReturn(false);
99-
100-
$this->paymentTokenManagementMock->expects(static::never())
64+
$this->paymentTokenManagement->expects(static::never())
10165
->method('getVisibleAvailableTokens');
10266

10367
$this->tokenManagement->getCustomerSessionTokens();
@@ -106,34 +70,16 @@ public function testGetCustomerSessionTokensNoActiveVaultProvider()
10670
public function testGetCustomerSessionTokens()
10771
{
10872
$customerId = 1;
109-
$providerCode = 'vault_provider';
110-
$storeId = 1;
11173
$token = $this->getMock(PaymentTokenInterface::class);
11274
$expectation = [$token];
11375

114-
$this->customerSessionMock->expects(self::once())
76+
$this->customerSession->expects(static::once())
11577
->method('getCustomerId')
11678
->willReturn($customerId);
11779

118-
$this->storeManager->expects(static::once())
119-
->method('getStore')
120-
->with(null)
121-
->willReturn($this->store);
122-
$this->store->expects(static::once())
123-
->method('getId')
124-
->willReturn($storeId);
125-
$this->vaultPayment->expects(static::once())
126-
->method('isActive')
127-
->with($storeId)
128-
->willReturn(true);
129-
$this->vaultPayment->expects(static::once())
130-
->method('getProviderCode')
131-
->with($storeId)
132-
->willReturn($providerCode);
133-
134-
$this->paymentTokenManagementMock->expects(static::once())
80+
$this->paymentTokenManagement->expects(static::once())
13581
->method('getVisibleAvailableTokens')
136-
->with($customerId, $providerCode)
82+
->with($customerId)
13783
->willReturn($expectation);
13884

13985
static::assertEquals(

0 commit comments

Comments
 (0)