1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace spec\BitBag\SyliusQuadPayPlugin\Validator\Constraints; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusQuadPayPlugin\QuadPayGatewayFactory; |
16
|
|
|
use BitBag\SyliusQuadPayPlugin\Validator\Constraints\OrderAmount; |
17
|
|
|
use BitBag\SyliusQuadPayPlugin\Validator\Constraints\OrderAmountValidator; |
18
|
|
|
use Payum\Core\Model\GatewayConfigInterface; |
19
|
|
|
use PhpSpec\ObjectBehavior; |
20
|
|
|
use Sylius\Component\Core\Model\PaymentInterface; |
21
|
|
|
use Sylius\Component\Core\Model\PaymentMethodInterface; |
22
|
|
|
use Symfony\Component\Validator\ConstraintValidator; |
23
|
|
|
use Symfony\Component\Validator\Context\ExecutionContextInterface; |
24
|
|
|
|
25
|
|
|
final class OrderAmountValidatorSpec extends ObjectBehavior |
26
|
|
|
{ |
27
|
|
|
function let(ExecutionContextInterface $executionContextInterface): void |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$this->initialize($executionContextInterface); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_is_initializable(): void |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$this->shouldHaveType(OrderAmountValidator::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_extends_constraint_validator_class(): void |
38
|
|
|
{ |
39
|
|
|
$this->shouldHaveType(ConstraintValidator::class); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
function it_validates( |
43
|
|
|
PaymentMethodInterface $paymentMethod, |
44
|
|
|
GatewayConfigInterface $gatewayConfig, |
45
|
|
|
PaymentInterface $payment |
46
|
|
|
): void { |
47
|
|
|
$orderAmountConstraint = new OrderAmount(); |
48
|
|
|
$gatewayConfig->getFactoryName()->willReturn(QuadPayGatewayFactory::FACTORY_NAME); |
|
|
|
|
49
|
|
|
$paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$this->validate($payment, $orderAmountConstraint); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.