admin管理员组文章数量:1402315
Problem
While running tests using PHPUnit and Orchestra Testbench, I encountered the following error:
ErrorException: Undefined variable $original at
/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3362
Context
I was developing a Laravel package, and that error appeared when tried to run a test that started by running migrations:
$this->artisan('migrate')->run();
Problem
While running tests using PHPUnit and Orchestra Testbench, I encountered the following error:
ErrorException: Undefined variable $original at
/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3362
Context
I was developing a Laravel package, and that error appeared when tried to run a test that started by running migrations:
$this->artisan('migrate')->run();
Share
Improve this question
asked Mar 22 at 22:00
sergio0983sergio0983
1,2968 silver badges19 bronze badges
1 Answer
Reset to default 1Cause
The root of the problem is a bug that only exists in the development branch of Laravel 13.x (dev-master or 13.x-dev), which is not yet released at the time of writing.
The reason why Laravel 13 was installed is because:
Testbench 11.x-dev requires laravel/framework:^13.0
My composer.json had "minimum-stability": "dev" without "prefer-stable": true
So when I ran composer require --dev orchestra/testbench, Composer pulled in the latest dev versions of both Testbench and Laravel
Solution
To avoid this kind of issue in your package development environment:
- Update your composer.json to include:
"prefer-stable": true,
"minimum-stability": "dev"
This ensures that only stable versions of packages are selected unless absolutely necessary.
- Require Testbench again:
composer remove orchestra/testbench
composer require --dev orchestra/testbench
This time, Composer will install the latest stable version of Testbench
- Run your tests again — the error should disappear.
本文标签: laravelErrorException Undefined variable original when running a testStack Overflow
版权声明:本文标题:laravel - ErrorException: Undefined variable $original when running a test - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744302403a2599643.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论