|
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\Checker; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
17
|
|
|
use PhpSpec\ObjectBehavior; |
|
18
|
|
|
use Sylius\Component\Shipping\Checker\ShippingMethodEligibilityCheckerInterface; |
|
19
|
|
|
use Sylius\Component\Shipping\Model\ShippableInterface; |
|
20
|
|
|
use Sylius\Component\Shipping\Model\ShippingCategoryInterface; |
|
21
|
|
|
use Sylius\Component\Shipping\Model\ShippingMethodInterface; |
|
22
|
|
|
use Sylius\Component\Shipping\Model\ShippingSubjectInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Saša Stamenković <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class ShippingMethodEligibilityCheckerSpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function it_implements_Sylius_shipping_method_eligibility_checker_interface(): void |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldImplement(ShippingMethodEligibilityCheckerInterface::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_approves_category_requirement_if_categories_match( |
|
35
|
|
|
ShippingSubjectInterface $subject, |
|
36
|
|
|
ShippingMethodInterface $shippingMethod, |
|
37
|
|
|
ShippingCategoryInterface $shippingCategory, |
|
38
|
|
|
ShippableInterface $shippable |
|
39
|
|
|
): void { |
|
40
|
|
|
$shippingMethod->getCategory()->willReturn($shippingCategory); |
|
41
|
|
|
$shippingMethod->getCategoryRequirement()->willReturn(ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_ANY); |
|
42
|
|
|
|
|
43
|
|
|
$shippable->getShippingCategory()->willReturn($shippingCategory); |
|
44
|
|
|
$subject->getShippables()->willReturn(new ArrayCollection([$shippable->getWrappedObject()])); |
|
45
|
|
|
|
|
46
|
|
|
$this->isEligible($subject, $shippingMethod)->shouldReturn(true); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function it_approves_category_requirement_if_no_category_is_required( |
|
50
|
|
|
ShippingSubjectInterface $subject, |
|
51
|
|
|
ShippingMethodInterface $shippingMethod |
|
52
|
|
|
): void { |
|
53
|
|
|
$shippingMethod->getCategory()->willReturn(null); |
|
54
|
|
|
|
|
55
|
|
|
$this->isEligible($subject, $shippingMethod)->shouldReturn(true); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function it_denies_category_requirement_if_categories_do_not_match( |
|
59
|
|
|
ShippingSubjectInterface $subject, |
|
60
|
|
|
ShippingMethodInterface $shippingMethod, |
|
61
|
|
|
ShippingCategoryInterface $shippingCategory, |
|
62
|
|
|
ShippingCategoryInterface $shippingCategory2, |
|
63
|
|
|
ShippableInterface $shippable |
|
64
|
|
|
): void { |
|
65
|
|
|
$shippingMethod->getCategory()->willReturn($shippingCategory); |
|
66
|
|
|
$shippingMethod->getCategoryRequirement()->willReturn(ShippingMethodInterface::CATEGORY_REQUIREMENT_MATCH_ANY); |
|
67
|
|
|
|
|
68
|
|
|
$shippable->getShippingCategory()->willReturn($shippingCategory2); |
|
69
|
|
|
$subject->getShippables()->willReturn(new ArrayCollection([$shippable->getWrappedObject()])); |
|
70
|
|
|
|
|
71
|
|
|
$this->isEligible($subject, $shippingMethod)->shouldReturn(false); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
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.