Skip to content

Commit

Permalink
Merge branch 'statamic-5' into fix/add-arguments-to-import-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed May 2, 2024
2 parents ca48296 + c341573 commit f1b580a
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ php please install:eloquent-driver

The command will install the `statamic/eloquent-driver` package, publish the config file, then prompt you to select which repositories you wish to move to the database. The command will then publish the relevant migrations and run `php artisan migrate` behind the scenes.

The command will also give you the opportunity to inidicate whether you'd like existing data to be imported.
The command will also give you the opportunity to indicate whether you'd like existing data to be imported.

### Importing flat-file content

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require": {
"php": "^8.1",
"statamic/cms": "dev-master"
"statamic/cms": "v5.0.0-alpha.6"
},
"require-dev": {
"doctrine/dbal": "^3.3",
Expand Down
10 changes: 10 additions & 0 deletions src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Statamic\Eloquent\Assets;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Statamic\Assets\Asset as FileAsset;
use Statamic\Assets\AssetUploader as Uploader;
use Statamic\Contracts\Assets\Asset as AssetContract;
Expand Down Expand Up @@ -223,4 +224,13 @@ public function getCurrentDirtyStateAttributes(): array
'data' => $this->data()->toArray(),
]);
}

private function clearCaches()
{
$this->meta = null;

Blink::forget("eloquent-asset-{$this->id()}");
Blink::forget($this->metaCacheKey());
Cache::forget($this->metaCacheKey());
}
}
3 changes: 1 addition & 2 deletions tests/Data/Entries/EntryQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Statamic\Facades\Blueprint;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;
use Statamic\Facades\Site;
use Tests\TestCase;

class EntryQueryBuilderTest extends TestCase
Expand Down Expand Up @@ -628,7 +627,7 @@ public function it_substitutes_entries_by_uri()
/** @test */
public function it_substitutes_entries_by_uri_and_site()
{
Site::setSites([
$this->setSites([
'en' => ['url' => 'http://localhost/', 'locale' => 'en'],
'fr' => ['url' => 'http://localhost/fr/', 'locale' => 'fr'],
]);
Expand Down
5 changes: 2 additions & 3 deletions tests/Data/Globals/GlobalSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tests\Data\Globals;

use Statamic\Eloquent\Globals\GlobalSet;
use Statamic\Facades\Site;
use Tests\TestCase;

class GlobalSetTest extends TestCase
Expand All @@ -13,7 +12,7 @@ public function it_gets_file_contents_for_saving_with_a_single_site()
{
config()->set('statamic.system.multisite', false);

Site::setSites([
$this->setSites([
'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://test.com/'],
]);

Expand Down Expand Up @@ -43,7 +42,7 @@ public function it_gets_file_contents_for_saving_with_multiple_sites()
{
config()->set('statamic.system.multisite', true);

Site::setSites([
$this->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/'],
Expand Down
3 changes: 1 addition & 2 deletions tests/Data/Taxonomies/TermQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Facades\Tests\Factories\EntryFactory;
use Statamic\Facades\Blueprint;
use Statamic\Facades\Collection;
use Statamic\Facades\Site;
use Statamic\Facades\Taxonomy;
use Statamic\Facades\Term;
use Statamic\Taxonomies\LocalizedTerm;
Expand Down Expand Up @@ -326,7 +325,7 @@ public function it_substitutes_terms_by_uri()
/** @test */
public function it_substitutes_terms_by_uri_and_site()
{
Site::setSites([
$this->setSites([
'en' => ['url' => 'http://localhost/', 'locale' => 'en'],
'fr' => ['url' => 'http://localhost/fr/', 'locale' => 'fr'],
]);
Expand Down
17 changes: 7 additions & 10 deletions tests/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ public function it_defers_to_the_live_computed_value_instead_of_the_stored_value
/** @test */
public function it_propagates_entry_if_configured()
{
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/'],
],
$this->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/'],
]);

$collection = (new Collection)
Expand All @@ -161,7 +158,7 @@ public function it_propagates_entry_if_configured()
/** @test */
public function it_propagates_updating_origin_data_to_descendent_models()
{
Facades\Site::setSites([
$this->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/'],
Expand Down Expand Up @@ -206,7 +203,7 @@ public function it_propagates_updating_origin_data_to_descendent_models()
/** @test */
public function it_propagates_origin_date_to_descendent_models()
{
Facades\Site::setSites([
$this->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/'],
Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ 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',
Expand Down Expand Up @@ -105,4 +104,11 @@ protected function defineDatabaseMigrations()
? $this->loadMigrationsFrom(__DIR__.'/../database/migrations/entries/2024_03_07_100000_create_entries_table_with_string_ids.php')
: $this->loadMigrationsFrom(__DIR__.'/../database/migrations/entries/2024_03_07_100000_create_entries_table.php');
}

protected function setSites($sites)
{
Site::setSites($sites);

config()->set('statamic.system.multisite', Site::hasMultiple());
}
}

0 comments on commit f1b580a

Please sign in to comment.