30 $this->configMock = $this->getMockBuilder(\
Magento\Payment\Gateway\ConfigInterface::class)
31 ->getMockForAbstractClass();
32 $this->resultFactoryMock = $this->getMockBuilder(
34 )->setMethods([
'create'])
35 ->disableOriginalConstructor()
37 $this->resultMock = $this->getMockBuilder(\
Magento\Payment\Gateway\
Validator\Result::class)
38 ->disableOriginalConstructor()
41 $this->model = new \Magento\Payment\Gateway\Validator\CountryValidator(
42 $this->resultFactoryMock,
52 $validationSubject = [
'storeId' =>
$storeId,
'country' => $country];
54 $this->configMock->expects($this->at(0))
57 ->willReturn($allowspecific);
58 $this->configMock->expects($this->at(1))
61 ->willReturn($specificcountry);
63 $this->resultFactoryMock->expects($this->once())
65 ->with([
'isValid' => $isValid,
'failsDescription' => [],
'errorCodes' => []])
66 ->willReturn($this->resultMock);
68 $this->assertSame($this->resultMock, $this->model->validate($validationSubject));
77 [1,
'US', 1,
'US,UK,CA',
true],
78 [1,
'BJ', 1,
'US,UK,CA',
false]
87 $validationSubject = [
'storeId' =>
$storeId];
89 $this->configMock->expects($this->at(0))
92 ->willReturn($allowspecific);
94 $this->resultFactoryMock->expects($this->once())
96 ->with([
'isValid' => $isValid,
'failsDescription' => [],
'errorCodes' => []])
97 ->willReturn($this->resultMock);
99 $this->assertSame($this->resultMock, $this->model->validate($validationSubject));
validateAllowspecificTrueDataProvider()
validateAllowspecificFalseDataProvider()
testValidateAllowspecificFalse($storeId, $allowspecific, $isValid)
testValidateAllowspecificTrue($storeId, $country, $allowspecific, $specificcountry, $isValid)