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

AdjustmentFactorySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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