mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Only append numbers when data set desc is the same
This commit is contained in:
@ -74,14 +74,31 @@ final class Datasets
|
||||
$data = iterator_to_array($data);
|
||||
}
|
||||
|
||||
$namedData = [];
|
||||
$number = 1;
|
||||
$dataSetDescriptions = [];
|
||||
$dataSetValues = [];
|
||||
|
||||
foreach ($data as $values) {
|
||||
$values = is_array($values) ? $values : [$values];
|
||||
|
||||
$name = $description . sprintf(' #%d', $number) . self::getDataSetDescription($values);
|
||||
$namedData[$name] = $values;
|
||||
$number++;
|
||||
$dataSetDescriptions[] = 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];
|
||||
}
|
||||
}
|
||||
|
||||
$valueIndex += $count;
|
||||
}
|
||||
|
||||
return $namedData;
|
||||
|
||||
@ -22,28 +22,30 @@
|
||||
✓ it throws exception if dataset already exist
|
||||
✓ it sets closures
|
||||
✓ it sets arrays
|
||||
✓ it gets bound to test case object #1 with ('a')
|
||||
✓ it gets bound to test case object #2 with ('b')
|
||||
✓ it truncates the description #1 with ('FoooFoooFoooFoooFoooFoooFoooF...ooFooo')
|
||||
✓ lazy datasets #1 with (1)
|
||||
✓ lazy datasets #2 with (2)
|
||||
✓ it gets bound to test case object with ('a')
|
||||
✓ it gets bound to test case object with ('b')
|
||||
✓ it truncates the description with ('FoooFoooFoooFoooFoooFoooFoooF...ooFooo')
|
||||
✓ lazy datasets with (1)
|
||||
✓ lazy datasets with (2)
|
||||
✓ lazy datasets did the job right
|
||||
✓ eager datasets #1 with (1)
|
||||
✓ eager datasets #2 with (2)
|
||||
✓ eager datasets with (1)
|
||||
✓ eager datasets with (2)
|
||||
✓ eager datasets did the job right
|
||||
✓ lazy registered datasets #1 with (1)
|
||||
✓ lazy registered datasets #2 with (2)
|
||||
✓ lazy registered datasets with (1)
|
||||
✓ lazy registered datasets with (2)
|
||||
✓ lazy registered datasets did the job right
|
||||
✓ eager registered datasets #1 with (1)
|
||||
✓ eager registered datasets #2 with (2)
|
||||
✓ eager registered datasets with (1)
|
||||
✓ eager registered datasets with (2)
|
||||
✓ eager registered datasets did the job right
|
||||
✓ eager wrapped registered datasets #1 with (1)
|
||||
✓ eager wrapped registered datasets #2 with (2)
|
||||
✓ eager wrapped registered datasets with (1)
|
||||
✓ eager wrapped registered datasets with (2)
|
||||
✓ eager registered wrapped datasets did the job right
|
||||
✓ lazy named datasets #1 with (Bar Object (...))
|
||||
✓ it creates unique test case names #1 with ('Name 1', Pest\Plugin Object (), true)
|
||||
✓ it creates unique test case names #2 with ('Name 1', Pest\Plugin Object (), true)
|
||||
✓ it creates unique test case names #3 with ('Name 1', Pest\Plugin Object (), false)
|
||||
✓ lazy named datasets with (Bar Object (...))
|
||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #1
|
||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #2
|
||||
✓ 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 - count
|
||||
|
||||
PASS Tests\Features\Exceptions
|
||||
@ -148,5 +150,5 @@
|
||||
WARN Tests\Visual\Success
|
||||
s visual snapshot of test suite on success
|
||||
|
||||
Tests: 6 skipped, 83 passed
|
||||
Time: 3.59s
|
||||
Tests: 6 skipped, 85 passed
|
||||
Time: 3.52s
|
||||
|
||||
@ -117,8 +117,10 @@ it('creates unique test case names', function (string $name, Plugin $plugin, boo
|
||||
['Name 1', new Plugin(), true],
|
||||
['Name 1', new Plugin(), true],
|
||||
['Name 1', new Plugin(), false],
|
||||
['Name 2', new Plugin(), false],
|
||||
['Name 2', new Plugin(), true],
|
||||
]);
|
||||
|
||||
it('creates unique test case names - count', function () use (&$counter) {
|
||||
assertEquals(3, $counter);
|
||||
assertEquals(5, $counter);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user