fixing some tests

This commit is contained in:
Antonio Ramirez
2016-12-11 04:17:55 +01:00
parent d8e517a9d1
commit 0834ad6ca0
40 changed files with 1153 additions and 23 deletions

View 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
View 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;

View 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' => [],
];

View File

@ -0,0 +1,13 @@
<?php
namespace app\controllers;
use yii\web\Controller;
class SiteController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
}

View 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;

View File

@ -0,0 +1 @@
Index

12
tests/_app/yii.php Normal file
View 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);