|
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
|
|
|
|