@@ -76,30 +76,45 @@ protected function setUp()
76
76
}
77
77
78
78
/**
79
- * Run test getConfig method
79
+ * Ensure that get config returns correct data if payment is active or not
80
80
*
81
81
* @param array $config
82
82
* @param array $expected
83
83
* @dataProvider getConfigDataProvider
84
84
*/
85
85
public function testGetConfig ($ config , $ expected )
86
86
{
87
- $ this ->braintreeAdapter ->expects (static ::once ())
88
- ->method ('generate ' )
89
- ->willReturn (self ::CLIENT_TOKEN );
87
+ if ($ config ['isActive ' ]) {
88
+ $ this ->braintreeAdapter ->expects ($ this ->once ())
89
+ ->method ('generate ' )
90
+ ->willReturn (self ::CLIENT_TOKEN );
91
+ } else {
92
+ $ config = array_replace_recursive (
93
+ $ this ->getConfigDataProvider ()[0 ]['config ' ],
94
+ $ config
95
+ );
96
+ $ expected = array_replace_recursive (
97
+ $ this ->getConfigDataProvider ()[0 ]['expected ' ],
98
+ $ expected
99
+ );
100
+ $ this ->braintreeAdapter ->expects ($ this ->never ())
101
+ ->method ('generate ' );
102
+ }
90
103
91
104
foreach ($ config as $ method => $ value ) {
92
- $ this ->config ->expects (static :: once ())
105
+ $ this ->config ->expects ($ this -> once ())
93
106
->method ($ method )
94
107
->willReturn ($ value );
95
108
}
96
109
97
- static :: assertEquals ($ expected , $ this ->configProvider ->getConfig ());
110
+ $ this -> assertEquals ($ expected , $ this ->configProvider ->getConfig ());
98
111
}
99
112
100
113
/**
101
- * @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
114
+ * @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
102
115
* @dataProvider getClientTokenDataProvider
116
+ * @param $merchantAccountId
117
+ * @param $params
103
118
*/
104
119
public function testGetClientToken ($ merchantAccountId , $ params )
105
120
{
@@ -124,7 +139,7 @@ public function getConfigDataProvider()
124
139
[
125
140
'config ' => [
126
141
'isActive ' => true ,
127
- 'getCcTypesMapper ' => ['visa ' => 'VI ' , 'american-express ' => 'AE ' ],
142
+ 'getCcTypesMapper ' => ['visa ' => 'VI ' , 'american-express ' => 'AE ' ],
128
143
'getSdkUrl ' => self ::SDK_URL ,
129
144
'getHostedFieldsSdkUrl ' => 'https://sdk.com/test.js ' ,
130
145
'getCountrySpecificCardTypeConfig ' => [
@@ -148,7 +163,7 @@ public function getConfigDataProvider()
148
163
'ccTypesMapper ' => ['visa ' => 'VI ' , 'american-express ' => 'AE ' ],
149
164
'sdkUrl ' => self ::SDK_URL ,
150
165
'hostedFieldsSdkUrl ' => 'https://sdk.com/test.js ' ,
151
- 'countrySpecificCardTypes ' =>[
166
+ 'countrySpecificCardTypes ' => [
152
167
'GB ' => ['VI ' , 'AE ' ],
153
168
'US ' => ['DI ' , 'JCB ' ]
154
169
],
@@ -166,6 +181,19 @@ public function getConfigDataProvider()
166
181
]
167
182
]
168
183
]
184
+ ],
185
+ [
186
+ 'config ' => [
187
+ 'isActive ' => false ,
188
+ ],
189
+ 'expected ' => [
190
+ 'payment ' => [
191
+ ConfigProvider::CODE => [
192
+ 'isActive ' => false ,
193
+ 'clientToken ' => null ,
194
+ ]
195
+ ]
196
+ ]
169
197
]
170
198
];
171
199
}
0 commit comments