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

Error when parallel testing with database driver #80

Closed
bradietilley opened this issue Jan 9, 2024 · 1 comment · Fixed by #81
Closed

Error when parallel testing with database driver #80

bradietilley opened this issue Jan 9, 2024 · 1 comment · Fixed by #81

Comments

@bradietilley
Copy link

bradietilley commented Jan 9, 2024

Pennant Version

1.5.1

Laravel Version

10.39.0

PHP Version

8.2.8

Database Driver & Version

MySQL v8.0.33 for macos 13.3 on arm64 (Homebrew)

Description

Running artisan test --parallel on any project with pennant (database driver) will fail most tests with the following error:

Error: Call to a member function prepare() on null

The database driver for pennant appears to be trying to connect to the original database parallel_testing_with_pennant instead of the tokenised databases such as parallel_testing_with_pennant_1 or parallel_testing_with_pennant_2, but I'm not sure.

Steps To Reproduce

Repo: https://github.com/bradietilley/parallel-testing-with-pennant

git clone [email protected]:bradietilley/parallel-testing-with-pennant.git
cd parallel-testing-with-pennant
composer install
cp .env.example .env
# <setup database details in .env>
artisan test --parallel

image

1) Tests\Feature\PennantTest::test_one
Error: Call to a member function prepare() on null

/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Connection.php:416
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Connection.php:809
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Connection.php:776
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2751
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2740
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3294
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2739
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/Drivers/DatabaseDriver.php:105
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/Drivers/Decorator.php:209
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/Drivers/Decorator.php:232
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:746
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/Drivers/Decorator.php:232
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/PendingScopedFeatureInteraction.php:70
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:746
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/PendingScopedFeatureInteraction.php:70
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/PendingScopedFeatureInteraction.php:96
/var/www/parallel-testing-with-pennant/vendor/laravel/pennant/src/PendingScopedFeatureInteraction.php:81
/var/www/parallel-testing-with-pennant/tests/Feature/PennantTest.php:15
/var/www/parallel-testing-with-pennant/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:176
@timacdonald
Copy link
Member

timacdonald commented Jan 9, 2024

Thanks for raising this and also for the reproduction repository ❤️

I've opened a PR to address this issue. I'll close this and we can track the PR instead: #81

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 a pull request may close this issue.

2 participants