6
6
namespace Magento \Vault \Test \Unit \Model ;
7
7
8
8
use Magento \Customer \Model \Session ;
9
- use Magento \Store \Api \Data \StoreInterface ;
10
- use Magento \Store \Model \StoreManagerInterface ;
11
9
use Magento \Vault \Api \Data \PaymentTokenInterface ;
12
10
use Magento \Vault \Model \CustomerTokenManagement ;
13
11
use Magento \Vault \Model \PaymentTokenManagement ;
14
- use Magento \ Vault \ Model \ VaultPaymentInterface ;
12
+ use PHPUnit_Framework_MockObject_MockObject as MockObject ;
15
13
16
14
class CustomerTokenManagementTest extends \PHPUnit_Framework_TestCase
17
15
{
18
16
/**
19
- * @var PaymentTokenManagement|\PHPUnit_Framework_MockObject_MockObject
17
+ * @var PaymentTokenManagement|MockObject
20
18
*/
21
- private $ paymentTokenManagementMock ;
19
+ private $ paymentTokenManagement ;
22
20
23
21
/**
24
- * @var Session|\PHPUnit_Framework_MockObject_MockObject
22
+ * @var Session|MockObject
25
23
*/
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 ;
42
25
43
26
/**
44
27
* @var CustomerTokenManagement
@@ -47,57 +30,38 @@ class CustomerTokenManagementTest extends \PHPUnit_Framework_TestCase
47
30
48
31
protected function setUp ()
49
32
{
50
- $ this ->paymentTokenManagementMock = $ this ->getMockBuilder (PaymentTokenManagement::class)
33
+ $ this ->paymentTokenManagement = $ this ->getMockBuilder (PaymentTokenManagement::class)
51
34
->disableOriginalConstructor ()
52
35
->getMock ();
53
- $ this ->customerSessionMock = $ this ->getMockBuilder (Session::class)
36
+ $ this ->customerSession = $ this ->getMockBuilder (Session::class)
54
37
->disableOriginalConstructor ()
55
38
->getMock ();
56
- $ this ->vaultPayment = $ this ->getMock (VaultPaymentInterface::class);
57
- $ this ->storeManager = $ this ->getMock (StoreManagerInterface::class);
58
- $ this ->store = $ this ->getMock (StoreInterface::class);
59
39
60
40
$ this ->tokenManagement = new CustomerTokenManagement (
61
- $ this ->vaultPayment ,
62
- $ this ->paymentTokenManagementMock ,
63
- $ this ->customerSessionMock ,
64
- $ this ->storeManager
41
+ $ this ->paymentTokenManagement ,
42
+ $ this ->customerSession
65
43
);
66
44
}
67
45
68
46
public function testGetCustomerSessionTokensNonRegisteredCustomer ()
69
47
{
70
- $ this ->customerSessionMock ->expects (self ::once ())
48
+ $ this ->customerSession ->expects (self ::once ())
71
49
->method ('getCustomerId ' )
72
50
->willReturn (null );
73
51
74
- $ this ->paymentTokenManagementMock ->expects (static ::never ())
52
+ $ this ->paymentTokenManagement ->expects (static ::never ())
75
53
->method ('getVisibleAvailableTokens ' );
76
54
77
55
$ this ->tokenManagement ->getCustomerSessionTokens ();
78
56
}
79
57
80
- public function testGetCustomerSessionTokensNoActiveVaultProvider ()
58
+ public function testGetCustomerSessionTokensForNotExistsCustomer ()
81
59
{
82
- $ customerId = 1 ;
83
- $ storeId = 1 ;
84
- $ this ->customerSessionMock ->expects (self ::once ())
60
+ $ this ->customerSession ->expects (static ::once ())
85
61
->method ('getCustomerId ' )
86
- ->willReturn ($ customerId );
62
+ ->willReturn (null );
87
63
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 ())
101
65
->method ('getVisibleAvailableTokens ' );
102
66
103
67
$ this ->tokenManagement ->getCustomerSessionTokens ();
@@ -106,34 +70,16 @@ public function testGetCustomerSessionTokensNoActiveVaultProvider()
106
70
public function testGetCustomerSessionTokens ()
107
71
{
108
72
$ customerId = 1 ;
109
- $ providerCode = 'vault_provider ' ;
110
- $ storeId = 1 ;
111
73
$ token = $ this ->getMock (PaymentTokenInterface::class);
112
74
$ expectation = [$ token ];
113
75
114
- $ this ->customerSessionMock ->expects (self ::once ())
76
+ $ this ->customerSession ->expects (static ::once ())
115
77
->method ('getCustomerId ' )
116
78
->willReturn ($ customerId );
117
79
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 ())
135
81
->method ('getVisibleAvailableTokens ' )
136
- ->with ($ customerId, $ providerCode )
82
+ ->with ($ customerId )
137
83
->willReturn ($ expectation );
138
84
139
85
static ::assertEquals (
0 commit comments