I want to write a test to make sure that a variable is protected. Is that possible? Here’s what I got.
/**
* @expectedException Fatal error
* @expectedExceptionMessage Cannot access protected property
*/
public function testCannotAccessProtectedProperty() {
$this->assertEquals($this->object->variableiwanttotest[0], $value);
}
Here is the error message
PHP Fatal error: Cannot access protected property Object::variableiwanttotest in /Users/confidential/ObjectTest.php on line 25
1 Answer