Completed
Push — master ( 3ff7e6...cf5edc )
by Kamil
96:30 queued 63:14
created

AddressFactorySpec::let()   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
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is a 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
namespace spec\Sylius\Component\Core\Factory;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Core\Factory\AddressFactory;
16
use Sylius\Component\Core\Factory\AddressFactoryInterface;
17
use Sylius\Component\Core\Model\AddressInterface;
18
use Sylius\Component\Core\Model\CustomerInterface;
19
use Sylius\Component\Resource\Factory\FactoryInterface;
20
21
/**
22
 * @mixin AddressFactory
23
 *
24
 * @author Anna Walasek <[email protected]>
25
 */
26
final class AddressFactorySpec extends ObjectBehavior
27
{
28
    function let(FactoryInterface $decoratedFactory)
29
    {
30
        $this->beConstructedWith($decoratedFactory);
31
    }
32
    
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType(AddressFactory::class);
36
    }
37
    
38
    function it_implements_address_factory_interface()
39
    {
40
        $this->shouldImplement(AddressFactoryInterface::class);
41
    }
42
    
43
    function it_is_a_resource_factory()
44
    {
45
        $this->shouldImplement(FactoryInterface::class);
46
    }
47
    
48
    function it_creates_a_new_address(FactoryInterface $decoratedFactory, AddressInterface $address)
49
    {
50
        $decoratedFactory->createNew()->willReturn($address);
51
        
52
        $this->createNew()->shouldReturn($address);
53
    }
54
    
55
    function it_creates_a_new_address_with_customer(
56
        FactoryInterface $decoratedFactory, 
57
        AddressInterface $address, 
58
        CustomerInterface $customer
59
    ) {
60
        $decoratedFactory->createNew()->willReturn($address);
61
        
62
        $address->setCustomer($customer)->shouldBeCalled();
63
64
        $this->createWithCustomer($customer)->shouldReturn($address);
65
    }
66
}
67