Completed
Push — master ( eeff33...1702a2 )
by Kamil
41:57 queued 20:40
created

TaxContextSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 3 1
A it_is_initializable() 0 4 1
A it_implements_context_interface() 0 4 1
A it_casts_tax_category_name_to_tax_category() 0 6 1
A it_throws_exception_if_there_is_no_tax_category_with_name_given_to_casting() 0 9 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\Resource\Repository\RepositoryInterface;
17
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
18
19
/**
20
 * @author Łukasz Chruściel <[email protected]>
21
 */
22
class TaxContextSpec extends ObjectBehavior
23
{
24
    function let(RepositoryInterface $taxCategoryRepository) {
25
        $this->beConstructedWith($taxCategoryRepository);
26
    }
27
28
    function it_is_initializable()
29
    {
30
        $this->shouldHaveType('Sylius\Behat\Context\Transform\TaxContext');
31
    }
32
33
    function it_implements_context_interface()
34
    {
35
        $this->shouldImplement(Context::class);
36
    }
37
38
    function it_casts_tax_category_name_to_tax_category($taxCategoryRepository, TaxCategoryInterface $taxCategory)
39
    {
40
        $taxCategoryRepository->findOneBy(['name' => 'TaxCategory'])->willReturn($taxCategory);
41
42
        $this->getTaxCategoryByName('TaxCategory')->shouldReturn($taxCategory);
43
    }
44
45
    function it_throws_exception_if_there_is_no_tax_category_with_name_given_to_casting($taxCategoryRepository)
46
    {
47
        $taxCategoryRepository->findOneBy(['name' => 'TaxCategory'])->willReturn(null);
48
49
        $this
50
            ->shouldThrow(new \InvalidArgumentException('Tax category with name "TaxCategory" does not exist'))
51
            ->during('getTaxCategoryByName', ['TaxCategory'])
52
        ;
53
    }
54
}
55