This is a powerful, time-saver when understood.
The keys of this array correspond to the class properties.
Each value relates to the passed argument to your classe's _construct method.
If an argument is an instance of a class, then do this:
'classArgumentsMap' => [
'core' => '\Drupal\gop\Core',
],
$this->obj->core will become a fully-mocked instance of \Drupal\gop\Core. All methods will require mocking before they may be called.
You can indicate a class instance should be a partial mock by doing like so:
'classArgumentsMap' => [
'core' => ['\Drupal\gop\Core', self::PARTIAL_MOCK]
],
$this->obj->core will become a partially-mocked instance of \Drupal\gop\Core. Method calls will return the actual methods unless you override them.
_construct calls a method on an argIn order to accommodate for constructors that call a method on thier arguments, you will need to set up classArgumentsMap using a callback, wherein you create the mock and set it's expectations.
If this was the constructor of your class being tested...
public function __construct(CacheBackendInterface $cache_backend) {
$this->cache = $cache_backend->get('data');
}
... you would need to set up your test like this:
'classArgumentsMap' => [
'cache_backend' => function () {
$mock = \Mockery::mock('\Drupal\Core\Cache\CacheBackendInterface');
$mock->shouldReceive('get')->andReturn('15');
return $mock;
},
],
If a passed argument is a value, do like this:
'classArgumentsMap' => [
'age' => [64, self::VALUE],
'name' => ['Aaron', self::VALUE],
],
$this->obj->age will become an integer value of 64.
$this->obj->name will become a string value of Aaron.