Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / ValidConstantPassTest.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\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         $stmts = $this->parse($code);
30         $this->traverse($stmts);
31     }
32
33     public function getInvalidReferences()
34     {
35         return array(
36             array('Foo\BAR'),
37
38             // class constant fetch
39             array('Psy\Test\CodeCleaner\ValidConstantPassTest::FOO'),
40             array('DateTime::BACON'),
41         );
42     }
43
44     /**
45      * @dataProvider getValidReferences
46      */
47     public function testProcessValidConstantReferences($code)
48     {
49         $stmts = $this->parse($code);
50         $this->traverse($stmts);
51     }
52
53     public function getValidReferences()
54     {
55         return array(
56             array('PHP_EOL'),
57
58             // class constant fetch
59             array('NotAClass::FOO'),
60             array('DateTime::ATOM'),
61             array('$a = new DateTime; $a::ATOM'),
62             array('DateTime::class'),
63             array('$a = new DateTime; $a::class'),
64         );
65     }
66 }