Пример #1
0
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     new \yii\web\Application(['id' => 'unit', 'basePath' => __DIR__, 'bootstrap' => ['log', 'multilingual'], 'controllerNamespace' => 'DevGroup\\Multilingual\\tests\\controllers', 'components' => ['log' => ['traceLevel' => 10, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['info']]]], 'request' => ['cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq', 'scriptFile' => __DIR__ . '/index.php', 'scriptUrl' => '/index.php'], 'cache' => ['class' => '\\yii\\caching\\DummyCache'], 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className()], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'Russia', 'iso' => 'ru']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data']]]);
     try {
         Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => 'mysql:host=localhost;dbname=multilingual.dev', 'username' => 'root', 'password' => '7896321']);
         Yii::$app->getDb()->open();
         $lines = explode(';', file_get_contents(__DIR__ . '/migrations/mysql.sql'));
         foreach ($lines as $line) {
             if (trim($line) !== '') {
                 Yii::$app->getDb()->pdo->exec($line);
             }
         }
     } catch (\Exception $e) {
         Yii::$app->clear('db');
     }
     if (Yii::$app->get('db', false) === null) {
         $this->markTestSkipped();
     } else {
         parent::setUp();
     }
 }
<?php

$params = (require __DIR__ . '/params.php');
$config = ['id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'multilingual'], 'components' => ['request' => ['cookieValidationKey' => '19wRK6yuUnGqL-dtBRZpye2Txxchj61J'], 'cache' => ['class' => 'yii\\caching\\FileCache', 'as lazy' => ['class' => 'DevGroup\\TagDependencyHelper\\LazyCache']], 'user' => ['identityClass' => 'app\\models\\User', 'enableAutoLogin' => true], 'errorHandler' => ['errorAction' => 'site/error'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => require __DIR__ . '/db.php', 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className(), 'excludeRoutes' => ['newsletter/index', 'newsletter/test'], 'rules' => ['' => 'post/index']], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'England', 'iso' => 'en']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data'], 'i18n' => ['translations' => ['admin' => ['class' => 'yii\\i18n\\PhpMessageSource'], 'yii2tech-admin' => ['class' => 'yii\\i18n\\PhpMessageSource']]], 'assetManager' => ['bundles' => ['yii\\web\\JqueryAsset' => false]]], 'modules' => ['dynagrid' => ['class' => '\\kartik\\dynagrid\\Module', 'dynaGridOptions' => ['gridOptions' => ['export' => false]]], 'gridview' => ['class' => '\\kartik\\grid\\Module']], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module', 'allowedIPs' => ['192.168.33.1', '127.0.0.1', '::1']];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module', 'allowedIPs' => ['192.168.33.1', '127.0.0.1', '::1']];
}
return $config;
<?php

Yii::setAlias('@tests', dirname(__DIR__) . '/tests');
$params = (require __DIR__ . '/params.php');
$db = (require __DIR__ . '/db.php');
$config = ['id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\\commands', 'controllerMap' => ['deferred' => ['class' => 'DevGroup\\DeferredTasks\\commands\\DeferredController']], 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'log' => ['targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => $db, 'mutex' => ['class' => 'yii\\mutex\\MysqlMutex', 'autoRelease' => false], 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className(), 'excludeRoutes' => ['newsletter/index', 'newsletter/test'], 'rules' => ['' => 'post/index'], 'scriptUrl' => '', 'baseUrl' => '', 'forceScheme' => 'http', 'forcePort' => 80, 'hostInfo' => 'http://demo.yii2-multilingual.dev'], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'Russia', 'iso' => 'ru']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'transport' => ['class' => 'Swift_SmtpTransport', 'host' => 'smtp.yandex.ru', 'port' => 465, 'encryption' => 'ssl', 'username' => '*****@*****.**', 'password' => 'z6jNK3MdjfJ49g6rJ']]], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;