forked from timber/timber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-timber-twig-date-filter-default.php
73 lines (60 loc) · 1.75 KB
/
test-timber-twig-date-filter-default.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Replicates Twig tests from twig/twig/tests/Fixtures/filters/date_default*.test
*
* @group Timber\Date
*/
class TestTimberTwigDateFilterDefault extends Timber_UnitTestCase
{
public function set_up()
{
parent::set_up();
update_option('date_format', 'Y-m-d');
}
public function get_context()
{
return [
'date1' => mktime(13, 45, 0, 10, 4, 2010),
];
}
public function testDateFormat1()
{
$result = Timber\Timber::compile_string(
"{{ date1|date }}",
$this->get_context()
);
$this->assertEquals('2010-10-04', $result);
}
public function testDateFormat2()
{
$result = Timber\Timber::compile_string(
"{{ date1|date('d/m/Y') }}",
$this->get_context()
);
$this->assertEquals('04/10/2010', $result);
}
public function testDateFormat3()
{
$result = Timber\Timber::compile_string(
"{{ date1|date(format='d/m/Y H:i:s P', timezone='America/Chicago') }}",
$this->get_context()
);
$this->assertEquals('04/10/2010 08:45:00 -05:00', $result);
}
public function testDateFormat4()
{
$result = Timber\Timber::compile_string(
"{{ date1|date(timezone='America/Chicago', format='d/m/Y H:i:s P') }}",
$this->get_context()
);
$this->assertEquals('04/10/2010 08:45:00 -05:00', $result);
}
public function testDateFormat5()
{
$result = Timber\Timber::compile_string(
"{{ date1|date('d/m/Y H:i:s P', timezone='America/Chicago') }}",
$this->get_context()
);
$this->assertEquals('04/10/2010 08:45:00 -05:00', $result);
}
}