Is it possible to create a mock object with disabled constructor and manually setted protected properties?
Here is an idiotic example:
class A {
Based on the accepted answer from @gontrollez, since we are using a mock builder we do not have the need to call new A; since we can use the class name instead.
$a = $this->getMockBuilder(A::class)
->disableOriginalConstructor()
->getMock();
$reflection = new ReflectionClass(A::class);
$reflection_property = $reflection->getProperty('p');
$reflection_property->setAccessible(true);
$reflection_property->setValue($a, 2);