Hello!
I’m trying to run codeception tests via Windows command line (command codecept run), but every time take an error “Db: invalid data source name while creating PDO connection”.
I used instructions with commands like
composer global require codeception/codeception
composer require --dev yiisoft/yii2-codeception
codecept bootstrap --customize
codecept build
which generated all the files in /tests/.
Then I copied necessary models to /tests/_data with changed namespace, copied original DB and generate dump of that. What I have now:
_codeception.yml
...
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=fortime_test'
user: 'root'
password: ''
dump: tests/_data/dump.sql
unit.suite.yml
class_name: UnitTester
modules:
enabled:
- Asserts
- Db
tests/unit/config.php
<?php
return [
'id' => 'app-console',
'class' => 'yii\console\Application',
'basePath' => \Yii::getAlias('@tests'),
'runtimePath' => \Yii::getAlias('@tests/_output'),
'bootstrap' => [],
'components' => [
'db' => [
'class' => '\yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=fortime_test',
'username' => 'root',
'password' => '',
]
]
];
and one test-file in tests/unit.
But it still wrong!
And I tried to remove _config.php with DB-connection data, but command line don’t worried about that.
Maybe do you have some ideas?
If yes, thanks a lot!