fixes ignored dataset description for string description

This commit is contained in:
Alex Manase
2022-11-17 15:43:30 +02:00
parent 339414e348
commit 09b7ab9a42
3 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest;
use Closure;
use Generator;
use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist;
use SebastianBergmann\Exporter\Exporter;
@ -122,7 +123,10 @@ final class Datasets
}
if ($datasets[$index] instanceof Traversable) {
$datasets[$index] = iterator_to_array($datasets[$index], false);
$preserveKeysForArrayIterator = $datasets[$index] instanceof Generator
&& is_string($datasets[$index]->key());
$datasets[$index] = iterator_to_array($datasets[$index], $preserveKeysForArrayIterator);
}
foreach ($datasets[$index] as $key => $values) {