Security update for Core, with self-updated composer
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / CodeCleaner / LeavePsyshAlonePassTest.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\LeavePsyshAlonePass;
15
16 class LeavePsyshAlonePassTest extends CodeCleanerTestCase
17 {
18     public function setUp()
19     {
20         $this->setPass(new LeavePsyshAlonePass());
21     }
22
23     public function testPassesInlineHtmlThroughJustFine()
24     {
25         $inline = $this->parse('not php at all!', '');
26         $this->traverse($inline);
27
28         // @todo a better thing to assert here?
29         $this->assertTrue(true);
30     }
31
32     /**
33      * @dataProvider validStatements
34      */
35     public function testProcessStatementPasses($code)
36     {
37         $stmts = $this->parse($code);
38         $this->traverse($stmts);
39
40         // @todo a better thing to assert here?
41         $this->assertTrue(true);
42     }
43
44     public function validStatements()
45     {
46         return array(
47             array('array_merge()'),
48             array('__psysh__()'),
49             array('$this'),
50             array('$psysh'),
51             array('$__psysh'),
52             array('$banana'),
53         );
54     }
55
56     /**
57      * @dataProvider invalidStatements
58      * @expectedException \Psy\Exception\RuntimeException
59      */
60     public function testProcessStatementFails($code)
61     {
62         $stmts = $this->parse($code);
63         $this->traverse($stmts);
64     }
65
66     public function invalidStatements()
67     {
68         return array(
69             array('$__psysh__'),
70             array('var_dump($__psysh__)'),
71             array('$__psysh__ = "your mom"'),
72             array('$__psysh__->fakeFunctionCall()'),
73         );
74     }
75 }