public function assertEvents(array $expected, $actual = null)
{
if ($actual === null) {
$actual = $this->_subject;
}
if ($actual instanceof Event) {
$actual = $actual->subject->getEvents();
}
if ($actual instanceof Subject) {
$actual = $actual->getEvents();
}
if (empty($actual)) {
throw new Exception('assertEvents: Expected actual to be not-empty');
}
if (!is_array($actual)) {
throw new Exception('assertEvents: Expected actual to be an array');
}
foreach ($expected as &$key) {
if (false !== strpos($key, '.')) {
continue;
}
$key = 'Crud.' . $key;
}
$this->assertEquals($expected, $actual, 'Not all expected events was fired');
}