Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/Psy/Test/CodeCleaner/FinalClassPassTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2017 Justin Hileman | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Psy\Test\CodeCleaner; | |
13 | |
14 use PhpParser\NodeTraverser; | |
15 use Psy\CodeCleaner\FinalClassPass; | |
16 | |
17 class FinalClassPassTest extends CodeCleanerTestCase | |
18 { | |
19 public function setUp() | |
20 { | |
21 $this->pass = new FinalClassPass(); | |
22 $this->traverser = new NodeTraverser(); | |
23 $this->traverser->addVisitor($this->pass); | |
24 } | |
25 | |
26 /** | |
27 * @dataProvider invalidStatements | |
28 * @expectedException \Psy\Exception\FatalErrorException | |
29 */ | |
30 public function testProcessStatementFails($code) | |
31 { | |
32 $stmts = $this->parse($code); | |
33 $this->traverser->traverse($stmts); | |
34 } | |
35 | |
36 public function invalidStatements() | |
37 { | |
38 $stmts = array( | |
39 array('final class A {} class B extends A {}'), | |
40 array('class A {} final class B extends A {} class C extends B {}'), | |
41 // array('namespace A { final class B {} } namespace C { class D extends \\A\\B {} }'), | |
42 ); | |
43 | |
44 if (!defined('HHVM_VERSION')) { | |
45 // For some reason Closure isn't final in HHVM? | |
46 $stmts[] = array('class A extends \\Closure {}'); | |
47 } | |
48 | |
49 return $stmts; | |
50 } | |
51 | |
52 /** | |
53 * @dataProvider validStatements | |
54 */ | |
55 public function testProcessStatementPasses($code) | |
56 { | |
57 $stmts = $this->parse($code); | |
58 $this->traverser->traverse($stmts); | |
59 } | |
60 | |
61 public function validStatements() | |
62 { | |
63 return array( | |
64 array('class A extends \\stdClass {}'), | |
65 array('final class A extends \\stdClass {}'), | |
66 array('class A {} class B extends A {}'), | |
67 ); | |
68 } | |
69 } |