fix: ignored dataset description for string description

This commit is contained in:
Alex Manase
2022-12-07 20:10:23 +02:00
parent f940b89284
commit d33cc19778
3 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest\Repositories;
use Closure;
use Generator;
use Pest\Exceptions\DatasetAlreadyExists;
use Pest\Exceptions\DatasetDoesNotExist;
use Pest\Exceptions\ShouldNotHappen;
@ -155,7 +156,10 @@ final class DatasetsRepository
}
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);
}
// @phpstan-ignore-next-line