Files
Twig/tests/Node/TypesTest.php
T
Jeroen Versteeg 67dabd8182 Add types tag
2024-08-29 19:26:49 +02:00

44 lines
913 B
PHP

<?php
namespace Twig\Tests\Node;
use Twig\Node\TypesNode;
use Twig\Test\NodeTestCase;
class TypesTest extends NodeTestCase
{
private function getValidMapping(): array
{
// {foo: 'string', bar?: 'int'}
return [
'foo' => [
'type' => 'string',
'optional' => false,
],
'bar' => [
'type' => 'int',
'optional' => true,
]
];
}
public function testConstructor()
{
$types = $this->getValidMapping();
$node = new TypesNode($types, 1);
$this->assertEquals($types, $node->getAttribute('mapping'));
}
public function getTests()
{
return [
// 1st test: Node shouldn't compile at all
[
new TypesNode($this->getValidMapping(), 1),
''
]
];
}
}