|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Test\Field\Parser\DateParser\DateFormatter; |
|
4
|
|
|
|
|
5
|
|
|
use Graze\CiffRenderer\Field\Parser\DateParser\DateFormatter\DateFormatterFactory; |
|
6
|
|
|
use \DateTimeImmutable; |
|
7
|
|
|
|
|
8
|
|
|
class DateFormatterTest extends \PHPUnit_Framework_TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @param string $expected |
|
12
|
|
|
* @param string $format |
|
13
|
|
|
* |
|
14
|
|
|
* @dataProvider testGetDateFormatDataProvider |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testFormat($expected, $format) |
|
17
|
|
|
{ |
|
18
|
|
|
$dateFormatter = DateFormatterFactory::getFormatter($format); |
|
19
|
|
|
|
|
20
|
|
|
$date = new DateTimeImmutable('1982-01-24'); |
|
21
|
|
|
|
|
22
|
|
|
$actual = $dateFormatter->format($date, $format); |
|
23
|
|
|
|
|
24
|
|
|
$this->assertSame($expected, $actual); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @return [] |
|
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
|
|
public function testGetDateFormatDataProvider() |
|
31
|
|
|
{ |
|
32
|
|
|
return [ |
|
33
|
|
|
["24011982", "dd''MM''yyyy"], |
|
34
|
|
|
["24 01 1982", "dd' 'MM' 'yyyy"], |
|
35
|
|
|
["24.01.1982", "dd'.'MM'.'yyyy"], |
|
36
|
|
|
["24,01,1982", "dd','MM','yyyy"], |
|
37
|
|
|
["24-01-1982", "dd'-'MM'-'yyyy"], |
|
38
|
|
|
["24\\01\\1982", "dd'\'MM'\'yyyy"], |
|
39
|
|
|
["24:01:1982", "dd':'MM':'yyyy"], |
|
40
|
|
|
//["81", "y"], |
|
|
|
|
|
|
41
|
|
|
//["", "cl:yy"], |
|
|
|
|
|
|
42
|
|
|
["24", "cl:j"], |
|
43
|
|
|
["024", "cl:jj"], |
|
44
|
|
|
["24", "cl:J"], |
|
45
|
|
|
["024", "cl:JJ"], |
|
46
|
|
|
// ["dmy", "cl:yyc"], |
|
|
|
|
|
|
47
|
|
|
// ["dmy", "cl:dddc"], |
|
|
|
|
|
|
48
|
|
|
// ["dmy", "cl:wwc"], |
|
|
|
|
|
|
49
|
|
|
// ["dmy", "cl:d"], |
|
|
|
|
|
|
50
|
|
|
["01", "MM"], |
|
51
|
|
|
["this is constant:24/01/1982", "'this is constant:'dd'/'MM'/'yyyy"], |
|
52
|
|
|
["24", "d"], |
|
53
|
|
|
//["dmy", "cl:x{Claricom.BarillaJulianDate}''cl:J"], |
|
|
|
|
|
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.