mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Also handle multiple descriptions within whole dataset
This commit is contained in:
@ -80,25 +80,24 @@ final class Datasets
|
||||
foreach ($data as $values) {
|
||||
$values = is_array($values) ? $values : [$values];
|
||||
|
||||
$dataSetDescriptions[] = self::getDataSetDescription($values);
|
||||
$dataSetDescriptions[] = $description . self::getDataSetDescription($values);
|
||||
$dataSetValues[] = $values;
|
||||
}
|
||||
|
||||
$namedData = [];
|
||||
$valueIndex = 0;
|
||||
|
||||
foreach (array_count_values($dataSetDescriptions) as $dataSetDescription => $count) {
|
||||
if ($count === 1) {
|
||||
$name = $description . $dataSetDescription;
|
||||
$namedData[$name] = $dataSetValues[$valueIndex];
|
||||
} else {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$name = $description . $dataSetDescription . sprintf(' #%d', $i + 1);
|
||||
$namedData[$name] = $dataSetValues[$valueIndex + $i];
|
||||
foreach (array_count_values($dataSetDescriptions) as $descriptionToCheck => $count) {
|
||||
if ($count > 1) {
|
||||
$index = 1;
|
||||
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
|
||||
if ($dataSetDescription === $descriptionToCheck) {
|
||||
$dataSetDescriptions[$i] .= sprintf(' #%d', $index++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$valueIndex += $count;
|
||||
$namedData = [];
|
||||
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
|
||||
$namedData[$dataSetDescription] = $dataSetValues[$i];
|
||||
}
|
||||
|
||||
return $namedData;
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), false)
|
||||
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), false)
|
||||
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), true)
|
||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #3
|
||||
✓ it creates unique test case names - count
|
||||
|
||||
PASS Tests\Features\Exceptions
|
||||
@ -150,5 +151,5 @@
|
||||
WARN Tests\Visual\Success
|
||||
s visual snapshot of test suite on success
|
||||
|
||||
Tests: 6 skipped, 85 passed
|
||||
Time: 3.52s
|
||||
Tests: 6 skipped, 86 passed
|
||||
Time: 3.58s
|
||||
|
||||
@ -119,8 +119,9 @@ it('creates unique test case names', function (string $name, Plugin $plugin, boo
|
||||
['Name 1', new Plugin(), false],
|
||||
['Name 2', new Plugin(), false],
|
||||
['Name 2', new Plugin(), true],
|
||||
['Name 1', new Plugin(), true],
|
||||
]);
|
||||
|
||||
it('creates unique test case names - count', function () use (&$counter) {
|
||||
assertEquals(5, $counter);
|
||||
assertEquals(6, $counter);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user