mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Add Composer autoloading functions and PHPStan for testing
This commit is contained in:
parent
e198c4db65
commit
f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions
46
vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php
vendored
Normal file
46
vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class TraitTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createTraitBuilder($class) {
|
||||
return new Trait_($class);
|
||||
}
|
||||
|
||||
public function testStmtAddition() {
|
||||
$method1 = new Stmt\ClassMethod('test1');
|
||||
$method2 = new Stmt\ClassMethod('test2');
|
||||
$method3 = new Stmt\ClassMethod('test3');
|
||||
$prop = new Stmt\Property(Stmt\Class_::MODIFIER_PUBLIC, [
|
||||
new Stmt\PropertyProperty('test')
|
||||
]);
|
||||
$use = new Stmt\TraitUse([new Name('OtherTrait')]);
|
||||
$trait = $this->createTraitBuilder('TestTrait')
|
||||
->setDocComment('/** Nice trait */')
|
||||
->addStmt($method1)
|
||||
->addStmts([$method2, $method3])
|
||||
->addStmt($prop)
|
||||
->addStmt($use)
|
||||
->getNode();
|
||||
$this->assertEquals(new Stmt\Trait_('TestTrait', [
|
||||
'stmts' => [$use, $prop, $method1, $method2, $method3]
|
||||
], [
|
||||
'comments' => [
|
||||
new Comment\Doc('/** Nice trait */')
|
||||
]
|
||||
]), $trait);
|
||||
}
|
||||
|
||||
public function testInvalidStmtError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Unexpected node of type "Stmt_Echo"');
|
||||
$this->createTraitBuilder('Test')
|
||||
->addStmt(new Stmt\Echo_([]))
|
||||
;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue