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

[10.x] Fix $exceptTables to allow an array of table names #47477

Merged
merged 2 commits into from
Jun 18, 2023

Conversation

cwilby
Copy link
Contributor

@cwilby cwilby commented Jun 18, 2023

The current implementation of Database Truncation in Laravel has a bug where it requires table names to be grouped by connection name, to ensure that specific tables are not truncated between tests.

An example is shown below, and the current code is here.

abstract class DuskTestCase extends BaseTestCase
{
    use CreatesApplication;
    use DatabaseTruncation;

    protected $connectionsToTruncate = ['mysql_testing'];
    protected $seeder = 'DatabaseSeeder';
    protected $exceptTables = [
        'mysql_testing' => [
            'table1',
            'table2'
        ]
    ];
}

According to the documentation, it should be possible for this array to contain table names, as follows:

abstract class DuskTestCase extends BaseTestCase
{
    use CreatesApplication;
    use DatabaseTruncation;

    protected $connectionsToTruncate = ['mysql_testing'];
    protected $seeder = 'DatabaseSeeder';
    protected $exceptTables = [
        'table1',
        'table2'
    ];
}

This PR changes the DatabaseTruncation trait to allow $exceptTables to be an array of table names.

…exceptTables` if a connection name is not found.
@cwilby cwilby changed the title [10.x] Allow $exceptTables to be defined as an array of table names [10.x] Fix $exceptTables to allow an array of table names Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants