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
|
|
|
* @dataProvider testGetDateFormatDataProvider |
12
|
|
|
*/ |
13
|
|
|
public function testFormat($expected, $format) |
14
|
|
|
{ |
15
|
|
|
$dateFormatter = DateFormatterFactory::getFormatter($format); |
16
|
|
|
|
17
|
|
|
$date = new DateTimeImmutable('1982-01-24'); |
18
|
|
|
|
19
|
|
|
$actual = $dateFormatter->format($date, $format); |
20
|
|
|
|
21
|
|
|
$this->assertSame($expected, $actual); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testGetDateFormatDataProvider() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
["24011982", "dd''MM''yyyy"], |
28
|
|
|
["24 01 1982", "dd' 'MM' 'yyyy"], |
29
|
|
|
["24.01.1982", "dd'.'MM'.'yyyy"], |
30
|
|
|
["24,01,1982", "dd','MM','yyyy"], |
31
|
|
|
["24-01-1982", "dd'-'MM'-'yyyy"], |
32
|
|
|
["24\\01\\1982", "dd'\'MM'\'yyyy"], |
33
|
|
|
["24:01:1982", "dd':'MM':'yyyy"], |
34
|
|
|
//["81", "y"], |
|
|
|
|
35
|
|
|
//["", "cl:yy"], |
|
|
|
|
36
|
|
|
["24", "cl:j"], |
37
|
|
|
["024", "cl:jj"], |
38
|
|
|
["24", "cl:J"], |
39
|
|
|
["024", "cl:JJ"], |
40
|
|
|
// ["dmy", "cl:yyc"], |
|
|
|
|
41
|
|
|
// ["dmy", "cl:dddc"], |
|
|
|
|
42
|
|
|
// ["dmy", "cl:wwc"], |
|
|
|
|
43
|
|
|
// ["dmy", "cl:d"], |
|
|
|
|
44
|
|
|
["01", "MM"], |
45
|
|
|
["this is constant:24/01/1982", "'this is constant:'dd'/'MM'/'yyyy"], |
46
|
|
|
["24", "d"], |
47
|
|
|
//["dmy", "cl:x{Claricom.BarillaJulianDate}''cl:J"], |
|
|
|
|
48
|
|
|
]; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.