1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12use Twig\Environment;
13use Twig\Loader\ArrayLoader;
14
15class Twig_Tests_NativeExtensionTest extends \PHPUnit\Framework\TestCase
16{
17    /**
18     * @requires PHP 5.3
19     */
20    public function testGetProperties()
21    {
22        if (PHP_VERSION_ID >= 70000) {
23            $this->markTestSkipped('Extension is not available on PHP 7+');
24        }
25
26        $twig = new Environment(new ArrayLoader(['index' => '{{ d1.date }}{{ d2.date }}']), [
27            'debug' => true,
28            'cache' => false,
29            'autoescape' => false,
30        ]);
31
32        $d1 = new \DateTime();
33        $d2 = new \DateTime();
34        $output = $twig->render('index', compact('d1', 'd2'));
35
36        // If it fails, PHP will crash.
37        $this->assertEquals($output, $d1->date.$d2->date);
38    }
39}
40