Completed
Push — master ( f9ba0c...336b1b )
by Kamil
23:42
created

AdjustmentFactorySpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 0
cbo 2
dl 0
loc 35
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_adjustment_factory_interface() 0 4 1
A it_creates_new_adjustment() 0 6 1
A it_creates_new_adjustment_with_provided_data() 0 10 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
namespace spec\Sylius\Component\Order\Factory;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Order\Factory\AdjustmentFactoryInterface;
16
use Sylius\Component\Order\Model\AdjustmentInterface;
17
use Sylius\Component\Resource\Factory\FactoryInterface;
18
19
/**
20
 * @author Mateusz Zalewski <[email protected]>
21
 */
22
class AdjustmentFactorySpec extends ObjectBehavior
23
{
24
    function let(FactoryInterface $adjustmentFactory)
25
    {
26
        $this->beConstructedWith($adjustmentFactory);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType('Sylius\Component\Order\Factory\AdjustmentFactory');
32
    }
33
34
    function it_implements_adjustment_factory_interface()
35
    {
36
        $this->shouldImplement(AdjustmentFactoryInterface::class);
37
    }
38
39
    function it_creates_new_adjustment($adjustmentFactory, AdjustmentInterface $adjustment)
40
    {
41
        $adjustmentFactory->createNew()->willReturn($adjustment);
42
43
        $this->createNew()->shouldReturn($adjustment);
44
    }
45
46
    function it_creates_new_adjustment_with_provided_data($adjustmentFactory, AdjustmentInterface $adjustment)
47
    {
48
        $adjustmentFactory->createNew()->willReturn($adjustment);
49
        $adjustment->setType('tax')->shouldBeCalled();
50
        $adjustment->setDescription('Tax description')->shouldBeCalled();
51
        $adjustment->setAmount(1000)->shouldBeCalled();
52
        $adjustment->setNeutral(false)->shouldBeCalled();
53
54
        $this->createWithData('tax', 'Tax description', 1000, false)->shouldReturn($adjustment);
55
    }
56
}
57