DateTimeFormatterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace JhFlexiTimeTest\Filter;
4
5
use JhFlexiTime\Filter\DateTimeFormatter;
6
use DateTime;
7
8
/**
9
 * Class DateTimeFormatterTest
10
 * @package JhFlexiTimeTest\Filter
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class DateTimeFormatterTest extends \PHPUnit_Framework_TestCase
14
{
15
16
    /**
17
     * @var DateTimeFormatter
18
     */
19
    protected $formatter;
20
21
    /**
22
     * SetUp
23
     */
24
    public function setUp()
25
    {
26
        $this->formatter = new DateTimeFormatter();
27
    }
28
29
    /**
30
     * @param $value
31
     * @param $expected
32
     *
33
     * @dataProvider filterValuesProvider
34
     */
35
    public function testDateTimeFormatterFilter($value, $expected)
36
    {
37
        $filteredValue = $this->formatter->filter($value);
38
        $this->assertEquals($expected, $filteredValue);
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function filterValuesProvider()
45
    {
46
        return [
47
            "valid-input-1"     => ["23 March 2014"    , new DateTime("23 March 2014")],
48
            "valid-input-2"     => ["23 Mar 2014"      , new DateTime("23 March 2014")],
49
            "invalid-input-1"   => ["23/03/2014"       , "23/03/2014"],
50
            "invalid-input-2"   => ["not-a-date"       , "not-a-date"],
51
            "no-input"          => [""                 , ""],
52
            "timestamp"         => [1359739801         , new DateTime("01 February 2013 17:30:01 +00:00")]
53
        ];
54
    }
55
}
56