Completed
Push — symfony-flex ( 2a70a0 )
by Kamil
26:10 queued 12:40
created

CustomerAfterCheckoutFactorySpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 50
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_implements_customer_ater_checkout_factory_interface() 0 4 1
A it_is_a_resource_factory() 0 4 1
A it_creates_a_new_customer() 0 6 1
A it_creates_a_new_customer_after_checkout() 0 25 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\Core\Factory;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Core\Factory\CustomerAfterCheckoutFactoryInterface;
18
use Sylius\Component\Core\Model\AddressInterface;
19
use Sylius\Component\Core\Model\CustomerInterface;
20
use Sylius\Component\Core\Model\OrderInterface;
21
use Sylius\Component\Resource\Factory\FactoryInterface;
22
23
final class CustomerAfterCheckoutFactorySpec extends ObjectBehavior
24
{
25
    function let(FactoryInterface $baseCustomerFactory): void
26
    {
27
        $this->beConstructedWith($baseCustomerFactory);
28
    }
29
30
    function it_implements_customer_ater_checkout_factory_interface(): void
31
    {
32
        $this->shouldImplement(CustomerAfterCheckoutFactoryInterface::class);
33
    }
34
35
    function it_is_a_resource_factory(): void
36
    {
37
        $this->shouldImplement(FactoryInterface::class);
38
    }
39
40
    function it_creates_a_new_customer(FactoryInterface $baseCustomerFactory, CustomerInterface $customer): void
41
    {
42
        $baseCustomerFactory->createNew()->willReturn($customer);
43
44
        $this->createNew()->shouldReturn($customer);
45
    }
46
47
    function it_creates_a_new_customer_after_checkout(
48
        FactoryInterface $baseCustomerFactory,
49
        CustomerInterface $guest,
50
        OrderInterface $order,
51
        AddressInterface $address,
52
        CustomerInterface $customer
53
    ): void {
54
        $order->getCustomer()->willReturn($guest);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Sylius\Component\...odel\CustomerInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
        $order->getBillingAddress()->willReturn($address);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Sylius\Component\...Model\AddressInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
57
        $guest->getEmail()->willReturn('[email protected]');
58
59
        $address->getFirstName()->willReturn('John');
60
        $address->getLastName()->willReturn('Doe');
61
        $address->getPhoneNumber()->willReturn('666777888');
62
63
        $baseCustomerFactory->createNew()->willReturn($customer);
64
65
        $customer->setEmail('[email protected]')->shouldBeCalled();
66
        $customer->setFirstName('John')->shouldBeCalled();
67
        $customer->setLastName('Doe')->shouldBeCalled();
68
        $customer->setPhoneNumber('666777888')->shouldBeCalled();
69
70
        $this->createAfterCheckout($order)->shouldReturn($customer);
71
    }
72
}
73