Completed
Push — master ( 038cb8...f2d1b9 )
by FX
13:23
created

MineFactorTest::testGetR2Factor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Tests\Entity;
4
5
use AppBundle\Entity\MineFactor;
6
use InvalidArgumentException;
7
use PHPUnit\Framework\TestCase;
8
9
class MineFactorTest extends TestCase
10
{
11
    public function testConstructor()
12
    {
13
        $factor = '100000000';
14
        $mineFactor = new MineFactor($factor);
15
16
        $this->assertEquals($factor, $mineFactor->getFactor());
17
    }
18
19
    public function testEmptyConstructor()
20
    {
21
        $factor = '';
22
        $this->expectException(InvalidArgumentException::class);
23
        $mineFactor = new MineFactor($factor);
0 ignored issues
show
Unused Code introduced by
$mineFactor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24
    }
25
26
    public function testInvalidArgumentConstructor()
27
    {
28
        $factor = '010000000';
29
        $this->expectException(InvalidArgumentException::class);
30
        $mineFactor = new MineFactor($factor);
0 ignored issues
show
Unused Code introduced by
$mineFactor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
31
    }
32
33
    public function testIsValidTrue()
34
    {
35
        $factor = '100000000';
36
        $mineFactor = new MineFactor($factor);
37
38
        $this->assertTrue($mineFactor->isValid('000100000'));
39
    }
40
41
    public function testIsValidFalse()
42
    {
43
        $factor = '100000000';
44
        $mineFactor = new MineFactor($factor);
45
46
        $this->assertFalse($mineFactor->isValid('010000000'));
47
    }
48
49
    public function testGetFactor()
50
    {
51
        $factor = '100000000';
52
        $mineFactor = new MineFactor($factor);
53
54
        $this->assertEquals($factor, $mineFactor->getFactor());
55
    }
56
57
    public function testGetR1Factor()
58
    {
59
        $factor = '050020005';
60
        $mineFactor = new MineFactor($factor);
61
62
        $this->assertEquals(50, $mineFactor->getR1Factor());
63
    }
64
65
    public function testGetR2Factor()
66
    {
67
        $factor = '050020005';
68
        $mineFactor = new MineFactor($factor);
69
70
        $this->assertEquals(20, $mineFactor->getR2Factor());
71
    }
72
73
    public function testGetR3Factor()
74
    {
75
        $factor = '050020005';
76
        $mineFactor = new MineFactor($factor);
77
78
        $this->assertEquals(5, $mineFactor->getR3Factor());
79
    }
80
}
81