Completed
Branch master (07e3fa)
by Bryan
50:48 queued 36:50
created

UnitTest::testUnitCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
 * @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