Skip to content

Commit 0db6c01

Browse files
committed
Test case to reproduce #66
1 parent 32ef8f4 commit 0db6c01

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Swaggest\JsonSchema\Tests\PHPUnit\Suite;
4+
5+
use Swaggest\JsonSchema\Schema;
6+
7+
class Issue66Test extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testIssue()
10+
{
11+
$schemaData = json_decode(<<<'JSON'
12+
{
13+
"$schema": "http://json-schema.org/draft-07/schema#",
14+
"$id": "urn:example:api:response-example",
15+
"type": "object",
16+
"additionalProperties": false,
17+
"required": ["confirmed", "to_pay"],
18+
"definitions": {
19+
"example_item": {
20+
"type": "object",
21+
"additionalProperties": false,
22+
"required": [
23+
"_type",
24+
"count"
25+
],
26+
"properties": {
27+
"_type": {
28+
"$id": "#/definitions/example_item/properties/confirmed/properties/_type",
29+
"type": "string",
30+
"enum": ["example_item"]
31+
},
32+
"count": {
33+
"$id": "#/definitions/example_item/properties/confirmed/properties/count",
34+
"type": "integer"
35+
}
36+
}
37+
}
38+
},
39+
"properties": {
40+
"confirmed": {
41+
"$ref": "#/definitions/example_item"
42+
},
43+
"to_pay": {
44+
"$ref": "#/definitions/example_item"
45+
}
46+
}
47+
}
48+
JSON
49+
);
50+
$schema = Schema::import($schemaData);
51+
$res = $schema->in(json_decode('{"confirmed":{"count":123, "_type": "example_item"}, "to_pay":{"count":123, "_type": "example_item"}}'));
52+
$this->assertSame(123, $res->confirmed->count);
53+
}
54+
55+
}

0 commit comments

Comments
 (0)