mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Add name to description for named datasets
This commit is contained in:
@ -77,10 +77,10 @@ final class Datasets
|
|||||||
$dataSetDescriptions = [];
|
$dataSetDescriptions = [];
|
||||||
$dataSetValues = [];
|
$dataSetValues = [];
|
||||||
|
|
||||||
foreach ($data as $values) {
|
foreach ($data as $key => $values) {
|
||||||
$values = is_array($values) ? $values : [$values];
|
$values = is_array($values) ? $values : [$values];
|
||||||
|
|
||||||
$dataSetDescriptions[] = $description . self::getDataSetDescription($values);
|
$dataSetDescriptions[] = $description . self::getDataSetDescription($key, $values);
|
||||||
$dataSetValues[] = $values;
|
$dataSetValues[] = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,12 +104,15 @@ final class Datasets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int|string $key
|
||||||
* @param array<int, mixed> $data
|
* @param array<int, mixed> $data
|
||||||
*/
|
*/
|
||||||
private static function getDataSetDescription(array $data): string
|
private static function getDataSetDescription($key, array $data): string
|
||||||
{
|
{
|
||||||
$exporter = new Exporter();
|
$exporter = new Exporter();
|
||||||
|
|
||||||
return \sprintf(' with (%s)', $exporter->shortenedRecursiveExport($data));
|
$nameInsert = is_string($key) ? \sprintf('data set "%s" ', $key) : '';
|
||||||
|
|
||||||
|
return \sprintf(' with %s(%s)', $nameInsert, $exporter->shortenedRecursiveExport($data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -345,6 +345,9 @@
|
|||||||
✓ it throws exception when `process isolation` is true
|
✓ it throws exception when `process isolation` is true
|
||||||
✓ it do not throws exception when `process isolation` is false
|
✓ it do not throws exception when `process isolation` is false
|
||||||
|
|
||||||
|
PASS Tests\Unit\Datasets
|
||||||
|
✓ it show the names of named datasets in their description
|
||||||
|
|
||||||
PASS Tests\Unit\Plugins\Version
|
PASS Tests\Unit\Plugins\Version
|
||||||
✓ it outputs the version when --version is used
|
✓ it outputs the version when --version is used
|
||||||
✓ it do not outputs version when --version is not used
|
✓ it do not outputs version when --version is not used
|
||||||
@ -385,5 +388,5 @@
|
|||||||
✓ depends with defined arguments
|
✓ depends with defined arguments
|
||||||
✓ depends run test only once
|
✓ depends run test only once
|
||||||
|
|
||||||
Tests: 7 skipped, 227 passed
|
Tests: 7 skipped, 228 passed
|
||||||
|
|
||||||
13
tests/Unit/Datasets.php
Normal file
13
tests/Unit/Datasets.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Pest\Datasets;
|
||||||
|
|
||||||
|
it('show the names of named datasets in their description', function () {
|
||||||
|
$descriptions = array_keys(Datasets::resolve('test description', [
|
||||||
|
'one' => [1],
|
||||||
|
'two' => [[2]],
|
||||||
|
]));
|
||||||
|
|
||||||
|
$this->assertSame('test description with data set "one" (1)', $descriptions[0]);
|
||||||
|
$this->assertSame('test description with data set "two" (array(2))', $descriptions[1]);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user