|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hryvinskyi\QuoteAddressValidator\Test\Unit\Plugin; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
6
|
|
|
use Hryvinskyi\QuoteAddressValidator\Plugin\AddAttributesValidation; |
|
7
|
|
|
use Hryvinskyi\QuoteAddressValidator\Model\AddressValidationInterface; |
|
8
|
|
|
use Hryvinskyi\QuoteAddressValidator\Model\ConfigInterface; |
|
9
|
|
|
use Magento\Quote\Api\Data\AddressInterface; |
|
10
|
|
|
use Magento\Quote\Api\Data\CartInterface; |
|
11
|
|
|
use Magento\Quote\Model\QuoteAddressValidator; |
|
12
|
|
|
|
|
13
|
|
|
class AddAttributesValidationTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|AddressValidationInterface |
|
17
|
|
|
*/ |
|
18
|
|
|
private $addressValidationMock; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|ConfigInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
private $configMock; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var AddAttributesValidation |
|
27
|
|
|
*/ |
|
28
|
|
|
private $plugin; |
|
29
|
|
|
|
|
30
|
|
|
protected function setUp(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->addressValidationMock = $this->createMock(AddressValidationInterface::class); |
|
33
|
|
|
$this->configMock = $this->createMock(ConfigInterface::class); |
|
34
|
|
|
|
|
35
|
|
|
$this->plugin = new AddAttributesValidation( |
|
36
|
|
|
$this->addressValidationMock, |
|
37
|
|
|
$this->configMock |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testAfterValidateForCart() |
|
42
|
|
|
{ |
|
43
|
|
|
$quoteAddressValidatorMock = $this->createMock(QuoteAddressValidator::class); |
|
44
|
|
|
$cartMock = $this->createMock(CartInterface::class); |
|
45
|
|
|
$addressMock = $this->createMock(AddressInterface::class); |
|
46
|
|
|
|
|
47
|
|
|
$this->configMock->expects($this->once()) |
|
|
|
|
|
|
48
|
|
|
->method('isEnabled') |
|
49
|
|
|
->willReturn(true); |
|
50
|
|
|
|
|
51
|
|
|
$this->addressValidationMock->expects($this->once()) |
|
|
|
|
|
|
52
|
|
|
->method('validate') |
|
53
|
|
|
->with($addressMock); |
|
54
|
|
|
|
|
55
|
|
|
$this->plugin->afterValidateForCart($quoteAddressValidatorMock, null, $cartMock, $addressMock); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testAfterValidate() |
|
59
|
|
|
{ |
|
60
|
|
|
$quoteAddressValidatorMock = $this->createMock(QuoteAddressValidator::class); |
|
61
|
|
|
$addressMock = $this->createMock(AddressInterface::class); |
|
62
|
|
|
|
|
63
|
|
|
$this->configMock->expects($this->once()) |
|
64
|
|
|
->method('isEnabled') |
|
65
|
|
|
->willReturn(true); |
|
66
|
|
|
|
|
67
|
|
|
$this->addressValidationMock->expects($this->once()) |
|
68
|
|
|
->method('validate') |
|
69
|
|
|
->with($addressMock); |
|
70
|
|
|
|
|
71
|
|
|
$result = $this->plugin->afterValidate($quoteAddressValidatorMock, true, $addressMock); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertTrue($result); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths