Completed
Push — scalar-types/user ( 04f6b1...6e06c6 )
by Kamil
57:21 queued 32:30
created

DefaultCalculatorSpec::it_is_initializable()   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
nc 1
cc 1
eloc 2
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Taxation\Calculator;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Taxation\Calculator\CalculatorInterface;
18
use Sylius\Component\Taxation\Model\TaxRateInterface;
19
20
/**
21
 * @author Paweł Jędrzejewski <[email protected]>
22
 * @author Michał Marcinkowski <[email protected]>
23
 */
24
final class DefaultCalculatorSpec extends ObjectBehavior
25
{
26
    function it_implements_Sylius_tax_calculator_interface(): void
0 ignored issues
show
Coding Style introduced by
function it_implements_S..._calculator_interface() does not seem to conform to the naming convention (^(?:(?:[a-z]|__)[a-zA-Z0-9]*|[a-z][a-z0-9_]*)$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
27
    {
28
        $this->shouldImplement(CalculatorInterface::class);
29
    }
30
31
    function it_calculates_tax_as_percentage_of_given_base_if_rate_is_not_included_in_price(
32
        TaxRateInterface $rate
33
    ): void {
34
        $rate->isIncludedInPrice()->willReturn(false);
35
        $rate->getAmount()->willReturn(0.23);
36
37
        $this->calculate(10000, $rate)->shouldReturn(2300.00);
38
        $this->calculate(100000, $rate)->shouldReturn(23000.00);
39
        $this->calculate(249599, $rate)->shouldReturn(57408.00);
40
    }
41
42
    function it_calculates_correct_tax_for_given_base_if_rate_is_included_in_price(
43
        TaxRateInterface $rate
44
    ): void {
45
        $rate->isIncludedInPrice()->willReturn(true);
46
        $rate->getAmount()->willReturn(0.23);
47
48
        $this->calculate(10000, $rate)->shouldReturn(1870.00);
49
50
        $rate->getAmount()->willReturn(0.2);
51
        $this->calculate(315, $rate)->shouldReturn(53.00);
52
    }
53
}
54