diff --git a/src/Generator/ValueGenerator.php b/src/Generator/ValueGenerator.php index 3c7b4c3b..d0c6b69f 100644 --- a/src/Generator/ValueGenerator.php +++ b/src/Generator/ValueGenerator.php @@ -361,6 +361,7 @@ public function generate() } $curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants()); + $curValue->setIndentation($this->indentation); } } diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index c9e04c90..fd28a53e 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -225,6 +225,85 @@ public function complexArray() return $this->generateArrayData($longOutput, $value); } + /** + * Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test + */ + public function complexArrayWCustomIndent(): array + { + $value = [ + '5bcf08a0a5d20' => [ + '5bcf08a0a5d65' => [ + '5bcf08a0a5d9f' => [ + '5bcf08a0a5dd8' => [ + '5bcf08a0a5e11' => [ + '5bcf08a0a5e4f' => '5bcf08a0a5e8c', + '5bcf08a0a5eca' => '5bcf08a0a5f05', + '5bcf08a0a5f43' => '5bcf08a0a5f7f', + '5bcf08a0a5fbd' => '5bcf08a0a5ff8', + ], + ], + '5bcf08a0a603a' => [], + '5bcf08a0a6062' => '5bcf08a0a609f', + '5bcf08a0a60dc' => [ + '5bcf08a0a611b' => '5bcf08a0a6158', + '5bcf08a0a6197' => [ + '5bcf08a0a61d7' => '5bcf08a0a6212', + '5bcf08a0a6250' => '5bcf08a0a628c', + '5bcf08a0a62cb' => '5bcf08a0a6306', + ], + '5bcf08a0a6345' => [ + '5bcf08a0a637e' => '5bcf08a0a63b4', + '5bcf08a0a63ee' => '5bcf08a0a642a', + ], + '5bcf08a0a6449' => '5bcf08a0a6485', + ], + ], + ], '5bcf08a0a64c8' => '5bcf08a0a6540', + '5bcf08a0a657f' => '5bcf08a0a65bf', + ], + ]; + + $longOutput = << array( + '5bcf08a0a5d65' => array( + '5bcf08a0a5d9f' => array( + '5bcf08a0a5dd8' => array( + '5bcf08a0a5e11' => array( + '5bcf08a0a5e4f' => '5bcf08a0a5e8c', + '5bcf08a0a5eca' => '5bcf08a0a5f05', + '5bcf08a0a5f43' => '5bcf08a0a5f7f', + '5bcf08a0a5fbd' => '5bcf08a0a5ff8', + ), + ), + '5bcf08a0a603a' => array( + + ), + '5bcf08a0a6062' => '5bcf08a0a609f', + '5bcf08a0a60dc' => array( + '5bcf08a0a611b' => '5bcf08a0a6158', + '5bcf08a0a6197' => array( + '5bcf08a0a61d7' => '5bcf08a0a6212', + '5bcf08a0a6250' => '5bcf08a0a628c', + '5bcf08a0a62cb' => '5bcf08a0a6306', + ), + '5bcf08a0a6345' => array( + '5bcf08a0a637e' => '5bcf08a0a63b4', + '5bcf08a0a63ee' => '5bcf08a0a642a', + ), + '5bcf08a0a6449' => '5bcf08a0a6485', + ), + ), + ), + '5bcf08a0a64c8' => '5bcf08a0a6540', + '5bcf08a0a657f' => '5bcf08a0a65bf', + ), +) +EOS; + + return $this->generateArrayData($longOutput, $value); + } + /** * Data provider for testPropertyDefaultValueCanHandleArrayWithUnsortedKeys test * @@ -338,6 +417,22 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra self::assertEquals($expected, $valueGenerator->generate()); } + /** + * @dataProvider complexArrayWCustomIndent + */ + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes( + string $type, + array $value, + string $expected + ): void { + $valueGenerator = new ValueGenerator(); + $valueGenerator->setType($type); + $valueGenerator->setValue($value); + $valueGenerator->setIndentation("\t"); + + self::assertEquals($expected, $valueGenerator->generate()); + } + /** * @group 6023 *