From 0d994a84ab7da9d8694dcd974510b80c179b799f Mon Sep 17 00:00:00 2001 From: hxss Date: Tue, 23 Oct 2018 13:07:25 +0300 Subject: [PATCH 1/8] recursively set indentations for child arrays --- src/Generator/ValueGenerator.php | 1 + 1 file changed, 1 insertion(+) 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); } } From 6a85203036a01652436231c6c3459b17b076dfec Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 23 Oct 2018 15:14:28 +0300 Subject: [PATCH 2/8] added test for recursively set indentations --- test/Generator/ValueGeneratorTest.php | 98 +++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index c9e04c90..37634897 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -225,6 +225,87 @@ public function complexArray() return $this->generateArrayData($longOutput, $value); } + /** + * Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test + * + * @return array + */ + public function complexArrayWCustomIndent() + { + $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 +419,23 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra self::assertEquals($expected, $valueGenerator->generate()); } + /** + * @dataProvider complexArrayWCustomIndent + * + * @param string $type + * @param array $value + * @param string $expected + */ + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes($type, array $value, $expected) + { + $valueGenerator = new ValueGenerator(); + $valueGenerator->setType($type); + $valueGenerator->setValue($value); + $valueGenerator->setIndentation("\t"); + + self::assertEquals($expected, $valueGenerator->generate()); + } + /** * @group 6023 * From 802c4eb56e5b48a8d43392ad27dcedfb18ae5b8f Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 23 Oct 2018 15:38:56 +0300 Subject: [PATCH 3/8] fix test style --- test/Generator/ValueGeneratorTest.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index 37634897..880c6a2d 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -227,10 +227,8 @@ public function complexArray() /** * Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test - * - * @return array */ - public function complexArrayWCustomIndent() + public function complexArrayWCustomIndent(): array { $value = [ '5bcf08a0a5d20' => [ @@ -421,12 +419,8 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra /** * @dataProvider complexArrayWCustomIndent - * - * @param string $type - * @param array $value - * @param string $expected */ - public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes($type, array $value, $expected) + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes(string $type, array $value, string $expected) { $valueGenerator = new ValueGenerator(); $valueGenerator->setType($type); From cbfafb701a9dab7695d674fd4b34a9669aee0417 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 23 Oct 2018 15:50:03 +0300 Subject: [PATCH 4/8] fix test style [2] (forgot :void) --- test/Generator/ValueGeneratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index 880c6a2d..2abbb728 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -420,7 +420,7 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra /** * @dataProvider complexArrayWCustomIndent */ - public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes(string $type, array $value, string $expected) + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes(string $type, array $value, string $expected): void { $valueGenerator = new ValueGenerator(); $valueGenerator->setType($type); From 1c8b7b1d37487a63adf737b46ff6a93656224558 Mon Sep 17 00:00:00 2001 From: hxss Date: Wed, 24 Oct 2018 02:55:22 +0500 Subject: [PATCH 5/8] fix whitespace in test standard --- test/Generator/ValueGeneratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index 2abbb728..9a6df369 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -277,7 +277,7 @@ public function complexArrayWCustomIndent(): array ), ), '5bcf08a0a603a' => array( - + ), '5bcf08a0a6062' => '5bcf08a0a609f', '5bcf08a0a60dc' => array( From 31a3890cf0e17d1cdfe8cc741c6ea169be54896f Mon Sep 17 00:00:00 2001 From: hxss Date: Wed, 24 Oct 2018 03:10:38 +0500 Subject: [PATCH 6/8] fix indents --- test/Generator/ValueGeneratorTest.php | 64 +++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index 9a6df369..f62f32ca 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -230,38 +230,38 @@ public function complexArray() */ 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', - ], - ]; + $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 = << Date: Wed, 24 Oct 2018 03:20:37 +0500 Subject: [PATCH 7/8] fix line length --- test/Generator/ValueGeneratorTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index f62f32ca..c97bc611 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -420,7 +420,11 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra /** * @dataProvider complexArrayWCustomIndent */ - public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes(string $type, array $value, string $expected): void + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes( + string $type, + array $value, + string $expected + ): void { $valueGenerator = new ValueGenerator(); $valueGenerator->setType($type); From 646a77c6d70840da6782e7949c2ab9e959a5f23f Mon Sep 17 00:00:00 2001 From: hxss Date: Wed, 24 Oct 2018 03:25:23 +0500 Subject: [PATCH 8/8] fix brackets positions --- test/Generator/ValueGeneratorTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index c97bc611..fd28a53e 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -424,8 +424,7 @@ public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfType string $type, array $value, string $expected - ): void - { + ): void { $valueGenerator = new ValueGenerator(); $valueGenerator->setType($type); $valueGenerator->setValue($value);