From 3c23d60d5d4b74fbced94f19fb41cf1d8912f82c Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 10 Apr 2024 16:13:04 +0100 Subject: [PATCH] Make drivers opt-in, rather than opt-out (#268) * Eloquent driver should be opt-in, not opt-out * Swap all drivers to `eloquent` in our `TestCase` --- config/eloquent-driver.php | 30 +++++++++++++++--------------- tests/TestCase.php | 4 ++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/config/eloquent-driver.php b/config/eloquent-driver.php index 3aa3ab41..b795c51b 100644 --- a/config/eloquent-driver.php +++ b/config/eloquent-driver.php @@ -6,84 +6,84 @@ 'table_prefix' => env('STATAMIC_ELOQUENT_PREFIX', ''), 'asset_containers' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Assets\AssetContainerModel::class, ], 'assets' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Assets\AssetModel::class, 'asset' => \Statamic\Eloquent\Assets\Asset::class, ], 'blueprints' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'blueprint_model' => \Statamic\Eloquent\Fields\BlueprintModel::class, 'fieldset_model' => \Statamic\Eloquent\Fields\FieldsetModel::class, ], 'collections' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Collections\CollectionModel::class, 'update_entry_order_queue' => 'default', 'update_entry_order_connection' => 'default', ], 'collection_trees' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Structures\TreeModel::class, 'tree' => \Statamic\Eloquent\Structures\CollectionTree::class, ], 'entries' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Entries\EntryModel::class, 'entry' => \Statamic\Eloquent\Entries\Entry::class, ], 'forms' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Forms\FormModel::class, ], 'form_submissions' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Forms\SubmissionModel::class, ], 'global_sets' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Globals\GlobalSetModel::class, ], 'global_set_variables' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Globals\VariablesModel::class, ], 'navigations' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Structures\NavModel::class, ], 'navigation_trees' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Structures\TreeModel::class, 'tree' => \Statamic\Eloquent\Structures\NavTree::class, ], 'revisions' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Revisions\RevisionModel::class, ], 'taxonomies' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Taxonomies\TaxonomyModel::class, ], 'terms' => [ - 'driver' => 'eloquent', + 'driver' => 'file', 'model' => \Statamic\Eloquent\Taxonomies\TermModel::class, ], ]; diff --git a/tests/TestCase.php b/tests/TestCase.php index 2b3a7d17..cf76c0d2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,6 +24,10 @@ protected function resolveApplicationConfiguration($app) parent::resolveApplicationConfiguration($app); $app['config']->set('statamic.eloquent-driver', require (__DIR__.'/../config/eloquent-driver.php')); + + collect(config('statamic.eloquent-driver')) + ->filter(fn ($config) => isset($config['driver'])) + ->each(fn ($config, $key) => $app['config']->set("statamic.eloquent-driver.{$key}.driver", 'eloquent')); } protected function getEnvironmentSetUp($app)