Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / AbstractClassPassTest.php
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\AbstractClassPass;
16
17 class AbstractClassPassTest extends CodeCleanerTestCase
18 {
19     public function setUp()
20     {
21         $this->pass      = new AbstractClassPass();
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         return array(
39             array('class A { abstract function a(); }'),
40             array('abstract class B { abstract function b() {} }'),
41             array('abstract class B { abstract function b() { echo "yep"; } }'),
42         );
43     }
44
45     /**
46      * @dataProvider validStatements
47      */
48     public function testProcessStatementPasses($code)
49     {
50         $stmts = $this->parse($code);
51         $this->traverser->traverse($stmts);
52     }
53
54     public function validStatements()
55     {
56         return array(
57             array('abstract class C { function c() {} }'),
58             array('abstract class D { abstract function d(); }'),
59         );
60     }
61 }