PHP-Parser/test/PhpParser/Node/ParamTest.php

38 lines
1.0 KiB
PHP
Raw Normal View History

2022-07-19 21:10:35 +02:00
<?php declare(strict_types=1);
namespace PhpParser\Node;
2022-07-19 21:10:35 +02:00
use PhpParser\Modifiers;
2022-07-19 21:10:35 +02:00
use PhpParser\Node\Expr\Variable;
class ParamTest extends \PHPUnit\Framework\TestCase {
2022-07-19 21:10:35 +02:00
public function testNoModifiers() {
$node = new Param(new Variable('foo'));
$this->assertFalse($node->isPromoted());
$this->assertFalse($node->isPrivate());
$this->assertFalse($node->isProtected());
$this->assertFalse($node->isPrivate());
2022-07-19 21:10:35 +02:00
$this->assertFalse($node->isReadonly());
}
/**
* @dataProvider provideModifiers
*/
public function testModifiers(string $modifier) {
$node = new Param(new Variable('foo'));
$node->flags = constant(Modifiers::class . '::' . strtoupper($modifier));
$this->assertTrue($node->isPromoted());
$this->assertTrue($node->{'is' . $modifier}());
}
2022-07-19 21:10:35 +02:00
public function provideModifiers() {
return [
['public'],
['protected'],
['private'],
['readonly'],
];
2022-07-19 21:10:35 +02:00
}
}