Open duncanmcclean opened 2 hours ago
As a workaround for the time being, I've added this to my TestCase
(I know the command name changed in Laravel 11, but I'm still supporting Laravel 10 in my package):
protected function defineDatabaseMigrations()
{
+ artisan($this, 'queue:batches-table');
artisan($this, 'migrate', ['--database' => 'testing']);
$this->beforeApplicationDestroyed(
fn () => artisan($this, 'migrate:rollback', ['--database' => 'testing'])
);
}
Could this be something to do with the fact the jobs migration now ships with new Laravel 11 apps, where it didn't previously? 🤔
Sorry, the name should have been queue
and not job
: https://github.com/orchestral/testbench-core/tree/7.x/laravel/migrations
Just updated the doc as well: https://github.com/orchestral/toolkit-docs/commit/7836c8a753deb50d1b74b7f0ba6157e328374a9f
thanks for the report
Thanks for the quick response!
Changing it to queue
fixes my Laravel 10 tests 🎉.
However, now I'm running into a new issue with my Laravel 11 tests where it'll publish the migration to the vendor/orchestra/testbench-core/laravel/database/migrations
directory, but the job_batches
table doesn't exist.
Then, if I re-run my test suite again, the table will be created fine. 🤔
For context, we're using this version constraint in our package:
"orchestra/testbench": "^8.0 || ^9.0.2",
When testing Laravel 10, it uses ^8.0
and when testing Laravel 11, it'll use ^9.0.2
.
I will need to debug your package directly to understand what's going on. WithMigration
doesn't publish any migration to database/migrations
but instead load migrations from migrations
path which mimic publishing migrations via available artisan commands.
Description:
In my package, I'm using Laravel's job batches feature to keep track of jobs relating to a specific import.
Since the job batches feature requires its own database table, I've uncommented the in-memory SQLite database in my
phpunit.xml
file and added theDatabaseMigrations
trait to the test which calls theBus::batch()
code.However, since Testbench doesn't ship with the queue migrations out-of-the-box, I reviewed the docs and tried to use the
WithMigration
attribute to load them, like this:However, that gives me this error:
I did some digging and it's trying to load/publish the migrations from this directory:
"/path/to/my/package/vendor/orchestra/testbench-core/laravel/migrations/jobs
However, that directory doesn't exist. Directories only exist for
notifications
andqueue
(but queue is essentially empty).I assume it should be loading/publishing the
0001_01_01_000002_testbench_create_jobs_table
migration in the parent directory?I'm happy to contribute a fix, if it'd be helpful.
Steps To Reproduce:
WithMigration
attribute to yourTestCase
class, like so:DatabaseMigrations
trait to one of your tests, like so: