Passed
Push — master ( 103120...e7a690 )
by Chris
03:27
created

TaxRateTest::testEquals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
4
namespace ConferenceTools\Tickets\Domain\ValueObject;
5
6
7
class TaxRateTest extends \PHPUnit\Framework\TestCase
8
{
9
    /**
10
     * @dataProvider provideCompare
11
     *
12
     * @param TaxRate $a
13
     * @param TaxRate $b
14
     * @param int $expected
15
     */
16
    public function testCompare(TaxRate $a, TaxRate $b, $expected)
17
    {
18
        self::assertEquals($expected, $a->compare($b));
19
        self::assertEquals(-1 * $expected, $b->compare($a));
20
    }
21
22
    public function provideCompare()
23
    {
24
        $a = new TaxRate(20);
25
        $b = new TaxRate(20);
26
        $c = new TaxRate(25);
27
        $d = new TaxRate(30);
28
29
        return [
30
            [$a, $b, 0],
31
            [$b, $c, -1],
32
            [$c, $d, -1],
33
            [$d, $a, 1],
34
        ];
35
    }
36
37 View Code Duplication
    public function testEquals()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $sut = new TaxRate(20);
40
        $taxrate1 = new TaxRate(20);
41
        $taxrate2 = new TaxRate(10);
42
43
        self::assertTrue($sut->equals($taxrate1));
44
        self::assertFalse($sut->equals($taxrate2));
45
    }
46
47
48 View Code Duplication
    public function testLessThan()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $sut = new TaxRate(20);
51
        $taxrate1 = new TaxRate(25);
52
        $taxrate2 = new TaxRate(10);
53
54
        self::assertTrue($sut->lessThan($taxrate1));
55
        self::assertFalse($sut->lessThan($taxrate2));
56
    }
57
58 View Code Duplication
    public function testGreaterThan()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $sut = new TaxRate(20);
61
        $taxrate1 = new TaxRate(10);
62
        $taxrate2 = new TaxRate(25);
63
64
        self::assertTrue($sut->greaterThan($taxrate1));
65
        self::assertFalse($sut->greaterThan($taxrate2));
66
    }
67
68
    public function testCreate()
69
    {
70
        $sut = new TaxRate(15);
71
72
        self::assertEquals(15, $sut->getPercentage());
73
    }
74
}
75