annotate vendor/nikic/php-parser/test/PhpParser/Builder/UseTest.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 use PhpParser\Builder;
Chris@0 4 use PhpParser\Node\Name;
Chris@0 5 use PhpParser\Node\Stmt;
Chris@13 6 use PHPUnit\Framework\TestCase;
Chris@0 7
Chris@13 8 class UseTest extends TestCase
Chris@0 9 {
Chris@0 10 protected function createUseBuilder($name, $type = Stmt\Use_::TYPE_NORMAL) {
Chris@0 11 return new Builder\Use_($name, $type);
Chris@0 12 }
Chris@0 13
Chris@0 14 public function testCreation() {
Chris@0 15 $node = $this->createUseBuilder('Foo\Bar')->getNode();
Chris@13 16 $this->assertEquals(new Stmt\Use_([
Chris@13 17 new Stmt\UseUse(new Name('Foo\Bar'), null)
Chris@13 18 ]), $node);
Chris@0 19
Chris@0 20 $node = $this->createUseBuilder(new Name('Foo\Bar'))->as('XYZ')->getNode();
Chris@13 21 $this->assertEquals(new Stmt\Use_([
Chris@0 22 new Stmt\UseUse(new Name('Foo\Bar'), 'XYZ')
Chris@13 23 ]), $node);
Chris@0 24
Chris@0 25 $node = $this->createUseBuilder('foo\bar', Stmt\Use_::TYPE_FUNCTION)->as('foo')->getNode();
Chris@13 26 $this->assertEquals(new Stmt\Use_([
Chris@0 27 new Stmt\UseUse(new Name('foo\bar'), 'foo')
Chris@13 28 ], Stmt\Use_::TYPE_FUNCTION), $node);
Chris@0 29 }
Chris@0 30 }