comparison vendor/psy/psysh/test/Psy/Test/CodeCleaner/LeavePsyshAlonePassTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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
29 /**
30 * @dataProvider validStatements
31 */
32 public function testProcessStatementPasses($code)
33 {
34 $stmts = $this->parse($code);
35 $this->traverse($stmts);
36 }
37
38 public function validStatements()
39 {
40 return array(
41 array('array_merge()'),
42 array('__psysh__()'),
43 array('$this'),
44 array('$psysh'),
45 array('$__psysh'),
46 array('$banana'),
47 );
48 }
49
50 /**
51 * @dataProvider invalidStatements
52 * @expectedException \Psy\Exception\RuntimeException
53 */
54 public function testProcessStatementFails($code)
55 {
56 $stmts = $this->parse($code);
57 $this->traverse($stmts);
58 }
59
60 public function invalidStatements()
61 {
62 return array(
63 array('$__psysh__'),
64 array('var_dump($__psysh__)'),
65 array('$__psysh__ = "your mom"'),
66 array('$__psysh__->fakeFunctionCall()'),
67 );
68 }
69 }