Completed
Push — master ( cec9f3...d27170 )
by Kamil
22:53
created

TaxonContextSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
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\Context\Transform;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Component\Core\Model\TaxonInterface;
17
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
18
19
/**
20
 * @author Mateusz Zalewski <[email protected]>
21
 */
22
class TaxonContextSpec extends ObjectBehavior
23
{
24
    function let(TaxonRepositoryInterface $taxonRepository)
25
    {
26
        $this->beConstructedWith($taxonRepository);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType('Sylius\Behat\Context\Transform\TaxonContext');
32
    }
33
34
    function it_implements_context_interface()
35
    {
36
        $this->shouldImplement(Context::class);
37
    }
38
39
    function it_returns_taxon_by_name($taxonRepository, TaxonInterface $taxon)
40
    {
41
        $taxonRepository->findOneByName('Books')->willReturn($taxon);
42
43
        $this->getTaxonByName('Books')->shouldReturn($taxon);
44
    }
45
46
    function it_throws_exception_if_taxon_with_given_name_does_not_exist($taxonRepository)
47
    {
48
        $taxonRepository->findOneByName('Books')->willReturn(null);
49
50
        $this
51
            ->shouldThrow(new \InvalidArgumentException('Taxon with name "Books" does not exist.'))
52
            ->during('getTaxonByName', ['Books'])
53
        ;
54
    }
55
}
56