diff --git a/src/Datasets.php b/src/Datasets.php index e2009c86..309ca51a 100644 --- a/src/Datasets.php +++ b/src/Datasets.php @@ -75,11 +75,13 @@ final class Datasets } $namedData = []; + $number = 1; foreach ($data as $values) { $values = is_array($values) ? $values : [$values]; - $name = $description . self::getDataSetDescription($values); + $name = $description . sprintf(' #%d', $number) . self::getDataSetDescription($values); $namedData[$name] = $values; + $number++; } return $namedData; diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 961a0180..c85f178e 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -22,25 +22,29 @@ ✓ it throws exception if dataset already exist ✓ it sets closures ✓ it sets arrays - ✓ 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) + ✓ 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) ✓ lazy datasets did the job right - ✓ eager datasets with (1) - ✓ eager datasets with (2) + ✓ eager datasets #1 with (1) + ✓ eager datasets #2 with (2) ✓ eager datasets did the job right - ✓ lazy registered datasets with (1) - ✓ lazy registered datasets with (2) + ✓ lazy registered datasets #1 with (1) + ✓ lazy registered datasets #2 with (2) ✓ lazy registered datasets did the job right - ✓ eager registered datasets with (1) - ✓ eager registered datasets with (2) + ✓ eager registered datasets #1 with (1) + ✓ eager registered datasets #2 with (2) ✓ eager registered datasets did the job right - ✓ eager wrapped registered datasets with (1) - ✓ eager wrapped registered datasets with (2) + ✓ eager wrapped registered datasets #1 with (1) + ✓ eager wrapped registered datasets #2 with (2) ✓ eager registered wrapped datasets did the job right - ✓ lazy named datasets with (Bar Object (...)) + ✓ 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) + ✓ it creates unique test case names - count PASS Tests\Features\Exceptions ✓ it gives access the the underlying expectException @@ -144,5 +148,5 @@ WARN Tests\Visual\Success s visual snapshot of test suite on success - Tests: 6 skipped, 79 passed - Time: 3.44s + Tests: 6 skipped, 83 passed + Time: 3.59s diff --git a/tests/Features/Datasets.php b/tests/Features/Datasets.php index 688616c0..1294e5d0 100644 --- a/tests/Features/Datasets.php +++ b/tests/Features/Datasets.php @@ -3,6 +3,7 @@ use Pest\Datasets; use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetDoesNotExist; +use Pest\Plugin; it('throws exception if dataset does not exist', function () { $this->expectException(DatasetDoesNotExist::class); @@ -106,3 +107,18 @@ $namedDatasets = [ test('lazy named datasets', function ($text) use ($state, $datasets) { assertTrue(true); })->with($namedDatasets); + +$counter = 0; + +it('creates unique test case names', function (string $name, Plugin $plugin, bool $bool) use (&$counter) { + assertTrue(true); + $counter++; +})->with([ + ['Name 1', new Plugin(), true], + ['Name 1', new Plugin(), true], + ['Name 1', new Plugin(), false], +]); + +it('creates unique test case names - count', function () use (&$counter) { + assertEquals(3, $counter); +});