Open tigerduck42 opened 1 year ago
How can someone reproduce the problem you're having? The default value of dropTables
parameter is true
, so wouldn't this method not work with the default arguments?
@tigerduck42 Can you give us more information?
I have the following lines in my bootstrap.php
to skip dropTable()
.
// Load one or more SQL files.
(new SchemaLoader())->loadSqlFiles(['tests/schema-structure.sql'], 'test', false);
In tests/schema-structure.sql
I will drop and recreate the whole database.
and will get the following error
vendor/bin/phpunit --testsuite price-control2
PHPUnit 9.6.9 by Sebastian Bergmann and contributors.
Error in bootstrap script: Cake\Database\Exception\MissingConnectionException:
Connection to Mysql could not be established: Unknown
#0 /var/www/html/vendor/cakephp/cakephp/src/TestSuite/Fixture/SchemaLoader.php(91): Cake\Database\Driver->getConnection()
#1 /var/www/html/tests/bootstrap.php(69): Cake\TestSuite\Fixture\SchemaLoader->loadSqlFiles()
#2 /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once('...')
#3 /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
#4 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(565): PHPUnit\Util\FileLoader::checkAndLoad()
#5 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(345): PHPUnit\TextUI\Command->handleBootstrap()
#6 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(112): PHPUnit\TextUI\Command->handleArguments()
#7 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run()
#8 /var/www/html/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#9 /var/www/html/vendor/bin/phpunit(120): include('...')
#10 {main}
@markstory Do we want to support this?
I can take another look at this. We shouldn't have errors like this being emitted from valid parameter sets.
Description
https://github.com/cakephp/cakephp/blob/4.x/src/TestSuite/Fixture/SchemaLoader.php#L71-L87
If
dropTables()
is by passed via$dropTables = false
(line 71) the$driver->connection = null
(Line 68) and$sql
can not be executed because no database is configured.CakePHP Version
4.4.14
PHP Version
8.1.5