mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-24 10:36:26 +00:00
44 lines
942 B
PHP
44 lines
942 B
PHP
<?php
|
|
|
|
namespace Twig\Tests\Node;
|
|
|
|
use Twig\Node\TypesNode;
|
|
use Twig\Test\NodeTestCase;
|
|
|
|
class TypesTest extends NodeTestCase
|
|
{
|
|
private static function getValidMapping(): array
|
|
{
|
|
// {foo: 'string', bar?: 'int'}
|
|
return [
|
|
'foo' => [
|
|
'type' => 'string',
|
|
'optional' => false,
|
|
],
|
|
'bar' => [
|
|
'type' => 'int',
|
|
'optional' => true,
|
|
],
|
|
];
|
|
}
|
|
|
|
public function testConstructor()
|
|
{
|
|
$types = self::getValidMapping();
|
|
$node = new TypesNode($types, 1);
|
|
|
|
$this->assertEquals($types, $node->getAttribute('mapping'));
|
|
}
|
|
|
|
public static function provideTests(): iterable
|
|
{
|
|
return [
|
|
// 1st test: Node shouldn't compile at all
|
|
[
|
|
new TypesNode(self::getValidMapping(), 1),
|
|
'',
|
|
],
|
|
];
|
|
}
|
|
}
|