Completed
Push — master ( 5bd7d5...03ff4c )
by Bryan
50:21 queued 42:15
created

UnitTest::getFormattedWithUnit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Bhhaskin\WeatherBee\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Bhhaskin\WeatherBee\Util\Unit;
6
7
/**
8
 * @covers Bhhaskin\WeatherBee\Util\Unit
9
 */
10
final class UnitTest extends TestCase
11
{
12
13
    /**
14
     * @covers Bhhaskin\WeatherBee\Util\Unit::__construct
15
     */
16
    public function testUnitCreation()
17
    {
18
        $this->assertInstanceOf(Unit::class, new Unit(0.0, "", ""));
19
    }
20
21
    /**
22
     * @covers Bhhaskin\WeatherBee\Util\Unit::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 Bhhaskin\WeatherBee\Util\Unit::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 Bhhaskin\WeatherBee\Util\Unit::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 Bhhaskin\WeatherBee\Util\Unit::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 Bhhaskin\WeatherBee\Util\Unit::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 Bhhaskin\WeatherBee\Util\Unit::getFormatted
68
     */
69
    public function getFormattedWithUnit()
70
    {
71
        $unit = new Unit(1.1, "fahrenheit", "");
72
        $this->assertEquals($unit->getFormatted(), "1.1 F");
73
    }
74
75
    /**
76
     * @covers Bhhaskin\WeatherBee\Util\Unit::getFormatted
77
     */
78
    public function getFormattedWithoutUnit()
79
    {
80
        $unit = new Unit(1.1, "", "");
81
        $this->assertEquals($unit->getFormatted(), "1.1");
82
    }
83
84
    /**
85
     * @covers Bhhaskin\WeatherBee\Util\Unit::__toString
86
     */
87
    public function testToString()
88
    {
89
        $unit = new Unit(1.1, "fahrenheit", "");
90
        $this->assertEquals($unit, "1.1 F");
91
    }
92
93
}
94