4 * This file is part of Psy Shell.
6 * (c) 2012-2018 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\CalledClassPass;
16 class CalledClassPassTest extends CodeCleanerTestCase
18 public function setUp()
20 $this->setPass(new CalledClassPass());
24 * @dataProvider invalidStatements
25 * @expectedException \Psy\Exception\ErrorException
27 public function testProcessStatementFails($code)
29 $this->parseAndTraverse($code);
32 public function invalidStatements()
37 ['get_called_class()'],
38 ['get_called_class(null)'],
39 ['function foo() { return get_class(); }'],
40 ['function foo() { return get_class(null); }'],
41 ['function foo() { return get_called_class(); }'],
42 ['function foo() { return get_called_class(null); }'],
47 * @dataProvider validStatements
49 public function testProcessStatementPasses($code)
51 $this->parseAndTraverse($code);
52 $this->assertTrue(true);
55 public function validStatements()
60 ['get_called_class($foo)'],
61 ['get_called_class(bar())'],
62 ['function foo($bar) { return get_class($bar); }'],
63 ['function foo($bar) { return get_called_class($bar); }'],
64 ['class Foo { function bar() { return get_class(); } }'],
65 ['class Foo { function bar() { return get_class(null); } }'],
66 ['class Foo { function bar() { return get_called_class(); } }'],
67 ['class Foo { function bar() { return get_called_class(null); } }'],
68 ['$foo = function () {}; $foo()'],
73 * @dataProvider validTraitStatements
75 public function testProcessTraitStatementPasses($code)
77 $this->parseAndTraverse($code);
78 $this->assertTrue(true);
81 public function validTraitStatements()
84 ['trait Foo { function bar() { return get_class(); } }'],
85 ['trait Foo { function bar() { return get_class(null); } }'],
86 ['trait Foo { function bar() { return get_called_class(); } }'],
87 ['trait Foo { function bar() { return get_called_class(null); } }'],