Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaLoader::loadSqlFiles() cannot find database if dropTables() is skipped #17289

Open
tigerduck42 opened this issue Sep 18, 2023 · 5 comments
Labels
Milestone

Comments

@tigerduck42
Copy link

tigerduck42 commented Sep 18, 2023

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 $sqlcan not be executed because no database is configured.

CakePHP Version

4.4.14

PHP Version

8.1.5

@markstory markstory added this to the 4.4.18 milestone Sep 19, 2023
@markstory markstory changed the title ShemaLoader::loadSqlFiles() cannot find datenbase if dopTables() is skipped ShemaLoader::loadSqlFiles() cannot find datenbase if dropTables() is skipped Sep 19, 2023
@markstory
Copy link
Member

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?

@othercorey othercorey changed the title ShemaLoader::loadSqlFiles() cannot find datenbase if dropTables() is skipped SchemaLoader::loadSqlFiles() cannot find database if dropTables() is skipped Sep 19, 2023
@markstory markstory modified the milestones: 4.4.18, 4.4.19 Sep 28, 2023
@othercorey
Copy link
Member

@tigerduck42 Can you give us more information?

@markstory markstory modified the milestones: 4.4.19, 4.5.1 Oct 15, 2023
@tigerduck42
Copy link
Author

tigerduck42 commented Oct 18, 2023

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 markstory modified the milestones: 4.5.1, 4.5.2 Nov 15, 2023
@markstory markstory modified the milestones: 4.5.2, 4.5.3 Dec 15, 2023
@othercorey
Copy link
Member

@markstory Do we want to support this?

@markstory
Copy link
Member

I can take another look at this. We shouldn't have errors like this being emitted from valid parameter sets.

@markstory markstory modified the milestones: 4.5.3, 4.5.4 Jan 20, 2024
@markstory markstory modified the milestones: 4.5.4, 4.5.5 Mar 6, 2024
@markstory markstory modified the milestones: 4.5.5, 4.5.6 May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants