Closed FirasSahli2010 closed 2 years ago
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.
Stacktrace would be useful too.
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'));
How is getConfig
used?
I really need that stack trace, please run your test with -vvv
parameter to get full stack trace.
Thanks a lot, I misconfigured the module
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?