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); |
|
|
|
|
55
|
|
|
$order->getBillingAddress()->willReturn($address); |
|
|
|
|
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
|
|
|
|
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.