X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fnikic%2Fphp-parser%2Ftest%2FPhpParser%2FBuilder%2FTraitUseTest.php;fp=vendor%2Fnikic%2Fphp-parser%2Ftest%2FPhpParser%2FBuilder%2FTraitUseTest.php;h=ec4e9400aab499231b92be41b647fcaffc748b0a;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/nikic/php-parser/test/PhpParser/Builder/TraitUseTest.php b/vendor/nikic/php-parser/test/PhpParser/Builder/TraitUseTest.php new file mode 100644 index 000000000..ec4e9400a --- /dev/null +++ b/vendor/nikic/php-parser/test/PhpParser/Builder/TraitUseTest.php @@ -0,0 +1,55 @@ +createTraitUseBuilder('SomeTrait') + ->and('AnotherTrait') + ->getNode() + ; + + $this->assertEquals( + new Stmt\TraitUse([ + new Name('SomeTrait'), + new Name('AnotherTrait') + ]), + $node + ); + } + + public function testWith() { + $node = $this->createTraitUseBuilder('SomeTrait') + ->with(new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar')) + ->with((new TraitUseAdaptation(null, 'test'))->as('baz')) + ->getNode() + ; + + $this->assertEquals( + new Stmt\TraitUse([new Name('SomeTrait')], [ + new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar'), + new Stmt\TraitUseAdaptation\Alias(null, 'test', null, 'baz') + ]), + $node + ); + } + + public function testInvalidAdaptationNode() { + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('Adaptation must have type TraitUseAdaptation'); + $this->createTraitUseBuilder('Test') + ->with(new Stmt\Echo_([])) + ; + } +}