Completed
Push — core-test-reorganisation ( 880d88 )
by Kamil
44:19 queued 07:25
created

TestPromotionFactorySpec::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 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\Behat\Service;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Component\Core\Model\ChannelInterface;
17
use Sylius\Component\Core\Model\PromotionInterface;
18
use Sylius\Behat\Service\TestPromotionFactory;
19
use Sylius\Behat\Service\TestPromotionFactoryInterface;
20
use Sylius\Component\Resource\Factory\FactoryInterface;
21
22
/**
23
 * @author Mateusz Zalewski <[email protected]>
24
 */
25
final class TestPromotionFactorySpec extends ObjectBehavior
26
{
27
    function let(FactoryInterface $promotionFactory)
28
    {
29
        $this->beConstructedWith($promotionFactory);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType(TestPromotionFactory::class);
35
    }
36
37
    function it_implements_a_test_promotion_factory_interface()
38
    {
39
        $this->shouldImplement(TestPromotionFactoryInterface::class);
40
    }
41
42
    function it_creates_a_promotion_with_a_given_name($promotionFactory, PromotionInterface $promotion)
43
    {
44
        $promotionFactory->createNew()->willReturn($promotion);
45
        $promotion->setName('Super promotion')->shouldBeCalled();
46
        $promotion->setCode('super_promotion')->shouldBeCalled();
47
        $promotion->setStartsAt(Argument::type(\DateTime::class))->shouldBeCalled();
48
        $promotion->setEndsAt(Argument::type(\DateTime::class))->shouldBeCalled();
49
50
        $this->create('Super promotion')->shouldReturn($promotion);
51
    }
52
53
    function it_creates_a_promotion_with_a_given_name_and_channel(
54
        FactoryInterface $promotionFactory,
55
        ChannelInterface $channel,
56
        PromotionInterface $promotion
57
    ) {
58
        $promotionFactory->createNew()->willReturn($promotion);
59
        $promotion->setName('Super promotion')->shouldBeCalled();
60
        $promotion->setCode('super_promotion')->shouldBeCalled();
61
        $promotion->setStartsAt(Argument::type(\DateTime::class))->shouldBeCalled();
62
        $promotion->setEndsAt(Argument::type(\DateTime::class))->shouldBeCalled();
63
        $promotion->addChannel($channel)->shouldBeCalled();
64
65
        $this->createForChannel('Super promotion', $channel)->shouldReturn($promotion);
66
    }
67
}
68