Skip to content

Commit a1905df

Browse files
authored
Added setSnapshotId method to easily override the snapshot identifier
1 parent 3c28c4f commit a1905df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Concerns/SnapshotIdAware.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66

77
trait SnapshotIdAware
88
{
9+
private ?string $snapshotId = null;
10+
911
/*
1012
* Determines the snapshot's id. By default, the test case's class and
1113
* method names are used.
1214
*/
1315
protected function getSnapshotId(): string
1416
{
17+
if ($this->snapshotId !== null) {
18+
return $this->snapshotId;
19+
}
20+
1521
return (new ReflectionClass($this))->getShortName().'__'.
1622
$this->nameWithDataSet().'__'.
1723
$this->snapshotIncrementor;
1824
}
25+
26+
protected function setSnapshotId(string $snapshotId): void
27+
{
28+
$this->snapshotId = $snapshotId;
29+
}
1930
}

0 commit comments

Comments
 (0)