annotate vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.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\Node\Stmt;
Chris@0 4
Chris@13 5 use PHPUnit\Framework\TestCase;
Chris@13 6
Chris@13 7 class ClassTest extends TestCase
Chris@0 8 {
Chris@0 9 public function testIsAbstract() {
Chris@13 10 $class = new Class_('Foo', ['type' => Class_::MODIFIER_ABSTRACT]);
Chris@0 11 $this->assertTrue($class->isAbstract());
Chris@0 12
Chris@0 13 $class = new Class_('Foo');
Chris@0 14 $this->assertFalse($class->isAbstract());
Chris@0 15 }
Chris@0 16
Chris@0 17 public function testIsFinal() {
Chris@13 18 $class = new Class_('Foo', ['type' => Class_::MODIFIER_FINAL]);
Chris@0 19 $this->assertTrue($class->isFinal());
Chris@0 20
Chris@0 21 $class = new Class_('Foo');
Chris@0 22 $this->assertFalse($class->isFinal());
Chris@0 23 }
Chris@0 24
Chris@0 25 public function testGetMethods() {
Chris@13 26 $methods = [
Chris@0 27 new ClassMethod('foo'),
Chris@0 28 new ClassMethod('bar'),
Chris@0 29 new ClassMethod('fooBar'),
Chris@13 30 ];
Chris@13 31 $class = new Class_('Foo', [
Chris@13 32 'stmts' => [
Chris@13 33 new TraitUse([]),
Chris@0 34 $methods[0],
Chris@13 35 new ClassConst([]),
Chris@0 36 $methods[1],
Chris@13 37 new Property(0, []),
Chris@0 38 $methods[2],
Chris@13 39 ]
Chris@13 40 ]);
Chris@0 41
Chris@0 42 $this->assertSame($methods, $class->getMethods());
Chris@0 43 }
Chris@0 44
Chris@0 45 public function testGetMethod() {
Chris@0 46 $methodConstruct = new ClassMethod('__CONSTRUCT');
Chris@0 47 $methodTest = new ClassMethod('test');
Chris@13 48 $class = new Class_('Foo', [
Chris@13 49 'stmts' => [
Chris@13 50 new ClassConst([]),
Chris@0 51 $methodConstruct,
Chris@13 52 new Property(0, []),
Chris@0 53 $methodTest,
Chris@13 54 ]
Chris@13 55 ]);
Chris@0 56
Chris@0 57 $this->assertSame($methodConstruct, $class->getMethod('__construct'));
Chris@0 58 $this->assertSame($methodTest, $class->getMethod('test'));
Chris@0 59 $this->assertNull($class->getMethod('nonExisting'));
Chris@0 60 }
Chris@0 61 }