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\InstanceOfPass;
16 class InstanceOfPassTest extends CodeCleanerTestCase
18 protected function setUp()
20 $this->setPass(new InstanceOfPass());
24 * @dataProvider invalidStatements
25 * @expectedException \Psy\Exception\FatalErrorException
27 public function testProcessInvalidStatement($code)
29 $this->parseAndTraverse($code);
32 public function invalidStatements()
35 ['null instanceof stdClass'],
36 ['true instanceof stdClass'],
37 ['9 instanceof stdClass'],
38 ['1.0 instanceof stdClass'],
39 ['"foo" instanceof stdClass'],
40 ['__DIR__ instanceof stdClass'],
41 ['PHP_SAPI instanceof stdClass'],
42 ['1+1 instanceof stdClass'],
43 ['true && false instanceof stdClass'],
44 ['"a"."b" instanceof stdClass'],
45 ['!5 instanceof stdClass'],
50 * @dataProvider validStatements
52 public function testProcessValidStatement($code)
54 $this->parseAndTraverse($code);
55 $this->assertTrue(true);
58 public function validStatements()
61 ['$a instanceof stdClass'],
62 ['strtolower("foo") instanceof stdClass'],
63 ['array(1) instanceof stdClass'],
64 ['(string) "foo" instanceof stdClass'],
65 ['(1+1) instanceof stdClass'],
66 ['"foo ${foo} $bar" instanceof stdClass'],
67 ['DateTime::ISO8601 instanceof stdClass'],