Skip to content

Commit 8bbfba3

Browse files
author
Enno Woortmann
committed
add test case for multidimensional array serialization (production lib v 0.20.1)
1 parent 562e860 commit 8bbfba3

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"symfony/polyfill-php81": "^1.28",
15-
"wol-soft/php-json-schema-model-generator-production": "^0.20",
15+
"wol-soft/php-json-schema-model-generator-production": "^0.20.1",
1616
"wol-soft/php-micro-template": "^1.10.0",
1717

1818
"php": ">=8.0",

tests/Basic/BasicSchemaGenerationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ public function testNestedSerializationFunctions(): void
218218
$this->assertFalse($object->toJSON([], 0, 0));
219219
}
220220

221+
public function testMultidimensionalArraySerialization(): void
222+
{
223+
$className = $this->generateClassFromFile(
224+
'MultidimensionalArray.json',
225+
(new GeneratorConfiguration())->setSerialization(true),
226+
);
227+
228+
$structure = [
229+
'array' => [
230+
[
231+
['id' => 1],
232+
['id' => 2],
233+
],
234+
[
235+
['id' => 3],
236+
['id' => 4],
237+
],
238+
],
239+
];
240+
241+
$object = new $className($structure);
242+
$this->assertSame($structure, $object->toArray());
243+
$this->assertSame('{"array":[[{"id":1},{"id":2}],[{"id":3},{"id":4}]]}', $object->toJSON());
244+
}
245+
221246
/**
222247
* @dataProvider invalidStringPropertyValueProvider
223248
*/

tests/Basic/PatternPropertiesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPModelGenerator\Exception\SchemaException;
88
use PHPModelGenerator\Model\GeneratorConfiguration;
99
use PHPModelGenerator\ModelGenerator;
10-
use PHPModelGenerator\SchemaProcessor\PostProcessor\AdditionalPropertiesAccessorPostProcessor;
1110
use PHPModelGenerator\SchemaProcessor\PostProcessor\PatternPropertiesAccessorPostProcessor;
1211
use PHPModelGenerator\Tests\AbstractPHPModelGeneratorTestCase;
1312
use stdClass;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"array": {
5+
"type": "array",
6+
"items": {
7+
"type": "array",
8+
"items": {
9+
"type": "object",
10+
"properties": {
11+
"id": {
12+
"type": "integer"
13+
}
14+
}
15+
}
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)