Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save the inherited blueprint to localized entry files #3818

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function fileData()
'id' => $this->id(),
'origin' => optional($this->origin())->id(),
'published' => $this->published === false ? false : null,
'blueprint' => $this->blueprint ?? $this->collection()->entryBlueprint()->handle(),
'blueprint' => $this->blueprint()->handle(),
]);

$data = $this->data()->all();
Expand Down
24 changes: 24 additions & 0 deletions tests/Data/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ public function it_gets_file_contents_for_saving_a_localized_entry()
$originEntry->shouldReceive('id')->andReturn('123');

Facades\Entry::shouldReceive('find')->with('123')->andReturn($originEntry);
$originEntry->shouldReceive('value')->with('blueprint')->andReturn('test');

$entry = (new Entry)
->collection('test')
Expand Down Expand Up @@ -856,6 +857,29 @@ public function the_explicit_blueprint_is_added_to_the_file_contents()
$this->assertEquals('another', $entry->fileData()['blueprint']);
}

/** @test */
public function the_inherited_blueprint_is_added_to_the_localized_file_contents()
{
BlueprintRepository::shouldReceive('in')->with('collections/test')->andReturn(collect([
'default' => (new Blueprint)->setHandle('default'),
'another' => (new Blueprint)->setHandle('another'),
]));
$collection = tap(Collection::make('test'))->save();
$this->assertEquals('default', $collection->entryBlueprint()->handle());

$originEntry = $this->mock(Entry::class);
$originEntry->shouldReceive('id')->andReturn('123');

Facades\Entry::shouldReceive('find')->with('123')->andReturn($originEntry);
$originEntry->shouldReceive('value')->with('blueprint')->andReturn('another');

$entry = (new Entry)
->collection('test')
->origin('123'); // do not set blueprint.

$this->assertEquals('another', $entry->fileData()['blueprint']);
}

/** @test */
public function it_gets_and_sets_the_template()
{
Expand Down