Skip to content

Commit 2e2042e

Browse files
committed
refactor: apply generator to draft 4 test
1 parent 7b4a61e commit 2e2042e

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

tests/Drafts/Draft4Test.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,34 @@ protected function getFilePaths(): array
2828
];
2929
}
3030

31-
public function getInvalidForAssocTests(): array
31+
public function getInvalidForAssocTests(): \Generator
3232
{
33-
$tests = parent::getInvalidForAssocTests();
34-
unset(
35-
$tests['type.json / object type matches objects / an array is not an object'],
36-
$tests['type.json / array type matches arrays / an object is not an array']
37-
);
33+
$skip = [
34+
'type.json / object type matches objects / an array is not an object',
35+
'type.json / array type matches arrays / an object is not an array',
36+
];
3837

39-
return $tests;
38+
foreach (parent::getInvalidForAssocTests() as $name => $testcase) {
39+
if (in_array($name, $skip, true)) {
40+
continue;
41+
}
42+
yield $name => $testcase;
43+
}
4044
}
4145

42-
public function getValidForAssocTests(): array
46+
public function getValidForAssocTests(): \Generator
4347
{
44-
$tests = parent::getValidForAssocTests();
45-
unset(
46-
$tests['type.json / object type matches objects / an array is not an object'],
47-
$tests['type.json / array type matches arrays / an object is not an array']
48-
);
48+
$skip = [
49+
'type.json / object type matches objects / an array is not an object',
50+
'type.json / array type matches arrays / an object is not an array',
51+
];
4952

50-
return $tests;
53+
foreach (parent::getValidForAssocTests() as $name => $testcase) {
54+
if (in_array($name, $skip, true)) {
55+
continue;
56+
}
57+
yield $name => $testcase;
58+
}
5159
}
5260

5361
/**

0 commit comments

Comments
 (0)