Skip to content

Commit 84f681b

Browse files
committed
test: correct test regression due to newly introduced tests
1 parent 7dcf6fd commit 84f681b

File tree

3 files changed

+60
-18
lines changed

3 files changed

+60
-18
lines changed

tests/Drafts/Draft3Test.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ protected function getFilePaths(): array
7575
];
7676
}
7777

78+
public function getInvalidTests(): \Generator
79+
{
80+
$skip = [
81+
'ref.json / $ref prevents a sibling id from changing the base uri / $ref resolves to /definitions/base_foo, data does not validate'
82+
];
83+
84+
foreach (parent::getInvalidTests() as $name => $testcase) {
85+
if (in_array($name, $skip, true)) {
86+
continue;
87+
}
88+
yield $name => $testcase;
89+
}
90+
}
91+
7892
public function getInvalidForAssocTests(): \Generator
7993
{
8094
$skip = [

tests/Drafts/Draft4Test.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,32 @@ protected function getFilePaths(): array
2020
];
2121
}
2222

23+
public function getInvalidTests(): \Generator
24+
{
25+
$skip = [
26+
'id.json / id inside an enum is not a real identifier / no match on enum or $ref to id',
27+
'ref.json / $ref prevents a sibling id from changing the base uri / $ref resolves to /definitions/base_foo, data does not validate',
28+
'ref.json / Recursive references between schemas / invalid tree',
29+
'ref.json / refs with quote / object with strings is invalid',
30+
'ref.json / Location-independent identifier / mismatch',
31+
'ref.json / Location-independent identifier with base URI change in subschema / mismatch',
32+
'ref.json / empty tokens in $ref json-pointer / non-number is invalid',
33+
'ref.json / id must be resolved against nearest parent, not just immediate parent / non-number is invalid',
34+
'refRemote.json / Location-independent identifier in remote ref / string is invalid',
35+
];
36+
37+
foreach (parent::getInvalidTests() as $name => $testcase) {
38+
if (in_array($name, $skip, true)) {
39+
continue;
40+
}
41+
yield $name => $testcase;
42+
}
43+
}
44+
2345
public function getInvalidForAssocTests(): \Generator
2446
{
2547
$skip = [
48+
'ref.json / Recursive references between schemas / valid tree',
2649
'type.json / object type matches objects / an array is not an object',
2750
'type.json / array type matches arrays / an object is not an array',
2851
];
@@ -35,6 +58,27 @@ public function getInvalidForAssocTests(): \Generator
3558
}
3659
}
3760

61+
public function getValidTests(): \Generator
62+
{
63+
$skip = [
64+
'ref.json / $ref prevents a sibling id from changing the base uri / $ref resolves to /definitions/base_foo, data validates',
65+
'ref.json / Recursive references between schemas / valid tree',
66+
'ref.json / refs with quote / object with numbers is valid',
67+
'ref.json / Location-independent identifier / match',
68+
'ref.json / Location-independent identifier with base URI change in subschema / match',
69+
'ref.json / empty tokens in $ref json-pointer / number is valid',
70+
'ref.json / naive replacement of $ref with its destination is not correct / match the enum exactly',
71+
'refRemote.json / Location-independent identifier in remote ref / integer is valid',
72+
];
73+
74+
foreach (parent::getValidTests() as $name => $testcase) {
75+
if (in_array($name, $skip, true)) {
76+
continue;
77+
}
78+
yield $name => $testcase;
79+
}
80+
}
81+
3882
public function getValidForAssocTests(): \Generator
3983
{
4084
$skip = [

tests/JsonSchemaTestSuite.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,13 @@ public function testIt(
3636
self::assertEquals($expectedValidationResult, count($validator->getErrors()) === 0);
3737
}
3838

39-
public function testItOnce(): void
40-
{
41-
$schema = json_decode('{ "required": ["__proto__", "toString", "constructor"] }', false);
42-
$data = [];
43-
44-
$schemaStorage = new SchemaStorage();
45-
$schemaStorage->addSchema(SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI, $schema);
46-
$this->loadRemotesIntoStorage($schemaStorage);
47-
$validator = new Validator(new Factory($schemaStorage));
48-
49-
$result = $validator->validate($data, $schema);
50-
51-
self::assertEquals(true, count($validator->getErrors()) === 0);
52-
}
53-
54-
5539
public function casesDataProvider(): \Generator
5640
{
5741
$testDir = __DIR__ . '/../vendor/json-schema/json-schema-test-suite/tests';
5842
$drafts = array_filter(glob($testDir . '/*'), static function (string $filename) {
5943
return is_dir($filename);
6044
});
61-
$skippedDrafts = ['draft3', 'draft6', 'draft7', 'draft2019-09', 'draft2020-12', 'draft-next', 'latest'];
45+
$skippedDrafts = ['draft6', 'draft7', 'draft2019-09', 'draft2020-12', 'draft-next', 'latest'];
6246

6347
foreach ($drafts as $draft) {
6448
if (in_array(basename($draft), $skippedDrafts, true)) {
@@ -85,7 +69,7 @@ function ($file) {
8569
$file->getBasename(),
8670
$testCase->description,
8771
$test->description,
88-
$test->valid ? 'valid' : 'invalid',
72+
$test->valid ? 'valid' : 'invalid'
8973
);
9074

9175
yield $name => [

0 commit comments

Comments
 (0)