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 |
|
|
|
|
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
|
|
|
|
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.