Skip to content

Commit 46fd09a

Browse files
committed
working
1 parent 7072885 commit 46fd09a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/Schema.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ private function process($data, $import = true, $path = '#')
344344

345345
if ($nestedEgg) {
346346
$result->setNestedProperty($key, $value, $nestedEgg);
347-
348347
} else {
349348
$result->$key = $value;
350349
}

src/Structure/ObjectItem.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public function setNestedProperty($propertyName, $value, Egg $nestedEgg)
1818
$nested->$propertyName = $value;
1919
}
2020

21+
public function getNested($name)
22+
{
23+
if (isset($this->__nestedObjects[$name])) {
24+
return $this->__nestedObjects[$name];
25+
}
26+
return null;
27+
}
28+
2129
protected $__additionalPropertyNames;
2230
public function addAdditionalPropertyName($name)
2331
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Swaggest\JsonSchema\Tests\PHPUnit\ClassStructure;
4+
5+
6+
use Swaggest\JsonSchema\Tests\Helper\NestedStructure;
7+
use Swaggest\JsonSchema\Tests\Helper\SampleStructure;
8+
9+
class NestedTest extends \PHPUnit_Framework_TestCase
10+
{
11+
public function testClassStructure()
12+
{
13+
$schema = NestedStructure::schema();
14+
$data = json_decode(<<<JSON
15+
{
16+
"ownString": "aaa",
17+
"ownMagicInt": 1,
18+
"native": true
19+
}
20+
JSON
21+
);
22+
$object = $schema->import($data);
23+
$this->assertSame('aaa', $object->ownString);
24+
$this->assertSame(true, $object->getNested(SampleStructure::class)->native);
25+
}
26+
27+
}

0 commit comments

Comments
 (0)