Skip to content

Commit a771833

Browse files
committed
feat(Data): DataZip now accepts any Data source
1 parent d2d13b7 commit a771833

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/Data/DataZip.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
final class DataZip implements Interceptable, DataProviderAttribute
2323
{
2424
/**
25-
* @param array<DataProvider> $providers Data providers to zip together.
25+
* @param array<DataProviderAttribute> $providers Data providers to zip together.
2626
*/
2727
public readonly array $providers;
2828

29-
public function __construct(DataProvider ...$providers)
29+
public function __construct(DataProviderAttribute ...$providers)
3030
{
3131
$this->providers = $providers;
3232
}

src/Data/Internal/DataProviderInterceptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private static function fromDataZip(TestInfo $info, DataZip $attr): iterable
218218
$generators = \array_map(
219219
static fn ($providerAttr): DeferredGenerator => DeferredGenerator::fromHandler(
220220
static function () use ($info, $providerAttr) {
221-
yield from self::fromDataProvider($info, $providerAttr);
221+
yield from self::extractDataSets($info, $providerAttr);
222222
},
223223
),
224224
$attr->providers,

tests/Data/Self/DataZip.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Testo\Application\Attribute\Test;
88
use Testo\Assert;
99
use Testo\Data\DataProvider;
10+
use Testo\Data\DataSet;
1011

1112
final class DataZip
1213
{
@@ -58,4 +59,19 @@ public function sumFew(int $a, int $b, string $c, string $d): void
5859
[3, 4, 'c', 'd'],
5960
], true));
6061
}
62+
63+
#[Test]
64+
#[\Testo\Data\DataZip(
65+
new DataSet([true], 'yes'),
66+
new DataProvider('lettersProvider'),
67+
new DataSet([42], 'answer'),
68+
)]
69+
public function mixedProviders(bool $flag, string $c, string $d, int $number): void
70+
{
71+
// DataSet has only 1 element, so zip stops after first iteration
72+
Assert::true($flag);
73+
Assert::same('a', $c);
74+
Assert::same('b', $d);
75+
Assert::same(42, $number);
76+
}
6177
}

0 commit comments

Comments
 (0)