-1

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();

1 Answer 1

1

Cause

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:

  1. 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.

  1. Require Testbench again:
composer remove orchestra/testbench
composer require --dev orchestra/testbench

This time, Composer will install the latest stable version of Testbench

  1. Run your tests again — the error should disappear.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.