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 Psy\CodeCleaner\ValidFunctionNamePass;
16 class ValidFunctionNamePassTest extends CodeCleanerTestCase
18 public function setUp()
20 $this->setPass(new ValidFunctionNamePass());
24 * @dataProvider getInvalidFunctions
25 * @expectedException \Psy\Exception\FatalErrorException
27 public function testProcessInvalidFunctionCallsAndDeclarations($code)
29 $stmts = $this->parse($code);
30 $this->traverse($stmts);
33 public function getInvalidFunctions()
36 // function declarations
37 array('function array_merge() {}'),
38 array('function Array_Merge() {}'),
40 function psy_test_codecleaner_validfunctionnamepass_alpha() {}
41 function psy_test_codecleaner_validfunctionnamepass_alpha() {}
44 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
47 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
53 array('psy_test_codecleaner_validfunctionnamepass_gamma()'),
55 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
61 array('function a() { a(); } function a() {}'),
66 * @dataProvider getValidFunctions
68 public function testProcessValidFunctionCallsAndDeclarations($code)
70 $stmts = $this->parse($code);
71 $this->traverse($stmts);
74 public function getValidFunctions()
77 array('function psy_test_codecleaner_validfunctionnamepass_epsilon() {}'),
79 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
85 function psy_test_codecleaner_validfunctionnamepass_eta() {}
87 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
88 function psy_test_codecleaner_validfunctionnamepass_eta() {}
92 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
93 function psy_test_codecleaner_validfunctionnamepass_eta() {}
96 function psy_test_codecleaner_validfunctionnamepass_eta() {}
100 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
101 function array_merge() {}
106 array('array_merge();'),
108 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
111 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
116 array('$test = function(){};$test()'),
118 namespace Psy\\Test\\CodeCleaner\\ValidFunctionNamePass {
122 Psy\\Test\\CodeCleaner\\ValidFunctionNamePass\\theta();
127 array('function a() { a(); }'),
129 // conditionally defined functions
159 while (false) { function a() {} }
163 do { function a() {} } while (false);