To ease with unit testing of Crud Listeners and Crud Actions, it’s recommended to use the proxy methods found in [CrudBaseObject]({{site.url}}/api/develop/class-CrudBaseObject.html).
These methods are much easier to mock than the full CrudComponent object.
They also allow you to just mock the methods you need for your specific test, rather than the big dependency nightmare the CrudComponent can be in some cases.<br />
These methods are available in all CrudAction and CrudListener objects.
Trigger a Crud Event
$this->_trigger('beforeSave')
$this->_trigger('beforeSave', ['data' => 'keys'])
$this->_trigger('beforeSave', $this->_subject(['data' => 'keys']))
Create a Crud Subject - used in $this->_trigger
$this->_subject()
$this->_subject(['data' => 'keys'])