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

ShippingMethodsResolverSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 6 1
A it_implements_Sylius_shipping_methods_resolver_interface() 0 4 1
A it_returns_all_methods_eligible_for_given_subject() 0 17 1
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
0 ignored issues
show
Coding Style introduced by
function it_implements_S...ds_resolver_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...
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