/**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $app->i18n->translations['extensions-manager'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages'];
     DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [DeferredQueueCompleteHandler::className(), 'handleEvent']);
     if ($app instanceof \yii\console\Application) {
         $app->controllerMap['extension'] = ExtensionController::className();
         $app->on(Application::EVENT_BEFORE_ACTION, function () {
             $module = ExtensionsManager::module();
             if ($module->autoDiscoverMigrations === true) {
                 if (isset(Yii::$app->params['yii.migrations']) === false) {
                     Yii::$app->params['yii.migrations'] = [];
                 }
                 /** @var array $extensions */
                 $extensions = $module->getExtensions();
                 foreach ($extensions as $name => $ext) {
                     if ($ext['composer_type'] === Extension::TYPE_DOTPLANT && $module->discoverDotPlantMigrations === false) {
                         continue;
                     }
                     $extData = ComposerInstalledSet::get()->getInstalled($ext['composer_name']);
                     $packageMigrations = ExtensionDataHelper::getInstalledExtraData($extData, 'migrationPath', true);
                     $packagePath = '@vendor/' . $ext['composer_name'];
                     foreach ($packageMigrations as $migrationPath) {
                         Yii::$app->params['yii.migrations'][] = "{$packagePath}/{$migrationPath}";
                     }
                 }
             }
         });
     }
 }
 /**
  * Populates Yii::$app with a new application
  * The application will be destroyed on tearDown() automatically.
  * @param array $config The application configuration, if needed
  * @param string $appClass name of the application class to create
  */
 protected function mockApplication($config = [], $appClass = '\\yii\\console\\Application')
 {
     new $appClass(ArrayHelper::merge(['id' => 'testapp', 'basePath' => __DIR__, 'vendorPath' => '../../vendor', 'controllerMap' => ['deferred' => ['class' => DeferredController::className()]], 'components' => ['mutex' => ['class' => 'yii\\mutex\\MysqlMutex', 'autoRelease' => false], 'db' => ['class' => Connection::className(), 'dsn' => 'mysql:host=localhost;dbname=yii2_deferred_tasks', 'username' => 'root', 'password' => ''], 'cache' => ['class' => 'yii\\caching\\FileCache']]], $config));
     Yii::$app->cache->flush();
     Yii::$app->getDb()->open();
     Yii::$app->runAction('migrate/down', [99999, 'interactive' => 0, 'migrationPath' => __DIR__ . '/../src/migrations/']);
     Yii::$app->runAction('migrate/up', ['interactive' => 0, 'migrationPath' => __DIR__ . '/../src/migrations/']);
 }
 /**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     if ($app instanceof \yii\console\Application) {
         // add deferred module
         $app->setModule('deferred', new DeferredTasksModule('deferred', $app));
         // this will automatically add deferred controller to console app
         $app->controllerMap['deferred'] = ['class' => DeferredController::className()];
     }
 }
 /**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     if ($app instanceof \yii\console\Application) {
         // add deferred module
         $app->setModule('deferred', new DeferredTasksModule('deferred', $app));
         // this will automatically add deferred controller to console app
         $app->controllerMap['deferred'] = ['class' => DeferredController::className()];
     }
     $app->i18n->translations['deferred-tasks'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages'];
     DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [QueueCompleteEventHandler::className(), 'handleEvent']);
 }
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     $this->mockApplication();
     $this->_controller = Yii::createObject(['class' => DeferredController::className()], [null, null]);
     parent::setUp();
 }