Skip to content

Commit

Permalink
Save the inherited blueprint to localized entry files (#3818)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Jun 9, 2021
1 parent d3f23e0 commit cba50da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit cba50da

Please sign in to comment.