fixing some tests
This commit is contained in:
15
tests/_app/config/console.php
Normal file
15
tests/_app/config/console.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'id' => 'yii2-test-console',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'aliases' => [
|
||||
'@Da/User' => dirname(dirname(dirname(__DIR__))) . '/lib/User',
|
||||
'@tests' => dirname(dirname(__DIR__)),
|
||||
],
|
||||
'components' => [
|
||||
'log' => null,
|
||||
'cache' => null,
|
||||
'db' => require __DIR__ . '/db.php',
|
||||
],
|
||||
];
|
||||
15
tests/_app/config/db.php
Normal file
15
tests/_app/config/db.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$db = [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=localhost;dbname=test',
|
||||
'username' => 'root',
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
];
|
||||
|
||||
if (file_exists(__DIR__ . '/db.local.php')) {
|
||||
$db = array_merge($db, require(__DIR__ . '/db.local.php'));
|
||||
}
|
||||
|
||||
return $db;
|
||||
34
tests/_app/config/test.php
Normal file
34
tests/_app/config/test.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'id' => 'yii2-user-tests',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'language' => 'en-US',
|
||||
'aliases' => [
|
||||
'@Da/User' => dirname(dirname(dirname(__DIR__))) . '/lib/User',
|
||||
'@tests' => dirname(dirname(__DIR__)),
|
||||
'@vendor' => VENDOR_DIR,
|
||||
'@bower' => VENDOR_DIR . '/bower-asset',
|
||||
],
|
||||
'bootstrap' => ['Da\User\Bootstrap'],
|
||||
'modules' => [
|
||||
'user' => [
|
||||
'class' => 'Da\User\Module',
|
||||
'administrators' => ['user'],
|
||||
],
|
||||
],
|
||||
'components' => [
|
||||
'db' => require __DIR__ . '/db.php',
|
||||
'mailer' => [
|
||||
'useFileTransport' => true,
|
||||
],
|
||||
'urlManager' => [
|
||||
'showScriptName' => true,
|
||||
],
|
||||
'request' => [
|
||||
'cookieValidationKey' => 'test',
|
||||
'enableCsrfValidation' => false,
|
||||
],
|
||||
],
|
||||
'params' => [],
|
||||
];
|
||||
13
tests/_app/controllers/SiteController.php
Normal file
13
tests/_app/controllers/SiteController.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
}
|
||||
10
tests/_app/views/layouts/main.php
Normal file
10
tests/_app/views/layouts/main.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
if (Yii::$app->user->getIsGuest()) {
|
||||
echo \yii\helpers\Html::a('Login', ['/user/security/login']);
|
||||
echo \yii\helpers\Html::a('Registration', ['/user/registration/register']);
|
||||
} else {
|
||||
echo \yii\helpers\Html::a('Logout', ['/user/security/logout']);
|
||||
}
|
||||
|
||||
echo $content;
|
||||
1
tests/_app/views/site/index.php
Normal file
1
tests/_app/views/site/index.php
Normal file
@ -0,0 +1 @@
|
||||
Index
|
||||
12
tests/_app/yii.php
Normal file
12
tests/_app/yii.php
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/_bootstrap.php';
|
||||
|
||||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
|
||||
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
|
||||
|
||||
$config = require(__DIR__ . '/config/console.php');
|
||||
|
||||
$exitCode = (new yii\console\Application($config))->run();
|
||||
exit($exitCode);
|
||||
Reference in New Issue
Block a user