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\Shipping\Resolver; |
15
|
|
|
|
16
|
|
|
use Doctrine\Common\Persistence\ObjectRepository; |
17
|
|
|
use PhpSpec\ObjectBehavior; |
18
|
|
|
use Sylius\Component\Shipping\Checker\ShippingMethodEligibilityCheckerInterface; |
19
|
|
|
use Sylius\Component\Shipping\Model\ShippingMethodInterface; |
20
|
|
|
use Sylius\Component\Shipping\Model\ShippingSubjectInterface; |
21
|
|
|
use Sylius\Component\Shipping\Resolver\ShippingMethodsResolverInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
final class ShippingMethodsResolverSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function let( |
29
|
|
|
ObjectRepository $methodRepository, |
30
|
|
|
ShippingMethodEligibilityCheckerInterface $eligibilityChecker |
31
|
|
|
): void { |
32
|
|
|
$this->beConstructedWith($methodRepository, $eligibilityChecker); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_implements_Sylius_shipping_methods_resolver_interface(): void |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$this->shouldImplement(ShippingMethodsResolverInterface::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function it_returns_all_methods_eligible_for_given_subject( |
41
|
|
|
ObjectRepository $methodRepository, |
42
|
|
|
ShippingMethodEligibilityCheckerInterface $eligibilityChecker, |
43
|
|
|
ShippingSubjectInterface $subject, |
44
|
|
|
ShippingMethodInterface $method1, |
45
|
|
|
ShippingMethodInterface $method2, |
46
|
|
|
ShippingMethodInterface $method3 |
47
|
|
|
): void { |
48
|
|
|
$methods = [$method1, $method2, $method3]; |
49
|
|
|
$methodRepository->findBy(['enabled' => true])->shouldBeCalled()->willReturn($methods); |
50
|
|
|
|
51
|
|
|
$eligibilityChecker->isEligible($subject, $method1)->shouldBeCalled()->willReturn(true); |
52
|
|
|
$eligibilityChecker->isEligible($subject, $method2)->shouldBeCalled()->willReturn(true); |
53
|
|
|
$eligibilityChecker->isEligible($subject, $method3)->shouldBeCalled()->willReturn(false); |
54
|
|
|
|
55
|
|
|
$this->getSupportedMethods($subject)->shouldReturn([$method1, $method2]); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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.