5c4c7b0590a0fb9d4048e3da3e44a3de7c3f8d11
[yaffs-website] / vendor / psy / psysh / test / CodeCleaner / LegacyEmptyPassTest.php
1 <?php
2
3 /*
4  * This file is part of Psy Shell.
5  *
6  * (c) 2012-2018 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         $this->parseAndTraverse($code);
30     }
31
32     public function invalidStatements()
33     {
34         if (\version_compare(PHP_VERSION, '5.5', '>=')) {
35             return [
36                 ['empty()'],
37             ];
38         }
39
40         return [
41             ['empty()'],
42             ['empty(null)'],
43             ['empty(PHP_EOL)'],
44             ['empty("wat")'],
45             ['empty(1.1)'],
46             ['empty(Foo::$bar)'],
47         ];
48     }
49
50     /**
51      * @dataProvider validStatements
52      */
53     public function testProcessValidStatement($code)
54     {
55         $this->parseAndTraverse($code);
56         $this->assertTrue(true);
57     }
58
59     public function validStatements()
60     {
61         if (\version_compare(PHP_VERSION, '5.5', '<')) {
62             return [
63                 ['empty($foo)'],
64             ];
65         }
66
67         return [
68             ['empty($foo)'],
69             ['empty(null)'],
70             ['empty(PHP_EOL)'],
71             ['empty("wat")'],
72             ['empty(1.1)'],
73             ['empty(Foo::$bar)'],
74         ];
75     }
76 }