public static function hasHandlers($class, $name)
{
if (empty(self::$_events[$name])) {
return false;
}
if (is_object($class)) {
$class = get_class($class);
} else {
$class = ltrim($class, '\\');
}
$classes = array_merge([$class], class_parents($class, true), class_implements($class, true));
foreach ($classes as $class) {
if (!empty(self::$_events[$name][$class])) {
return true;
}
}
return false;
}
public function test_MigrationEvent() { try { $this->cleanDb(); $this->mockYiiApplication(); \Yii::$app->mycfg->system->version = null; // to trigger migration event $bootstrap = new MyLibraryBootstrap(); $bootstrap->bootstrap(\Yii::$app); $this->assertTrue(\yii\base\Event::hasHandlers(\app\components\Controller::class, \app\components\Controller::EVENT_BEFORE_ACTION), 'migration event for controller was not added'); } finally { $this->resetConnection(); } }