Mercurial > hg > isophonics-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | 1 <?php declare(strict_types=1); |
2 | 2 |
3 namespace PhpParser\Node\Stmt; | 3 namespace PhpParser\Node\Stmt; |
4 | 4 |
5 class ClassTest extends \PHPUnit_Framework_TestCase | 5 use PHPUnit\Framework\TestCase; |
6 | |
7 class ClassTest extends TestCase | |
6 { | 8 { |
7 public function testIsAbstract() { | 9 public function testIsAbstract() { |
8 $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT)); | 10 $class = new Class_('Foo', ['type' => Class_::MODIFIER_ABSTRACT]); |
9 $this->assertTrue($class->isAbstract()); | 11 $this->assertTrue($class->isAbstract()); |
10 | 12 |
11 $class = new Class_('Foo'); | 13 $class = new Class_('Foo'); |
12 $this->assertFalse($class->isAbstract()); | 14 $this->assertFalse($class->isAbstract()); |
13 } | 15 } |
14 | 16 |
15 public function testIsFinal() { | 17 public function testIsFinal() { |
16 $class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL)); | 18 $class = new Class_('Foo', ['type' => Class_::MODIFIER_FINAL]); |
17 $this->assertTrue($class->isFinal()); | 19 $this->assertTrue($class->isFinal()); |
18 | 20 |
19 $class = new Class_('Foo'); | 21 $class = new Class_('Foo'); |
20 $this->assertFalse($class->isFinal()); | 22 $this->assertFalse($class->isFinal()); |
21 } | 23 } |
22 | 24 |
23 public function testGetMethods() { | 25 public function testGetMethods() { |
24 $methods = array( | 26 $methods = [ |
25 new ClassMethod('foo'), | 27 new ClassMethod('foo'), |
26 new ClassMethod('bar'), | 28 new ClassMethod('bar'), |
27 new ClassMethod('fooBar'), | 29 new ClassMethod('fooBar'), |
28 ); | 30 ]; |
29 $class = new Class_('Foo', array( | 31 $class = new Class_('Foo', [ |
30 'stmts' => array( | 32 'stmts' => [ |
31 new TraitUse(array()), | 33 new TraitUse([]), |
32 $methods[0], | 34 $methods[0], |
33 new ClassConst(array()), | 35 new ClassConst([]), |
34 $methods[1], | 36 $methods[1], |
35 new Property(0, array()), | 37 new Property(0, []), |
36 $methods[2], | 38 $methods[2], |
37 ) | 39 ] |
38 )); | 40 ]); |
39 | 41 |
40 $this->assertSame($methods, $class->getMethods()); | 42 $this->assertSame($methods, $class->getMethods()); |
41 } | 43 } |
42 | 44 |
43 public function testGetMethod() { | 45 public function testGetMethod() { |
44 $methodConstruct = new ClassMethod('__CONSTRUCT'); | 46 $methodConstruct = new ClassMethod('__CONSTRUCT'); |
45 $methodTest = new ClassMethod('test'); | 47 $methodTest = new ClassMethod('test'); |
46 $class = new Class_('Foo', array( | 48 $class = new Class_('Foo', [ |
47 'stmts' => array( | 49 'stmts' => [ |
48 new ClassConst(array()), | 50 new ClassConst([]), |
49 $methodConstruct, | 51 $methodConstruct, |
50 new Property(0, array()), | 52 new Property(0, []), |
51 $methodTest, | 53 $methodTest, |
52 ) | 54 ] |
53 )); | 55 ]); |
54 | 56 |
55 $this->assertSame($methodConstruct, $class->getMethod('__construct')); | 57 $this->assertSame($methodConstruct, $class->getMethod('__construct')); |
56 $this->assertSame($methodTest, $class->getMethod('test')); | 58 $this->assertSame($methodTest, $class->getMethod('test')); |
57 $this->assertNull($class->getMethod('nonExisting')); | 59 $this->assertNull($class->getMethod('nonExisting')); |
58 } | 60 } |
59 | |
60 public function testDeprecatedTypeNode() { | |
61 $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT)); | |
62 $this->assertTrue($class->isAbstract()); | |
63 $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->flags); | |
64 $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->type); | |
65 } | |
66 } | 61 } |