-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
PropertyHook::isFinal()
helper method with tests
- Loading branch information
1 parent
96d40b0
commit aaab8ec
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpParser\Node; | ||
|
||
use PhpParser\Modifiers; | ||
|
||
class PropertyHookTest extends \PHPUnit\Framework\TestCase { | ||
/** | ||
* @dataProvider provideModifiers | ||
*/ | ||
public function testModifiers($modifier): void { | ||
$node = new PropertyHook( | ||
'get', | ||
null, | ||
[ | ||
'flags' => constant(Modifiers::class . '::' . strtoupper($modifier)), | ||
] | ||
); | ||
|
||
$this->assertTrue($node->{'is' . $modifier}()); | ||
} | ||
|
||
public function testNoModifiers(): void { | ||
$node = new PropertyHook('get', null); | ||
|
||
$this->assertFalse($node->isFinal()); | ||
} | ||
|
||
public static function provideModifiers() { | ||
return [ | ||
['final'], | ||
]; | ||
} | ||
|
||
public function testIsFinal() { | ||
$node = new PropertyHook( | ||
'get', | ||
null, | ||
[ | ||
'flags' => Modifiers::FINAL, | ||
] | ||
); | ||
$this->assertTrue($node->isFinal()); | ||
} | ||
} |