-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathIntervalNormalizerTest.php
More file actions
58 lines (51 loc) · 1.31 KB
/
IntervalNormalizerTest.php
File metadata and controls
58 lines (51 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Hypeit\TradeTracker\Test\Normalizer;
use Hypeit\TradeTracker\Normalizer\IntervalNormalizer;
use PHPUnit\Framework\TestCase;
/**
* Class IntervalNormalizerTest
* @package Hypeit\TradeTracker\Test\Normalizer
*/
class IntervalNormalizerTest extends TestCase
{
/**
* Test if the normalizer works properly.
*
* @param mixed $value
* @param mixed $expected
*
* @dataProvider intervalProvider
*/
public function testNormalize($value, $expected)
{
$normalizer = new IntervalNormalizer();
$result = $normalizer->normalize($value);
if (is_object($result)) {
$result = get_class($result);
}
$this->assertEquals($expected, $result);
}
/**
* Test that the normalizer throws an exception.
*
* @throws \Exception
*/
public function testNormalizeWithException()
{
$this->expectException(\Exception::class);
$normalizer = new IntervalNormalizer();
$normalizer->normalize('P15D1M');
}
/**
* Data provider for @see testNormalize
*/
public function intervalProvider()
{
return [
['P1D', \DateInterval::class],
['P15M1DT202010', \DateInterval::class],
['', null],
[null, null],
];
}
}