From d2243c33174442a349603ce4457f4368441e2b5f Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Tue, 12 Apr 2016 16:12:38 -0400 Subject: [PATCH] Add sanity check tests --- tests/TypeTest.php | 113 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/tests/TypeTest.php b/tests/TypeTest.php index 883e3a81a..177b13439 100644 --- a/tests/TypeTest.php +++ b/tests/TypeTest.php @@ -761,4 +761,117 @@ class TypeTest extends PHPUnit_Framework_TestCase $file_checker = new \CodeInspector\FileChecker('somefile.php', $stmts); $file_checker->check(); } + + public function testVariableReassignment() + { + $stmts = self::$_parser->parse('bar(); + + '); + + $file_checker = new \CodeInspector\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } + + public function testVariableReassignmentInIf() + { + $stmts = self::$_parser->parse('bar(); + } + + '); + + $file_checker = new \CodeInspector\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } + + /** + * @expectedException CodeInspector\CodeException + */ + public function testVariableReassignmentInIfWithOutsideCall() + { + $stmts = self::$_parser->parse('bar(); + } + + $one->bar(); + + '); + + $file_checker = new \CodeInspector\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } + + public function testUnionTypeFlow() + { + $stmts = self::$_parser->parse('foo(); + } + else { + if ($var instanceof Two) { + $var->bar(); + } + else if ($var) { + $var->baz(); + } + } + '); + + $file_checker = new \CodeInspector\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } }