8853a91199005156a1afce343b11f4327952f754
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / LegacyEmptyPassTest.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 Psy\CodeCleaner\LegacyEmptyPass;
15
16 class LegacyEmptyPassTest extends CodeCleanerTestCase
17 {
18     public function setUp()
19     {
20         $this->setPass(new LegacyEmptyPass());
21     }
22
23     /**
24      * @dataProvider invalidStatements
25      * @expectedException \Psy\Exception\ParseErrorException
26      */
27     public function testProcessInvalidStatement($code)
28     {
29         $stmts = $this->parse($code);
30         $this->traverser->traverse($stmts);
31     }
32
33     public function invalidStatements()
34     {
35         if (version_compare(PHP_VERSION, '5.5', '>=')) {
36             return array(
37                 array('empty()'),
38             );
39         }
40
41         return array(
42             array('empty()'),
43             array('empty(null)'),
44             array('empty(PHP_EOL)'),
45             array('empty("wat")'),
46             array('empty(1.1)'),
47             array('empty(Foo::$bar)'),
48         );
49     }
50
51     /**
52      * @dataProvider validStatements
53      */
54     public function testProcessValidStatement($code)
55     {
56         $stmts = $this->parse($code);
57         $this->traverser->traverse($stmts);
58     }
59
60     public function validStatements()
61     {
62         if (version_compare(PHP_VERSION, '5.5', '<')) {
63             return array(
64                 array('empty($foo)'),
65             );
66         }
67
68         return array(
69             array('empty($foo)'),
70             array('empty(null)'),
71             array('empty(PHP_EOL)'),
72             array('empty("wat")'),
73             array('empty(1.1)'),
74             array('empty(Foo::$bar)'),
75         );
76     }
77 }