From a1905dff74ade9d689f068a7a8e90eeea8a49802 Mon Sep 17 00:00:00 2001 From: Maarten Buis Date: Fri, 31 Oct 2025 13:24:48 +0100 Subject: [PATCH] Added `setSnapshotId` method to easily override the snapshot identifier --- src/Concerns/SnapshotIdAware.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Concerns/SnapshotIdAware.php b/src/Concerns/SnapshotIdAware.php index 34f40c6..ee9bcb6 100644 --- a/src/Concerns/SnapshotIdAware.php +++ b/src/Concerns/SnapshotIdAware.php @@ -6,14 +6,25 @@ trait SnapshotIdAware { + private ?string $snapshotId = null; + /* * Determines the snapshot's id. By default, the test case's class and * method names are used. */ protected function getSnapshotId(): string { + if ($this->snapshotId !== null) { + return $this->snapshotId; + } + return (new ReflectionClass($this))->getShortName().'__'. $this->nameWithDataSet().'__'. $this->snapshotIncrementor; } + + protected function setSnapshotId(string $snapshotId): void + { + $this->snapshotId = $snapshotId; + } }