diff --git a/.gitignore b/.gitignore index c337a744..bd3fea95 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ vendor .phpunit.result.cache .php_cs.cache .nova/* +.phpunit.cache diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index b62d0cbd..abae0056 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -106,19 +106,28 @@ private function publishMigrations(): void { $this->publishes($taxonomyMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_taxonomies_table.php' => database_path('migrations/2024_03_07_100000_create_taxonomies_table.php'), - __DIR__.'/../database/migrations/2024_03_07_100000_create_terms_table.php' => database_path('migrations/2024_03_07_100000_create_terms_table.php'), ], 'statamic-eloquent-taxonomy-migrations'); + $this->publishes($termMigrations = [ + __DIR__.'/../database/migrations/2024_03_07_100000_create_terms_table.php' => database_path('migrations/2024_03_07_100000_create_terms_table.php'), + ], 'statamic-eloquent-term-migrations'); + $this->publishes($globalMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_globals_table.php' => database_path('migrations/2024_03_07_100000_create_globals_table.php'), - __DIR__.'/../database/migrations/2024_03_07_100000_create_global_variables_table.php' => database_path('migrations/2024_03_07_100000_create_global_variables_table.php'), ], 'statamic-eloquent-global-migrations'); + $this->publishes($globalVariablesMigrations = [ + __DIR__.'/../database/migrations/2024_03_07_100000_create_global_variables_table.php' => database_path('migrations/2024_03_07_100000_create_global_variables_table.php'), + ], 'statamic-eloquent-global-variables-migrations'); + $this->publishes($navigationMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_navigations_table.php' => database_path('migrations/2024_03_07_100000_create_navigations_table.php'), - __DIR__.'/../database/migrations/2024_03_07_100000_create_navigation_trees_table.php' => database_path('migrations/2024_03_07_100000_create_navigation_trees_table.php'), ], 'statamic-eloquent-navigation-migrations'); + $this->publishes($navigationTreeMigrations = [ + __DIR__.'/../database/migrations/2024_03_07_100000_create_navigation_trees_table.php' => database_path('migrations/2024_03_07_100000_create_navigation_trees_table.php'), + ], 'statamic-eloquent-navigation-tree-migrations'); + $this->publishes($collectionMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_collections_table.php' => database_path('migrations/2024_03_07_100000_create_collections_table.php'), ], 'statamic-eloquent-collection-migrations'); @@ -130,11 +139,17 @@ private function publishMigrations(): void $this->publishes($formMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_forms_table.php' => database_path('migrations/2024_03_07_100000_create_forms_table.php'), - __DIR__.'/../database/migrations/2024_03_07_100000_create_form_submissions_table.php' => database_path('migrations/2024_03_07_100000_create_form_submissions_table.php'), ], 'statamic-eloquent-form-migrations'); - $this->publishes($assetMigrations = [ + $this->publishes($formSubmissionMigrations = [ + __DIR__.'/../database/migrations/2024_03_07_100000_create_form_submissions_table.php' => database_path('migrations/2024_03_07_100000_create_form_submissions_table.php'), + ], 'statamic-eloquent-form-submission-migrations'); + + $this->publishes($assetContainerMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_asset_containers_table.php' => database_path('migrations/2024_03_07_100000_create_asset_containers_table.php'), + ], 'statamic-eloquent-asset-container-migrations'); + + $this->publishes($assetMigrations = [ __DIR__.'/../database/migrations/2024_03_07_100000_create_asset_table.php' => database_path('migrations/2024_03_07_100000_create_asset_table.php'), ], 'statamic-eloquent-asset-migrations'); @@ -145,11 +160,16 @@ private function publishMigrations(): void $this->publishes( array_merge( $taxonomyMigrations, + $termMigrations, $globalMigrations, + $globalVariablesMigrations, $navigationMigrations, + $navigationTreeMigrations, $collectionMigrations, $blueprintMigrations, $formMigrations, + $formSubmissionMigrations, + $assetContainerMigrations, $assetMigrations, $revisionMigrations ), diff --git a/tests/Data/Entries/EntryQueryBuilderTest.php b/tests/Data/Entries/EntryQueryBuilderTest.php index e7221289..65b5de45 100644 --- a/tests/Data/Entries/EntryQueryBuilderTest.php +++ b/tests/Data/Entries/EntryQueryBuilderTest.php @@ -626,10 +626,10 @@ public function it_substitutes_entries_by_uri() /** @test */ public function it_substitutes_entries_by_uri_and_site() { - Site::setConfig(['sites' => [ + Site::setSites([ 'en' => ['url' => 'http://localhost/', 'locale' => 'en'], 'fr' => ['url' => 'http://localhost/fr/', 'locale' => 'fr'], - ]]); + ]); Collection::make('posts')->routes('/posts/{slug}')->sites(['en', 'fr'])->save(); EntryFactory::id('1')->slug('post-1')->collection('posts')->data(['title' => 'Post 1'])->locale('en')->create(); diff --git a/tests/Data/Globals/GlobalSetTest.php b/tests/Data/Globals/GlobalSetTest.php index 84033b66..29963a0c 100644 --- a/tests/Data/Globals/GlobalSetTest.php +++ b/tests/Data/Globals/GlobalSetTest.php @@ -11,11 +11,10 @@ class GlobalSetTest extends TestCase /** @test */ public function it_gets_file_contents_for_saving_with_a_single_site() { - Site::setConfig([ - 'default' => 'en', - 'sites' => [ - 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], - ], + config()->set('statamic.system.multisite', false); + + Site::setSites([ + 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], ]); $set = (new GlobalSet())->title('The title'); @@ -42,13 +41,12 @@ public function it_gets_file_contents_for_saving_with_a_single_site() /** @test */ public function it_gets_file_contents_for_saving_with_multiple_sites() { - Site::setConfig([ - 'default' => 'en', - 'sites' => [ - 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], - 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], - 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], - ], + config()->set('statamic.system.multisite', true); + + Site::setSites([ + 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], + 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], + 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], ]); $set = (new GlobalSet())->title('The title'); diff --git a/tests/Data/Taxonomies/TermQueryBuilderTest.php b/tests/Data/Taxonomies/TermQueryBuilderTest.php index 67907f86..61475ac7 100644 --- a/tests/Data/Taxonomies/TermQueryBuilderTest.php +++ b/tests/Data/Taxonomies/TermQueryBuilderTest.php @@ -326,10 +326,10 @@ public function it_substitutes_terms_by_uri() /** @test */ public function it_substitutes_terms_by_uri_and_site() { - Site::setConfig(['sites' => [ + Site::setSites([ 'en' => ['url' => 'http://localhost/', 'locale' => 'en'], 'fr' => ['url' => 'http://localhost/fr/', 'locale' => 'fr'], - ]]); + ]); Taxonomy::make('tags')->sites(['en', 'fr'])->save(); Term::make('tag-1')->slug('tag-1')->taxonomy('tags') diff --git a/tests/Entries/EntryTest.php b/tests/Entries/EntryTest.php index fa6f1621..cdf3c91c 100644 --- a/tests/Entries/EntryTest.php +++ b/tests/Entries/EntryTest.php @@ -162,14 +162,11 @@ public function it_propagates_entry_if_configured() /** @test */ public function it_propagates_updating_origin_data_to_descendent_models() { - Facades\Site::setConfig([ - 'default' => 'en', - 'sites' => [ - 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], - 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], - 'es' => ['name' => 'Spanish', 'locale' => 'es_ES', 'url' => 'http://test.com/es/'], - 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], - ], + Facades\Site::setSites([ + 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], + 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], + 'es' => ['name' => 'Spanish', 'locale' => 'es_ES', 'url' => 'http://test.com/es/'], + 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], ]); $blueprint = Facades\Blueprint::makeFromFields(['foo' => ['type' => 'test', 'localizable' => true]])->setHandle('test'); @@ -210,14 +207,11 @@ public function it_propagates_updating_origin_data_to_descendent_models() /** @test */ public function it_propagates_origin_date_to_descendent_models() { - Facades\Site::setConfig([ - 'default' => 'en', - 'sites' => [ - 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], - 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], - 'es' => ['name' => 'Spanish', 'locale' => 'es_ES', 'url' => 'http://test.com/es/'], - 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], - ], + Facades\Site::setSites([ + 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'], + 'fr' => ['name' => 'French', 'locale' => 'fr_FR', 'url' => 'http://fr.test.com/'], + 'es' => ['name' => 'Spanish', 'locale' => 'es_ES', 'url' => 'http://test.com/es/'], + 'de' => ['name' => 'German', 'locale' => 'de_DE', 'url' => 'http://test.com/de/'], ]); $blueprint = Facades\Blueprint::makeFromFields(['foo' => ['type' => 'test', 'localizable' => true]])->setHandle('test'); diff --git a/tests/TestCase.php b/tests/TestCase.php index e26eebd0..3bf34637 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -63,12 +63,10 @@ protected function resolveApplicationConfiguration($app) protected function getEnvironmentSetUp($app) { // We changed the default sites setup but the tests assume defaults like the following. - $app['config']->set('statamic.sites', [ - 'default' => 'en', - 'sites' => [ - 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://localhost/'], - ], + \Statamic\Facades\Site::setSites([ + 'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://localhost/'], ]); + $app['config']->set('auth.providers.users.driver', 'statamic'); $app['config']->set('statamic.stache.watcher', false); $app['config']->set('statamic.users.repository', 'file'); @@ -78,6 +76,7 @@ protected function getEnvironmentSetUp($app) ]); $app['config']->set('statamic.editions.pro', true); + $app['config']->set('statamic.system.multisite', true); $app['config']->set('cache.stores.outpost', [ 'driver' => 'file',