Skip to content

Commit 267f986

Browse files
Stephan Wentzpl-github
authored andcommitted
fix: Add support for phpunit10
1 parent d0b1a4d commit 267f986

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Snapshot/SnapshotTrait.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use function getenv;
1414
use function is_string;
1515
use function mb_strtolower;
16+
use function method_exists;
1617
use function rtrim;
1718
use function Safe\array_walk_recursive;
1819
use function Safe\json_decode;
@@ -215,15 +216,25 @@ private function snapshotName(string $postfix): string
215216
$class = preg_replace('/(.)([[:upper:]])/u', '\1_\2', $class);
216217
$class = mb_strtolower($class);
217218

218-
$method = $this->getName(false);
219+
if (method_exists($this, 'name')) {
220+
$method = $this->name();
221+
} else {
222+
$method = $this->getName(false);
223+
}
224+
219225
if (strpos($method, 'test') === 0) {
220226
$method = substr($method, strlen('test'));
221227
}
222228

223229
$method = preg_replace('/(.)([[:upper:]])/u', '\1_\2', $method);
224230
$method = mb_strtolower($method);
225231

226-
$dataset = mb_strtolower($this->getDataSetAsString(false));
232+
if (method_exists($this, 'dataSetAsString')) {
233+
$dataset = mb_strtolower($this->dataSetAsString());
234+
} else {
235+
$dataset = mb_strtolower($this->getDataSetAsString(false));
236+
}
237+
227238
$matches = [];
228239
preg_match('/"([^"]+)"/', $dataset, $matches);
229240

0 commit comments

Comments
 (0)