Completed
Push — master ( bf308c...9563f6 )
by Bryan
13:17 queued 06:12
created

UnitTest::testGetValue()   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
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use Bhhaskin\WeatherBee\Util\Unit;
5
6
/**
7
 * @coversDefaultClass Bhhaskin\WeatherBee\Util\Unit
8
 */
9
final class UnitTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
12
    /**
13
     * @covers ::__construct
14
     */
15
    public function testUnitCreation()
16
    {
17
        $this->assertInstanceOf(Unit::class, new Unit(0.0, "", ""));
18
    }
19
20
    /**
21
     * @covers ::getValue
22
     */
23
    public function testGetValue()
24
    {
25
        $unit = new Unit(1.0, "", "");
26
        $this->assertEquals($unit->getValue(), 1.0);
27
    }
28
29
    /**
30
     * @covers ::getUnit
31
     */
32
    public function testgetUnit()
33
    {
34
        $unit = new Unit(0.0, "foo", "");
35
        $this->assertEquals($unit->getUnit(), "foo");
36
    }
37
38
    /**
39
     * @covers ::getUnit
40
     */
41
    public function testgetUnitFahrenheit()
42
    {
43
        $unit = new Unit(0.0, "fahrenheit", "");
44
        $this->assertEquals($unit->getUnit(), "F");
45
    }
46
47
    /**
48
     * @covers ::getUnit
49
     */
50
    public function testgetUnitCelsius()
51
    {
52
        $unit = new Unit(0.0, "celsius", "");
53
        $this->assertEquals($unit->getUnit(), "C");
54
    }
55
56
    /**
57
     * @covers ::getDescription
58
     */
59
    public function testGetDecription()
60
    {
61
        $unit = new Unit(0.0, "", "foo");
62
        $this->assertEquals($unit->getDescription(), "foo");
63
    }
64
65
    /**
66
     * @covers ::getDescription
67
     */
68
    public function getFormatted()
69
    {
70
        $unit = new Unit(1.1, "fahrenheit", "");
71
        $this->assertEquals($unit->getFormatted(), "1.1 F");
72
    }
73
74
    /**
75
     * @covers ::__toString
76
     */
77
    public function testToString()
78
    {
79
        $unit = new Unit(1.1, "fahrenheit", "");
80
        $this->assertEquals($unit, "1.1 F");
81
    }
82
83
}
84