Passed
Push — master ( 445708...0db764 )
by Steffen
08:17
created

TemperatureConverterTest::testConversion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 5
nop 6
1
<?php
2
/*
3
 * This file is part of the unicorn project
4
 *
5
 * (c) Philipp Braeutigam <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Xynnn\Unicorn\Tests\Converter;
11
12
use Xynnn\Unicorn\Converter\TemperatureConverter;
13
use Xynnn\Unicorn\Model\ConvertibleValue;
14
15
class TemperatureConverterTest extends AbstractConverterTest
16
{
17
    public function testIsInstantiable()
18
    {
19
        $converter = $this->getConverter();
20
21
        $this->assertInstanceOf(TemperatureConverter::class, $converter);
22
    }
23
24
    public function testGetName()
25
    {
26
        $converter = $this->getConverter();
27
28
        $this->assertEquals('unicorn.converter.temperature', $converter->getName());
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function dataProvider()
35
    {
36
        $converter = $this->getConverter();
37
38
        return [
39
            [$converter, new ConvertibleValue('10', $converter::$celsius), $converter::$fahrenheit, '50', $converter::$fahrenheit->getName(), $converter::$fahrenheit->getAbbreviation()],
40
            [$converter, new ConvertibleValue('50', $converter::$fahrenheit), $converter::$celsius, '10', $converter::$celsius->getName(), $converter::$celsius->getAbbreviation()],
41
            [$converter, new ConvertibleValue('100', $converter::$celsius), $converter::$fahrenheit, '212', $converter::$fahrenheit->getName(), $converter::$fahrenheit->getAbbreviation()],
42
            [$converter, new ConvertibleValue('10', $converter::$celsius), $converter::$kelvin, '283.15', $converter::$kelvin->getName(), $converter::$kelvin->getAbbreviation()],
43
            [$converter, new ConvertibleValue('100', $converter::$celsius), $converter::$kelvin, '373.15', $converter::$kelvin->getName(), $converter::$kelvin->getAbbreviation()]
44
        ];
45
    }
46
47
    /**
48
     * @return TemperatureConverter
49
     */
50
    private function getConverter() : TemperatureConverter
51
    {
52
        return new TemperatureConverter();
53
    }
54
}
55