Skip to content
Open
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 @@ -185,7 +185,7 @@ public function collection($collection = null)

public function blueprint($blueprint = null)
{
$key = "entry-{$this->id()}-blueprint";
$key = 'entry-'.($this->id() ?? 'obj-'.spl_object_id($this)).'-blueprint';

return $this
->fluentlyGetOrSet('blueprint')
Expand Down
20 changes: 20 additions & 0 deletions tests/Data/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,25 @@ public function it_gets_the_default_collection_blueprint_when_undefined()
$this->assertNotSame($first, $second);
}

#[Test]
public function unsaved_entries_in_different_collections_do_not_share_a_blueprint()
{
BlueprintRepository::shouldReceive('in')->with('collections/blog')->andReturn(collect([
'post' => $post = (new Blueprint)->setHandle('post'),
]));
BlueprintRepository::shouldReceive('in')->with('collections/products')->andReturn(collect([
'product' => $product = (new Blueprint)->setHandle('product'),
]));
$blog = tap(Collection::make('blog'))->save();
$products = tap(Collection::make('products'))->save();

$blogEntry = (new Entry)->collection($blog);
$productEntry = (new Entry)->collection($products);

$this->assertSame($post, $blogEntry->blueprint());
$this->assertSame($product, $productEntry->blueprint());
}

#[Test]
public function the_blueprint_is_blinked_when_getting_and_flushed_when_setting()
{
Expand Down Expand Up @@ -2154,6 +2173,7 @@ public function it_respects_custom_blueprint_template_path_per_collection()
$blueprint = tap(Blueprint::make('standard_article')->setNamespace('collections.articles'))->save();

$articleEntry = Entry::make('test')->collection($articles)->blueprint($blueprint->handle());
tap(Blueprint::make('standard_article')->setNamespace('collections.pages'))->save();
$pageEntry = Entry::make('test')->collection($pages)->blueprint($blueprint->handle());

// mapped collection uses the mapped prefix instead of the collection handle
Expand Down
Loading