Helper for managing test connections
Adds test_<connection name>
aliases for all non-test connections.
Drops all tables.
Enables query logging for all database connections.
Runs callback with constraints disabled correctly per-database
Truncates all tables.
addTestAliases(): void
Adds test_<connection name>
aliases for all non-test connections.
This forces all models to use the test connection instead. For example, if a model is confused to use connection files
then it will be aliased to test_files
.
The default
connection is aliased to test
.
void
dropTables(string $connectionName, array<string>|null $tables = null): void
Drops all tables.
string
$connectionName Connection name
array<string>|null
$tables optional List of tables names or null for all.
void
enableQueryLogging(array<int, string>|null $connections = null): void
Enables query logging for all database connections.
array<int, string>|null
$connections optional Connection names or null for all.
void
runWithoutConstraints(Cake\Database\Connection $connection, Closure $callback): void
Runs callback with constraints disabled correctly per-database
Cake\Database\Connection
$connection Database connection
Closure
$callback callback
void
truncateTables(string $connectionName, array<string>|null $tables = null): void
Truncates all tables.
string
$connectionName Connection name
array<string>|null
$tables optional List of tables names or null for all.
void
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.TestSuite.ConnectionHelper.html