|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Component\Payment\Resolver; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Component\Payment\Model\PaymentInterface; |
|
18
|
|
|
use Sylius\Component\Payment\Model\PaymentMethodInterface; |
|
19
|
|
|
use Sylius\Component\Payment\Resolver\PaymentMethodsResolverInterface; |
|
20
|
|
|
use Sylius\Component\Registry\PrioritizedServiceRegistryInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @author Anna Walasek <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
final class CompositeMethodsResolverSpec extends ObjectBehavior |
|
26
|
|
|
{ |
|
27
|
|
|
function let(PrioritizedServiceRegistryInterface $resolversRegistry): void |
|
28
|
|
|
{ |
|
29
|
|
|
$this->beConstructedWith($resolversRegistry); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function it_implements_Sylius_payment_methods_resolver_interface(): void |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$this->shouldImplement(PaymentMethodsResolverInterface::class); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function it_uses_registry_to_provide_payment_methods_for_payment( |
|
38
|
|
|
PaymentMethodsResolverInterface $firstMethodsResolver, |
|
39
|
|
|
PaymentMethodsResolverInterface $secondMethodsResolver, |
|
40
|
|
|
PrioritizedServiceRegistryInterface $resolversRegistry, |
|
41
|
|
|
PaymentMethodInterface $paymentMethod, |
|
42
|
|
|
PaymentInterface $payment |
|
43
|
|
|
): void { |
|
44
|
|
|
$resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); |
|
45
|
|
|
|
|
46
|
|
|
$firstMethodsResolver->supports($payment)->willReturn(false); |
|
47
|
|
|
$secondMethodsResolver->supports($payment)->willReturn(true); |
|
48
|
|
|
|
|
49
|
|
|
$secondMethodsResolver->getSupportedMethods($payment)->willReturn([$paymentMethod]); |
|
50
|
|
|
|
|
51
|
|
|
$this->getSupportedMethods($payment)->shouldReturn([$paymentMethod]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
function it_returns_empty_array_if_none_of_registered_resolvers_support_passed_payment( |
|
55
|
|
|
PaymentMethodsResolverInterface $firstMethodsResolver, |
|
56
|
|
|
PaymentMethodsResolverInterface $secondMethodsResolver, |
|
57
|
|
|
PrioritizedServiceRegistryInterface $resolversRegistry, |
|
58
|
|
|
PaymentInterface $payment |
|
59
|
|
|
): void { |
|
60
|
|
|
$resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); |
|
61
|
|
|
|
|
62
|
|
|
$firstMethodsResolver->supports($payment)->willReturn(false); |
|
63
|
|
|
$secondMethodsResolver->supports($payment)->willReturn(false); |
|
64
|
|
|
|
|
65
|
|
|
$this->getSupportedMethods($payment)->shouldReturn([]); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
function it_supports_payment_if_at_least_one_registered_resolver_supports_it( |
|
69
|
|
|
PaymentMethodsResolverInterface $firstMethodsResolver, |
|
70
|
|
|
PaymentMethodsResolverInterface $secondMethodsResolver, |
|
71
|
|
|
PrioritizedServiceRegistryInterface $resolversRegistry, |
|
72
|
|
|
PaymentInterface $payment |
|
73
|
|
|
): void { |
|
74
|
|
|
$resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); |
|
75
|
|
|
|
|
76
|
|
|
$firstMethodsResolver->supports($payment)->willReturn(false); |
|
77
|
|
|
$secondMethodsResolver->supports($payment)->willReturn(true); |
|
78
|
|
|
|
|
79
|
|
|
$this->supports($payment)->shouldReturn(true); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
function it_does_not_support_payment_if_none_of_registered_resolvers_supports_it( |
|
83
|
|
|
PaymentMethodsResolverInterface $firstMethodsResolver, |
|
84
|
|
|
PaymentMethodsResolverInterface $secondMethodsResolver, |
|
85
|
|
|
PrioritizedServiceRegistryInterface $resolversRegistry, |
|
86
|
|
|
PaymentInterface $payment |
|
87
|
|
|
): void { |
|
88
|
|
|
$resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); |
|
89
|
|
|
|
|
90
|
|
|
$firstMethodsResolver->supports($payment)->willReturn(false); |
|
91
|
|
|
$secondMethodsResolver->supports($payment)->willReturn(false); |
|
92
|
|
|
|
|
93
|
|
|
$this->supports($payment)->shouldReturn(false); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.