Completed
Push — master ( 20f7b9...07e3fa )
by Bryan
37:16 queued 31:15
created

UnitTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testUnitCreation() 0 4 1
A testGetValue() 0 5 1
A testgetUnit() 0 5 1
A testgetUnitFahrenheit() 0 5 1
A testgetUnitCelsius() 0 5 1
A testGetDecription() 0 5 1
A getFormatted() 0 5 1
A testToString() 0 5 1
1
<?php
2
namespace Bhhaskin\WeatherBee\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Bhhaskin\WeatherBee\Util\Unit;
6
7
/**
8
 * @coversDefaultClass Bhhaskin\WeatherBee\Util\Unit
9
 */
10
final class UnitTest extends TestCase
11
{
12
13
    /**
14
     * @covers ::__construct
15
     */
16
    public function testUnitCreation()
17
    {
18
        $this->assertInstanceOf(Unit::class, new Unit(0.0, "", ""));
19
    }
20
21
    /**
22
     * @covers ::getValue
23
     */
24
    public function testGetValue()
25
    {
26
        $unit = new Unit(1.0, "", "");
27
        $this->assertEquals($unit->getValue(), 1.0);
28
    }
29
30
    /**
31
     * @covers ::getUnit
32
     */
33
    public function testgetUnit()
34
    {
35
        $unit = new Unit(0.0, "foo", "");
36
        $this->assertEquals($unit->getUnit(), "foo");
37
    }
38
39
    /**
40
     * @covers ::getUnit
41
     */
42
    public function testgetUnitFahrenheit()
43
    {
44
        $unit = new Unit(0.0, "fahrenheit", "");
45
        $this->assertEquals($unit->getUnit(), "F");
46
    }
47
48
    /**
49
     * @covers ::getUnit
50
     */
51
    public function testgetUnitCelsius()
52
    {
53
        $unit = new Unit(0.0, "celsius", "");
54
        $this->assertEquals($unit->getUnit(), "C");
55
    }
56
57
    /**
58
     * @covers ::getDescription
59
     */
60
    public function testGetDecription()
61
    {
62
        $unit = new Unit(0.0, "", "foo");
63
        $this->assertEquals($unit->getDescription(), "foo");
64
    }
65
66
    /**
67
     * @covers ::getFormatted
68
     */
69
    public function getFormatted()
70
    {
71
        $unit = new Unit(1.1, "fahrenheit", "");
72
        $this->assertEquals($unit->getFormatted(), "1.1 F");
73
    }
74
75
    /**
76
     * @covers ::__toString
77
     */
78
    public function testToString()
79
    {
80
        $unit = new Unit(1.1, "fahrenheit", "");
81
        $this->assertEquals($unit, "1.1 F");
82
    }
83
84
}
85