You can set a properties when creating a mock using setProperty
:
$mock = $this->niceMock('MyClass')
->setProperty('foo', 'bar')
->get();
$this->foo; // bar
Setting multiple properties can be done with setProperties
:
$mock = $this->niceMock('MyClass')
->setProperties([
'foo' => 'bar',
'bar' => 'baz',
])
->get();
$this->bar; // baz
When using setProperties
it will add on the provided properties, not replace any previously set ones.
Note: The property or properties are set after all other aspects of the mock have been setup. This means properties that may be set as part of a partial mock will be overridden by the properties provided.
This feature was introduced in Multiverse (Release v1.7.0).