Files
Twig/tests/NativeExtensionTest.php
2019-06-30 14:48:27 +02:00

44 lines
1012 B
PHP

<?php
namespace Twig\Tests;
namespace Twig\Tests;
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Twig\Environment;
use Twig\Loader\ArrayLoader;
class NativeExtensionTest extends \PHPUnit\Framework\TestCase
{
/**
* @requires PHP 5.3
*/
public function testGetProperties()
{
if (\PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Extension is not available on PHP 7+');
}
$twig = new Environment(new ArrayLoader(['index' => '{{ d1.date }}{{ d2.date }}']), [
'debug' => true,
'cache' => false,
'autoescape' => false,
]);
$d1 = new \DateTime();
$d2 = new \DateTime();
$output = $twig->render('index', compact('d1', 'd2'));
// If it fails, PHP will crash.
$this->assertEquals($output, $d1->date.$d2->date);
}
}