Passed
Push — master ( 9c20ed...a7d58a )
by Carsten
07:10
created

TaxTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A tearDown() 0 4 1
A testTaxValue() 0 13 1
A testTaxValueAfter() 0 11 1
1
<?php
2
3
namespace Lenius\Basket\Tests;
4
5
/*
6
 * This file is part of Lenius Basket, a PHP package to handle
7
 * your shopping basket.
8
 *
9
 * Copyright (c) 2017 Lenius.
10
 * https://github.com/lenius/basket
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 *
15
 * @author Carsten Jonstrup<[email protected]>
16
 * @copyright 2017 Lenius.
17
 *
18
 * @version production
19
 *
20
 * @link https://github.com/lenius/basket
21
 */
22
use Lenius\Basket\Tax;
23
use PHPUnit\Framework\TestCase;
24
25
class TaxTest extends TestCase
26
{
27
    private $item;
28
29
    public function setUp(): void
30
    {
31
    }
32
33
    public function tearDown(): void
34
    {
35
        $this->item = null;
36
    }
37
38
    public function testTaxValue(): void
39
    {
40
        $value = 25;
41
42
        $this->item = new Tax($value);
43
44
        $this->assertEquals(125, $this->item->add(100));
45
        $this->assertEquals(25, $this->item->rate(100));
46
        $this->assertEquals(25, $this->item->percentage);
47
        $this->assertEquals(0.75, $this->item->deductModifier);
48
        $this->assertEquals(1.25, $this->item->addModifier);
49
        $this->assertEquals(75, $this->item->deduct(100));
50
    }
51
52
    public function testTaxValueAfter(): void
53
    {
54
        $value = 100;
55
        $afterValue = 50;
56
57
        $this->item = new Tax($value, $afterValue);
58
59
        $this->assertEquals(-50, $this->item->percentage);
60
        $this->assertEquals(1.5, $this->item->deductModifier);
61
        $this->assertEquals(0.5, $this->item->addModifier);
62
    }
63
}
64