a6c52e0419d8f5c8f52e86b98191a294c82a0f55
[yaffs-website] / vendor / psy / psysh / test / CodeCleaner / ValidConstantPassTest.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\ValidConstantPass;
15
16 class ValidConstantPassTest extends CodeCleanerTestCase
17 {
18     public function setUp()
19     {
20         $this->setPass(new ValidConstantPass());
21     }
22
23     /**
24      * @dataProvider getInvalidReferences
25      * @expectedException \Psy\Exception\FatalErrorException
26      */
27     public function testProcessInvalidConstantReferences($code)
28     {
29         $this->parseAndTraverse($code);
30     }
31
32     public function getInvalidReferences()
33     {
34         return [
35             ['Foo\BAR'],
36
37             // class constant fetch
38             ['Psy\Test\CodeCleaner\ValidConstantPassTest::FOO'],
39             ['DateTime::BACON'],
40         ];
41     }
42
43     /**
44      * @dataProvider getValidReferences
45      */
46     public function testProcessValidConstantReferences($code)
47     {
48         $this->parseAndTraverse($code);
49         $this->assertTrue(true);
50     }
51
52     public function getValidReferences()
53     {
54         return [
55             ['PHP_EOL'],
56
57             // class constant fetch
58             ['NotAClass::FOO'],
59             ['DateTime::ATOM'],
60             ['$a = new DateTime; $a::ATOM'],
61             ['DateTime::class'],
62             ['$a = new DateTime; $a::class'],
63         ];
64     }
65 }