|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Component\Taxation\Resolver; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
|
18
|
|
|
use Sylius\Component\Taxation\Model\TaxableInterface; |
|
19
|
|
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface; |
|
20
|
|
|
use Sylius\Component\Taxation\Model\TaxRateInterface; |
|
21
|
|
|
use Sylius\Component\Taxation\Resolver\TaxRateResolverInterface; |
|
22
|
|
|
|
|
23
|
|
|
final class TaxRateResolverSpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function let(RepositoryInterface $taxRateRepository): void |
|
26
|
|
|
{ |
|
27
|
|
|
$this->beConstructedWith($taxRateRepository); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
function it_implements_tax_rate_resolver_interface(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldImplement(TaxRateResolverInterface::class); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_returns_tax_rate_for_given_taxable_category( |
|
36
|
|
|
$taxRateRepository, |
|
37
|
|
|
TaxableInterface $taxable, |
|
38
|
|
|
TaxCategoryInterface $taxCategory, |
|
39
|
|
|
TaxRateInterface $taxRate |
|
40
|
|
|
): void { |
|
41
|
|
|
$taxable->getTaxCategory()->willReturn($taxCategory); |
|
|
|
|
|
|
42
|
|
|
$taxRateRepository->findOneBy(['category' => $taxCategory])->shouldBeCalled()->willReturn($taxRate); |
|
43
|
|
|
|
|
44
|
|
|
$this->resolve($taxable)->shouldReturn($taxRate); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
function it_returns_null_if_tax_rate_for_given_taxable_category_does_not_exist( |
|
48
|
|
|
$taxRateRepository, |
|
49
|
|
|
TaxableInterface $taxable, |
|
50
|
|
|
TaxCategoryInterface $taxCategory |
|
51
|
|
|
): void { |
|
52
|
|
|
$taxable->getTaxCategory()->willReturn($taxCategory); |
|
|
|
|
|
|
53
|
|
|
$taxRateRepository->findOneBy(['category' => $taxCategory])->shouldBeCalled()->willReturn(null); |
|
54
|
|
|
|
|
55
|
|
|
$this->resolve($taxable)->shouldReturn(null); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function it_returns_null_if_taxable_does_not_belong_to_any_category( |
|
59
|
|
|
TaxableInterface $taxable |
|
60
|
|
|
): void { |
|
61
|
|
|
$taxable->getTaxCategory()->willReturn(null); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$this->resolve($taxable)->shouldReturn(null); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.