I get error message: codecept [PHPUnit\Framework\Error\Notice] Undefined index: default
FirasSahli2010 opened this issue · comments
Firas Sahli commented
Hello everyone,
When running my unit test I get an error message saying
[PHPUnit\Framework\Error\Notice] Undefined index: default
Is there a solution for this error?
Gintautas Miselis commented
This is probably configuration error.
Please show the part of codeception.yaml or unit.suite.yaml containing Db configuration.
P.S. Unit tests are not supposed to use database.
Gintautas Miselis commented
Stacktrace would be useful too.
Firas Sahli commented
I have the following
enabled:
- Db:
dns: 'mysql:host=localhost;dbname=test'
user: 'user'
password: ''
dump: 'tests/_data/database/empty_db.sql'
populate: true
cleanup: true
populator: 'mysql -u $user -h $host $dbname < $dump'
skip_cleanup_if_failed: false,
initial_queries:
- 'CREATE DATABASE IF NOT EXISTS temp_db;'
- 'USE temp_db;'
- 'SET NAMES utf8;'
And during the test I do
public function getConfig(): array
{
return [
'dsn' => 'mysql:host=localhost;dbname=test',
'user' => 'root',
'password' => '',
'dump' => 'tests/_data/database/empty_db.sql',
'populate' => true,
'cleanup' => true,
'populator' => null,
'skip_cleanup_if_failed' => false,
'reconnect' => true,
'initial_queries'=> 'CREATE DATABASE IF NOT EXISTS test; USE test; SET NAMES utf8;'
];
}
I got the error when I do
$this->module->haveInDatabase('logbook', array('fsahli', '2022-06-21 17:19:13', 'Test note asasas 2010', 'Something'));
Gintautas Miselis commented
How is getConfig
used?
I really need that stack trace, please run your test with -vvv
parameter to get full stack trace.
Firas Sahli commented
Thanks a lot, I misconfigured the module