Skip to content

Commit c447d6e

Browse files
authored
[5.x] Add entry serialization test (#11900)
1 parent c3fefc2 commit c447d6e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/Data/Entries/EntryTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,4 +2678,31 @@ public function it_clones_internal_collections()
26782678
$this->assertEquals('A', $entry->getSupplement('bar'));
26792679
$this->assertEquals('B', $clone->getSupplement('bar'));
26802680
}
2681+
2682+
#[Test]
2683+
public function entries_can_be_serialized_after_resolving_values()
2684+
{
2685+
$entry = EntryFactory::id('entry-id')
2686+
->collection('test')
2687+
->slug('entry-slug')
2688+
->create();
2689+
2690+
$customEntry = CustomEntry::fromEntry($entry);
2691+
2692+
$serialized = serialize($customEntry);
2693+
$unserialized = unserialize($serialized);
2694+
2695+
$this->assertSame('entry-slug', $unserialized->slug);
2696+
}
2697+
}
2698+
2699+
class CustomEntry extends Entry
2700+
{
2701+
public static function fromEntry(Entry $entry)
2702+
{
2703+
return (new static)
2704+
->slug($entry->slug)
2705+
->collection($entry->collection)
2706+
->data($entry->data);
2707+
}
26812708
}

0 commit comments

Comments
 (0)