8000 recursively set indentations for child arrays by hxss · Pull Request #164 · zendframework/zend-code · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

recursively set indentations for child arrays #164

Merged
merged 8 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Generator/ValueGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ public function generate()
}

$curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants());
$curValue->setIndentation($this->indentation);
}
}

Expand Down
95 changes: 95 additions & 0 deletions test/Generator/ValueGeneratorTest.php
BBC8
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<<EOS
array(
'5bcf08a0a5d20' => 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
*
Expand Down Expand Up @@ -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
*
Expand Down
0