Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/PhpParser/Builder/TraitUseTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php declare(strict_types=1); | |
2 | |
3 namespace PhpParser\Builder; | |
4 | |
5 use PhpParser\Node\Name; | |
6 use PhpParser\Node\Stmt; | |
7 | |
8 class TraitUseTest extends \PHPUnit\Framework\TestCase | |
9 { | |
10 protected function createTraitUseBuilder(...$traits) { | |
11 return new TraitUse(...$traits); | |
12 } | |
13 | |
14 public function testAnd() { | |
15 $node = $this->createTraitUseBuilder('SomeTrait') | |
16 ->and('AnotherTrait') | |
17 ->getNode() | |
18 ; | |
19 | |
20 $this->assertEquals( | |
21 new Stmt\TraitUse([ | |
22 new Name('SomeTrait'), | |
23 new Name('AnotherTrait') | |
24 ]), | |
25 $node | |
26 ); | |
27 } | |
28 | |
29 public function testWith() { | |
30 $node = $this->createTraitUseBuilder('SomeTrait') | |
31 ->with(new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar')) | |
32 ->with((new TraitUseAdaptation(null, 'test'))->as('baz')) | |
33 ->getNode() | |
34 ; | |
35 | |
36 $this->assertEquals( | |
37 new Stmt\TraitUse([new Name('SomeTrait')], [ | |
38 new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar'), | |
39 new Stmt\TraitUseAdaptation\Alias(null, 'test', null, 'baz') | |
40 ]), | |
41 $node | |
42 ); | |
43 } | |
44 | |
45 public function testInvalidAdaptationNode() { | |
46 $this->expectException(\LogicException::class); | |
47 $this->expectExceptionMessage('Adaptation must have type TraitUseAdaptation'); | |
48 $this->createTraitUseBuilder('Test') | |
49 ->with(new Stmt\Echo_([])) | |
50 ; | |
51 } | |
52 } |