4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\CodeCleaner;
14 use PhpParser\NodeTraverser;
15 use Psy\CodeCleaner\AssignThisVariablePass;
17 class AssignThisVariablePassTest extends CodeCleanerTestCase
19 public function setUp()
21 $this->pass = new AssignThisVariablePass();
22 $this->traverser = new NodeTraverser();
23 $this->traverser->addVisitor($this->pass);
27 * @dataProvider invalidStatements
28 * @expectedException \Psy\Exception\FatalErrorException
30 public function testProcessStatementFails($code)
32 $stmts = $this->parse($code);
33 $this->traverser->traverse($stmts);
36 public function invalidStatements()
40 array('strtolower($this = "this")'),
45 * @dataProvider validStatements
47 public function testProcessStatementPasses($code)
49 $stmts = $this->parse($code);
50 $this->traverser->traverse($stmts);
53 public function validStatements()
58 array('$a = "this"; $$a = 3'),
59 array('$$this = "b"'),