Completed
Push — scalar-types/ui ( 162de3 )
by Kamil
22:15
created

it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
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
0 ignored issues
show
Coding Style introduced by
function it_implements_S...ity_checker_interface() does not seem to conform to the naming convention (^(?:(?:[a-z]|__)[a-zA-Z0-9]*|[a-z][a-z0-9_]*)$).

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.

Loading history...
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