Completed
Push — master ( 6d05bc...71ecc8 )
by Kamil
25:05
created

AddressFactorySpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_address_factory_interface() 0 4 1
A it_is_a_resource_factory() 0 4 1
A it_creates_a_new_address() 0 6 1
A it_creates_a_new_address_with_customer() 0 11 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