-
I'm using Github actions workflow to run tests for both Laravel package which is addon for Orchid. Laravel 10 tests are passed but every 11 is failed with
I saw #247 with exact same error but I first of all it's 5 years old and second - I didn't quite understand what solution was taken at the end Relevant files content ( // tests/TestCase.php
<?php
namespace Tests;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as BaseTestCase;
use Orchid\Attachment\Models\Attachment as OrchidAttachment;
use Orchid\Platform\Dashboard;
use Tests\Models\Attachment;
use Illuminate\Contracts\Config\Repository;
use function Orchestra\Testbench\workbench_path;
abstract class TestCase extends BaseTestCase
{
use WithWorkbench, InteractsWithViews, RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Factory::guessFactoryNamesUsing(function ($factory) {
$factoryBasename = class_basename($factory);
return "Workbench\\Database\Factories\\$factoryBasename".'Factory';
});
// Use our test mockup model instead
Dashboard::useModel(OrchidAttachment::class, Attachment::class);
}
protected function defineEnvironment($app)
{
tap($app['config'], function (Repository $config) {
$config->set('database.default', 'testbench');
$config->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
});
}
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations();
$this->loadMigrationsFrom(workbench_path('database/migrations'));
$this->artisan('orchid:install'); // installs migrations required for Orchid admin panel
}
} // testbench.yaml
providers:
- Orchid\Platform\Providers\FoundationServiceProvider
- Czernika\OrchidImages\OrchidImagesServiceProvider
workbench:
install: true
discovers:
web: true
api: false
commands: false
components: false
views: false
config: true
build:
- asset-publish
- create-sqlite-db
- migrate:refresh
- orchid:install
assets:
- orchid-assets
sync: [] Custom migrations I use within workbench dir is for testing relations purposes only (not a part of a package) Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('thumb_url')->nullable();
$table->unsignedInteger('thumb_id') // to be compatible with Orchid it needs to be INTEGER type
->nullable();
$table->foreign('thumb_id')
->references('id')
->on('attachments');
}); Github workflow file is pretty basic matrix for Laravel 10/11 and PHP 8.1/8.2/8.3 Edit: for Laravel 10 test case I'm using Testbench v8 and v9 for Laravel 11 matrix:
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
exclude:
- laravel: 11.*
php: 8.1 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Had to remove |
Beta Was this translation helpful? Give feedback.
Had to remove
$this->loadLaravelMigrations();
line asorchid:install
command runsmigrate
command