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

DataStorageConverterTest::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
cc 1
eloc 5
nc 1
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\DataStorageConverter;
13
use Xynnn\Unicorn\Model\ConvertibleValue;
14
15
class DataStorageConverterTest extends AbstractConverterTest
16
{
17
    public function testIsInstantiable()
18
    {
19
        $converter = $this->getConverter();
20
21
        $this->assertInstanceOf(DataStorageConverter::class, $converter);
22
    }
23
24
    public function testGetName()
25
    {
26
        $converter = $this->getConverter();
27
28
        $this->assertEquals('unicorn.converter.datastorage', $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('1', $converter::$gigabyte), $converter::$megabyte, '1000', $converter::$megabyte->getName(), $converter::$megabyte->getAbbreviation()],
40
            [$converter, new ConvertibleValue('1', $converter::$gibibyte), $converter::$mebibyte, '1024', $converter::$mebibyte->getName(), $converter::$mebibyte->getAbbreviation()],
41
            [$converter, new ConvertibleValue('1', $converter::$tebibyte), $converter::$gibibyte, '1024', $converter::$gibibyte->getName(), $converter::$gibibyte->getAbbreviation()],
42
            [$converter, new ConvertibleValue('1', $converter::$tebibyte), $converter::$mebibyte, '1048576', $converter::$mebibyte->getName(), $converter::$mebibyte->getAbbreviation()],
43
            [$converter, new ConvertibleValue('1', $converter::$gibibyte), $converter::$megabyte, '1073.741824', $converter::$megabyte->getName(), $converter::$megabyte->getAbbreviation()],
44
            [$converter, new ConvertibleValue('1', $converter::$gibibyte), $converter::$megabyte, '1073.741824', $converter::$megabyte->getName(), $converter::$megabyte->getAbbreviation()],
45
            [$converter, new ConvertibleValue('1', $converter::$pebibyte), $converter::$gigabyte, '1125899.906842624', $converter::$gigabyte->getName(), $converter::$gigabyte->getAbbreviation()],
46
            [$converter, new ConvertibleValue('1', $converter::$gigabit), $converter::$megabit, '1000', $converter::$megabit->getName(), $converter::$megabit->getAbbreviation()],
47
            [$converter, new ConvertibleValue('1', $converter::$gigabit), $converter::$megabyte, '125', $converter::$megabyte->getName(), $converter::$megabyte->getAbbreviation()],
48
            [$converter, new ConvertibleValue('1', $converter::$gibibit), $converter::$mebibit, '1024', $converter::$mebibit->getName(), $converter::$mebibit->getAbbreviation()],
49
            [$converter, new ConvertibleValue('1', $converter::$gibibit), $converter::$megabyte, '134.217728', $converter::$megabyte->getName(), $converter::$megabyte->getAbbreviation()]
50
        ];
51
    }
52
53
    /**
54
     * @return DataStorageConverter
55
     */
56
    private function getConverter() : DataStorageConverter
57
    {
58
        return new DataStorageConverter();
59
    }
60
}
61