A
A
Anton2016-08-29 18:01:45
Yii
Anton, 2016-08-29 18:01:45

How to configure _bootstrap for phpunit?

Hello. I can't run unit tests,
it gives me this:

<pre>PHP Fatal Error &#039;yii\base\ErrorException&#039; with message &#039;Clas

in F:\Open-server\OpenServer\domains\job.ua\tests\unit\FirstTest.php:13

Stack trace:
#0 [internal function]: yii\base\ErrorHandler-&gt;handleFatalError()
#1 {main}</pre>

Please tell me what is the problem with
_bootrap.php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
Yii::setAlias('@tests', dirname(__DIR__) . '/tests');

$config = $config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../common/config/main.php'),
    require(__DIR__ . '/../common/config/main-local.php'),
    require(__DIR__ . '/../console/config/main.php'),
    require(__DIR__ . '/../console/config/main-local.php'),
    require (__DIR__. '/config/config.php')
);

$application = new yii\web\Application($config);

My config.php
<?php
return [
    'language' => 'en-US',
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=jobtest',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
    ],
];

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question