-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export-sites
command: Prevent lang
and attributes
being exporte…
…d with empty values (#349) * Add test to confirm site exporter works * Add failing test * Filter out empty values from site config * Simplify. * Fix styling --------- Co-authored-by: duncanmcclean <[email protected]>
- Loading branch information
1 parent
38371ab
commit 8111023
Showing
2 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Commands; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Statamic\Eloquent\Sites\SiteModel; | ||
use Statamic\Sites\Sites; | ||
use Tests\TestCase; | ||
|
||
class ExportSitesTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
#[Test] | ||
public function it_exports_sites() | ||
{ | ||
SiteModel::create(['handle' => 'en', 'name' => 'English', 'locale' => 'en_US', 'lang' => '', 'url' => 'http://test.com/', 'attributes' => []]); | ||
SiteModel::create(['handle' => 'fr', 'name' => 'French', 'locale' => 'fr_FR', 'lang' => '', 'url' => 'http://fr.test.com/', 'attributes' => []]); | ||
SiteModel::create(['handle' => 'es', 'name' => 'Spanish', 'locale' => 'es_ES', 'lang' => '', 'url' => 'http://test.com/es/', 'attributes' => ['foo' => 'bar']]); | ||
SiteModel::create(['handle' => 'de', 'name' => 'German', 'locale' => 'de_DE', 'lang' => 'de', 'url' => 'http://test.com/de/', 'attributes' => []]); | ||
|
||
$this->artisan('statamic:eloquent:export-sites') | ||
->expectsOutputToContain('Sites exported') | ||
->assertExitCode(0); | ||
|
||
$this->assertEquals([ | ||
'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/', | ||
'attributes' => ['foo' => 'bar'], | ||
], | ||
'de' => [ | ||
'name' => 'German', | ||
'lang' => 'de', | ||
'locale' => 'de_DE', | ||
'url' => 'http://test.com/de/', | ||
], | ||
], (new Sites)->config()); | ||
} | ||
} |