mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge branch 'master' into feature/depends
This commit is contained in:
@ -74,12 +74,30 @@ final class Datasets
|
|||||||
$data = iterator_to_array($data);
|
$data = iterator_to_array($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$namedData = [];
|
$dataSetDescriptions = [];
|
||||||
|
$dataSetValues = [];
|
||||||
|
|
||||||
foreach ($data as $values) {
|
foreach ($data as $values) {
|
||||||
$values = is_array($values) ? $values : [$values];
|
$values = is_array($values) ? $values : [$values];
|
||||||
|
|
||||||
$name = $description . self::getDataSetDescription($values);
|
$dataSetDescriptions[] = $description . self::getDataSetDescription($values);
|
||||||
$namedData[$name] = $values;
|
$dataSetValues[] = $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
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++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$namedData = [];
|
||||||
|
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
|
||||||
|
$namedData[$dataSetDescription] = $dataSetValues[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $namedData;
|
return $namedData;
|
||||||
|
|||||||
@ -41,6 +41,13 @@
|
|||||||
✓ eager wrapped registered datasets with (2)
|
✓ eager wrapped registered datasets with (2)
|
||||||
✓ eager registered wrapped datasets did the job right
|
✓ eager registered wrapped datasets did the job right
|
||||||
✓ lazy named datasets with (Bar Object (...))
|
✓ 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 with ('Name 1', Pest\Plugin Object (), true) #3
|
||||||
|
✓ it creates unique test case names - count
|
||||||
|
|
||||||
WARN Tests\Features\Depends
|
WARN Tests\Features\Depends
|
||||||
✓ first
|
✓ first
|
||||||
@ -156,3 +163,4 @@
|
|||||||
|
|
||||||
Tests: 1 warnings, 7 skipped, 85 passed
|
Tests: 1 warnings, 7 skipped, 85 passed
|
||||||
Time: 2.65s
|
Time: 2.65s
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
use Pest\Datasets;
|
use Pest\Datasets;
|
||||||
use Pest\Exceptions\DatasetAlreadyExist;
|
use Pest\Exceptions\DatasetAlreadyExist;
|
||||||
use Pest\Exceptions\DatasetDoesNotExist;
|
use Pest\Exceptions\DatasetDoesNotExist;
|
||||||
|
use Pest\Plugin;
|
||||||
|
|
||||||
it('throws exception if dataset does not exist', function () {
|
it('throws exception if dataset does not exist', function () {
|
||||||
$this->expectException(DatasetDoesNotExist::class);
|
$this->expectException(DatasetDoesNotExist::class);
|
||||||
@ -106,3 +107,21 @@ $namedDatasets = [
|
|||||||
test('lazy named datasets', function ($text) use ($state, $datasets) {
|
test('lazy named datasets', function ($text) use ($state, $datasets) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
})->with($namedDatasets);
|
})->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],
|
||||||
|
['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(6, $counter);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user