SimpleFormatterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testFormats() 0 4 1
A quantitiesProvider() 0 10 1
1
<?php
2
3
namespace hiqdev\php\units\tests\formatters;
4
5
use hiqdev\php\units\formatters\SimpleFormatter;
6
use hiqdev\php\units\Quantity;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Class SimpleFormatterTest
11
 *
12
 * @author Dmytro Naumenko <[email protected]>
13
 */
14
class SimpleFormatterTest extends TestCase
15
{
16
    /**
17
     * @var SimpleFormatter
18
     */
19
    protected $formatter;
20
21
    public function setUp()
22
    {
23
        $this->formatter = new SimpleFormatter();
24
    }
25
26
    /**
27
     * @dataProvider quantitiesProvider
28
     *
29
     * @param Quantity $quantity
30
     * @param string $expected
31
     */
32
    public function testFormats(Quantity $quantity, string $expected): void
33
    {
34
        $this->assertSame($expected, $this->formatter->format($quantity));
35
    }
36
37
    public function quantitiesProvider(): array
38
    {
39
        return [
40
            [Quantity::create('mb', 100), '100 mb'],
41
            [Quantity::create('mb', 10000), '10 000 mb'],
42
            [Quantity::create('wtf', 100500), '100 500 wtf'],
43
            [Quantity::create('min', 60.14), '60.14 min'],
44
            [Quantity::create('item', 0.00001), '0.00001 item'],
45
        ];
46
    }
47
}
48