/var/www/vhosts/ihelp.ro/httpdocs/vendor/jasny/twig-extensions/tests
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/jasny/twig-extensions/tests/DateExtensionTest.php (4458B)
markAsSkipped("Unable to set locale to 'en_EN'");
}
$this->assertRender($en, $template);
}
/**
* @dataProvider localDateTimeProvider
*
* @param string $en
* @param string $nl
* @param string $template
*/
public function testLocalDateTimeNL($en, $nl, $template)
{
if (!\Locale::setDefault("nl_NL")) {
return $this->markAsSkipped("Unable to set locale to 'nl_NL'");
}
$this->assertRender($nl, $template);
}
public function durationProvider()
{
return [
['31s', "{{ 31|duration }}"],
['17m 31s', "{{ 1051|duration }}"],
['3h 17m 31s', "{{ 11851|duration }}"],
['2d 3h 17m 31s', "{{ 184651|duration }}"],
['3w 2d 3h 17m 31s', "{{ 1999051|duration }}"],
['1y 3w 2d 3h 17m 31s', "{{ 33448651|duration }}"],
['17 minute(s)', "{{ 1051|duration([null, ' minute(s)', ' hour(s)', ' day(s)']) }}"],
['3 hour(s)', "{{ 11851|duration([null, null, ' hour(s)']) }}"],
['2 day(s)', "{{ 184651|duration([null, null, null, ' day(s)']) }}"],
['3 week(s)', "{{ 1999051|duration([null, null, null, null, ' week(s)']) }}"],
['1 year(s)', "{{ 33448651|duration([null, null, null, null, null, ' year(s)']) }}"],
['3u:17m', "{{ 11851|duration([null, 'm', 'u'], ':') }}"],
['3:17h', "{{ 11851|duration([null, '', ''], ':') }}h"],
];
}
/**
* @dataProvider durationProvider
*
* @param string $expect
* @param string $template
*/
public function testDuration($expect, $template)
{
$this->assertRender($expect, $template);
}
public function ageProvider()
{
$time = time() - (((32 * 365) + 100) * 24 * 3600);
$date = date('Y-m-d', $time);
return [
['32', "{{ $time|age }}"],
['32', "{{ '$date'|age }}"]
];
}
/**
* @dataProvider ageProvider
*
* @param string $expect
* @param string $template
*/
public function testAge($expect, $template)
{
$this->assertRender($expect, $template);
}
public function filterProvider()
{
return [
['localdate'],
['localtime'],
['localdatetime'],
['duration'],
['age']
];
}
/**
* @dataProvider filterProvider
*
* @param string $filter
*/
public function testWithNull($filter)
{
$this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}');
}
}