|
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\Twig\Extension; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusQuadPayPlugin\QuadPayGatewayFactory; |
|
16
|
|
|
use BitBag\SyliusQuadPayPlugin\Repository\PaymentMethodRepositoryInterface; |
|
17
|
|
|
use BitBag\SyliusQuadPayPlugin\Twig\Extension\RenderWidgetExtension; |
|
18
|
|
|
use Payum\Core\Model\GatewayConfigInterface; |
|
19
|
|
|
use PhpSpec\ObjectBehavior; |
|
20
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
|
21
|
|
|
use Sylius\Component\Core\Model\PaymentMethodInterface; |
|
22
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
|
23
|
|
|
|
|
24
|
|
|
final class RenderWidgetExtensionSpec extends ObjectBehavior |
|
25
|
|
|
{ |
|
26
|
|
|
function let( |
|
|
|
|
|
|
27
|
|
|
PaymentMethodRepositoryInterface $paymentMethodRepository, |
|
28
|
|
|
EngineInterface $templatingEngine |
|
29
|
|
|
): void { |
|
30
|
|
|
$this->beConstructedWith($paymentMethodRepository, $templatingEngine); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function it_is_initializable(): void |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$this->shouldHaveType(RenderWidgetExtension::class); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function it_extends_twig_extension(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$this->shouldHaveType(\Twig_Extension::class); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function it_returns_functions(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$functions = $this->getFunctions(); |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
$functions->shouldHaveCount(1); |
|
48
|
|
|
|
|
49
|
|
|
/** @var \Twig_SimpleFunction $function */ |
|
50
|
|
|
$function = $functions[0]; |
|
51
|
|
|
|
|
52
|
|
|
$function->shouldHaveType(\Twig_SimpleFunction::class); |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
$function->getName()->shouldReturn('bitbag_quadpay_render_widget'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
function it_renders_quadpay_widget( |
|
58
|
|
|
ChannelInterface $channel, |
|
59
|
|
|
EngineInterface $templatingEngine, |
|
60
|
|
|
PaymentMethodRepositoryInterface $paymentMethodRepository, |
|
61
|
|
|
PaymentMethodInterface $paymentMethod, |
|
62
|
|
|
GatewayConfigInterface $gatewayConfig |
|
63
|
|
|
): void { |
|
64
|
|
|
$gatewayConfig->getConfig()->willReturn([ |
|
65
|
|
|
'minimumAmount' => 300, |
|
66
|
|
|
'maximumAmount' => 3000, |
|
67
|
|
|
]); |
|
68
|
|
|
$paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); |
|
|
|
|
|
|
69
|
|
|
$paymentMethodRepository->findOneByGatewayFactoryNameAndChannel(QuadPayGatewayFactory::FACTORY_NAME, $channel)->willReturn($paymentMethod); |
|
|
|
|
|
|
70
|
|
|
$templatingEngine->render('@BitBagSyliusQuadPayPlugin/_widget.html.twig', [ |
|
71
|
|
|
'amount' => 100, |
|
72
|
|
|
'paymentMethod' => $paymentMethod, |
|
73
|
|
|
'minAmount' => 300, |
|
74
|
|
|
'maxAmount' => 3000, |
|
75
|
|
|
])->willReturn('<div>BitBag</div>'); |
|
76
|
|
|
|
|
77
|
|
|
$this->renderQuadPayWidget(100, $channel)->shouldReturn('<div>BitBag</div>'); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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.