FormatterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testFormatAmount() 0 4 1
A dataTestFormatAmount() 0 12 1
A testFormatDateTime() 0 4 1
A dataTestFormatDateTime() 0 7 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatEET;
4
5
use DateTimeImmutable;
6
use DateTimeZone;
7
use PHPUnit\Framework\TestCase;
8
9
class FormatterTest extends TestCase
10
{
11
12
	/**
13
	 * @dataProvider dataTestFormatAmount
14
	 *
15
	 * @param int|null $value
16
	 * @param string|null $expected
17
	 */
18
	public function testFormatAmount(?int $value = null, ?string $expected = null): void
19
	{
20
		$this->assertSame($expected, Formatter::formatAmount($value));
21
	}
22
23
	/**
24
	 * @return mixed[]
25
	 */
26
	public function dataTestFormatAmount(): array
27
	{
28
		return [
29
			[0, '0.00'],
30
			[10000, '100.00'],
31
			[150, '1.50'],
32
			[-5500, '-55.00'],
33
			[-12425, '-124.25'],
34
			[-12420, '-124.20'],
35
			[null, null],
36
		];
37
	}
38
39
	/**
40
	 * @dataProvider dataTestFormatDateTime
41
	 *
42
	 * @param DateTimeImmutable $value
43
	 * @param string $expected
44
	 */
45
	public function testFormatDateTime(DateTimeImmutable $value, string $expected): void
46
	{
47
		$this->assertSame($expected, Formatter::formatDateTime($value));
48
	}
49
50
	/**
51
	 * @return mixed[][]
52
	 */
53
	public function dataTestFormatDateTime(): array
54
	{
55
		return [
56
			[new DateTimeImmutable('2016-03-11 11:05:00', new DateTimeZone('Europe/Prague')), '2016-03-11T11:05:00+01:00'],
57
			[new DateTimeImmutable('2016-08-11 11:05:00', new DateTimeZone('Europe/Prague')), '2016-08-11T11:05:00+02:00'],
58
		];
59
	}
60
61
}
62