phpunit – mockbuilder – set mock object internal property
You can make the property public by using Reflection, and then set the desired value: $a = new A; $reflection = new ReflectionClass($a); $reflection_property = $reflection->getProperty(‘p’); $reflection_property->setAccessible(true); $reflection_property->setValue($a, 2); Anyway in your example you don’t need to set p value for the Exception to be raised. You are using a mock for being able to … Read more