Mercurial > hg > isophonics-drupal-site
annotate vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
rev | line source |
---|---|
Chris@13 | 1 <?php declare(strict_types=1); |
Chris@0 | 2 |
Chris@0 | 3 namespace PhpParser\Builder; |
Chris@0 | 4 |
Chris@0 | 5 use PhpParser\Comment; |
Chris@0 | 6 use PhpParser\Node\Name; |
Chris@0 | 7 use PhpParser\Node\Stmt; |
Chris@13 | 8 use PHPUnit\Framework\TestCase; |
Chris@0 | 9 |
Chris@13 | 10 class TraitTest extends TestCase |
Chris@0 | 11 { |
Chris@0 | 12 protected function createTraitBuilder($class) { |
Chris@0 | 13 return new Trait_($class); |
Chris@0 | 14 } |
Chris@0 | 15 |
Chris@0 | 16 public function testStmtAddition() { |
Chris@0 | 17 $method1 = new Stmt\ClassMethod('test1'); |
Chris@0 | 18 $method2 = new Stmt\ClassMethod('test2'); |
Chris@0 | 19 $method3 = new Stmt\ClassMethod('test3'); |
Chris@13 | 20 $prop = new Stmt\Property(Stmt\Class_::MODIFIER_PUBLIC, [ |
Chris@0 | 21 new Stmt\PropertyProperty('test') |
Chris@13 | 22 ]); |
Chris@0 | 23 $use = new Stmt\TraitUse([new Name('OtherTrait')]); |
Chris@0 | 24 $trait = $this->createTraitBuilder('TestTrait') |
Chris@0 | 25 ->setDocComment('/** Nice trait */') |
Chris@0 | 26 ->addStmt($method1) |
Chris@0 | 27 ->addStmts([$method2, $method3]) |
Chris@0 | 28 ->addStmt($prop) |
Chris@0 | 29 ->addStmt($use) |
Chris@0 | 30 ->getNode(); |
Chris@0 | 31 $this->assertEquals(new Stmt\Trait_('TestTrait', [ |
Chris@0 | 32 'stmts' => [$use, $prop, $method1, $method2, $method3] |
Chris@0 | 33 ], [ |
Chris@0 | 34 'comments' => [ |
Chris@0 | 35 new Comment\Doc('/** Nice trait */') |
Chris@0 | 36 ] |
Chris@0 | 37 ]), $trait); |
Chris@0 | 38 } |
Chris@0 | 39 |
Chris@0 | 40 /** |
Chris@0 | 41 * @expectedException \LogicException |
Chris@0 | 42 * @expectedExceptionMessage Unexpected node of type "Stmt_Echo" |
Chris@0 | 43 */ |
Chris@0 | 44 public function testInvalidStmtError() { |
Chris@0 | 45 $this->createTraitBuilder('Test') |
Chris@13 | 46 ->addStmt(new Stmt\Echo_([])) |
Chris@0 | 47 ; |
Chris@0 | 48 } |
Chris@0 | 49 } |