diff --git a/phpunit/code/re-assign-array-to-bool.php b/phpunit/code/re-assign-array-to-bool.php new file mode 100644 index 00000000..e15cfe71 --- /dev/null +++ b/phpunit/code/re-assign-array-to-bool.php @@ -0,0 +1,7 @@ +exec('Cannot re-assign variable', 're-assign.php'); + $this->exec('Cannot re-assign `$obj` from `php::Str` to `php::Object`', 're-assign.php'); } public function testAssignClass() @@ -51,4 +53,107 @@ class AssignTest extends \BaseTest 'std-unsafe-ptr-argument-requires-container.php' ); } + + // === Object value assigned to non-object variable (right side is New_ expr) === + + public function testObjectToInt() + { + $this->exec("Cannot re-assign `\$x` from `php::Object` to `php::Int`", 're-assign-obj-to-int.php'); + } + + public function testObjectToFloat() + { + $this->exec("Cannot re-assign `\$x` from `php::Object` to `php::Float`", 're-assign-obj-to-float.php'); + } + + public function testObjectToBool() + { + $this->exec("Cannot re-assign `\$x` from `php::Object` to `php::Bool`", 're-assign-obj-to-bool.php'); + } + + public function testObjectToStr() + { + $this->exec("Cannot re-assign `\$x` from `php::Object` to `php::Str`", 're-assign-obj-to-str.php'); + } + + public function testObjectToArray() + { + $this->exec("Cannot re-assign `\$obj` from `php::Object` to `php::Array`", 're-assign-obj-to-array.php'); + } + + // === Non-object value assigned to Object variable === + + public function testIntToObject() + { + $this->exec("Cannot re-assign `\$obj` from `php::Int` to `php::Object`", 're-assign-int-to-obj.php'); + } + + public function testFloatToObject() + { + $this->exec("Cannot re-assign `\$obj` from `php::Float` to `php::Object`", 're-assign-float-to-obj.php'); + } + + public function testBoolToObject() + { + $this->exec("Cannot re-assign `\$obj` from `php::Bool` to `php::Object`", 're-assign-bool-to-obj.php'); + } + + public function testArrayToObject() + { + $this->exec("Cannot re-assign `\$obj` from `php::Array` to `php::Object`", 're-assign-array-to-obj.php'); + } + + // === Str / Array value assigned to non-object scalar variable === + + public function testStrToInt() + { + $this->exec("Cannot re-assign `\$x` from `php::Str` to `php::Int`", 're-assign-str-to-int.php'); + } + + public function testArrayToInt() + { + $this->exec("Cannot re-assign `\$x` from `php::Array` to `php::Int`", 're-assign-array-to-int.php'); + } + + public function testStrToFloat() + { + $this->exec("Cannot re-assign `\$x` from `php::Str` to `php::Float`", 're-assign-str-to-float.php'); + } + + public function testArrayToFloat() + { + $this->exec("Cannot re-assign `\$x` from `php::Array` to `php::Float`", 're-assign-array-to-float.php'); + } + + public function testStrToBool() + { + $this->exec("Cannot re-assign `\$x` from `php::Str` to `php::Bool`", 're-assign-str-to-bool.php'); + } + + public function testArrayToBool() + { + $this->exec("Cannot re-assign `\$x` from `php::Array` to `php::Bool`", 're-assign-array-to-bool.php'); + } + + // === Scalar value assigned to Array variable === + + public function testIntToArray() + { + $this->exec("Cannot re-assign `\$x` from `php::Int` to `php::Array`", 're-assign-int-to-array.php'); + } + + public function testFloatToArray() + { + $this->exec("Cannot re-assign `\$x` from `php::Float` to `php::Array`", 're-assign-float-to-array.php'); + } + + public function testBoolToArray() + { + $this->exec("Cannot re-assign `\$x` from `php::Bool` to `php::Array`", 're-assign-bool-to-array.php'); + } + + public function testStrToArray() + { + $this->exec("Cannot re-assign `\$x` from `php::Str` to `php::Array`", 're-assign-str-to-array.php'); + } }