Skip to content

Commit b6406bf

Browse files
Merge branch '12.3'
2 parents 120f0c4 + b6cedb9 commit b6406bf

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

src/Framework/TestBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function buildDataProviderTestSuite(string $methodName, string $classNam
9595
foreach ($data as $_dataName => $_data) {
9696
$_test = new $className($methodName);
9797

98-
$_test->setData($_dataName, $_data->getData());
98+
$_test->setData($_dataName, $_data->value());
9999

100100
$this->configureTestCase(
101101
$_test,

src/Metadata/Api/DataProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public function providedData(string $className, string $methodName): ?array
7171
$testMethodIsNonVariadic = !$testMethod->isVariadic();
7272

7373
foreach ($data as $key => $providedData) {
74-
$value = $providedData->getData();
74+
$value = $providedData->value();
7575

7676
if (!is_array($value)) {
7777
throw new InvalidDataProviderException(
7878
sprintf(
7979
'Data set %s provided by %s is invalid, expected array but got %s',
8080
$this->formatKey($key),
81-
$providedData->getProviderLabel(),
81+
$providedData->label(),
8282
get_debug_type($value),
8383
),
8484
);
@@ -88,7 +88,7 @@ public function providedData(string $className, string $methodName): ?array
8888
$this->triggerWarningForArgumentCount(
8989
$testMethod,
9090
$this->formatKey($key),
91-
$providedData->getProviderLabel(),
91+
$providedData->label(),
9292
count($value),
9393
$testMethodNumberOfParameters,
9494
);
@@ -195,7 +195,7 @@ private function dataProvidedByMethods(ReflectionMethod $testMethod, MetadataCol
195195
sprintf(
196196
'The key "%s" has already been defined by provider %s',
197197
$key,
198-
$result[$key]->getProviderLabel(),
198+
$result[$key]->label(),
199199
),
200200
);
201201
}
@@ -238,7 +238,7 @@ private function dataProvidedByMetadata(MetadataCollection $testWith): array
238238
sprintf(
239239
'The key "%s" has already been defined by %s',
240240
$key,
241-
$result[$key]->getProviderLabel(),
241+
$result[$key]->label(),
242242
),
243243
);
244244
}

src/Metadata/Api/ProvidedData.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,38 @@
99
*/
1010
namespace PHPUnit\Metadata\Api;
1111

12+
/**
13+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
14+
*
15+
* @internal This class is not covered by the backward compatibility promise for PHPUnit
16+
*/
1217
final readonly class ProvidedData
1318
{
14-
public function __construct(
15-
private string $providerLabel,
16-
private mixed $data
17-
) {
19+
/**
20+
* @var non-empty-string
21+
*/
22+
private string $label;
23+
private mixed $value;
24+
25+
/**
26+
* @param non-empty-string $label
27+
*/
28+
public function __construct(string $label, mixed $value)
29+
{
30+
$this->label = $label;
31+
$this->value = $value;
1832
}
1933

20-
public function getData(): mixed
34+
/**
35+
* @return non-empty-string
36+
*/
37+
public function label(): string
2138
{
22-
return $this->data;
39+
return $this->label;
2340
}
2441

25-
public function getProviderLabel(): string
42+
public function value(): mixed
2643
{
27-
return $this->providerLabel;
44+
return $this->value;
2845
}
2946
}

tests/unit/Metadata/Api/DataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private function getRawDataFromProvidedData(array $providedData): array
220220
$raw = [];
221221

222222
foreach ($providedData as $key => $data) {
223-
$raw[$key] = $data->getData();
223+
$raw[$key] = $data->value();
224224
}
225225

226226
return $raw;

0 commit comments

Comments
 (0)