mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 00:54:49 +02:00
Add: e_parse::toFlatArray() and e_parse::fromFlatArray()
Utility functions to convert multi-dimensional arrays to slash-delimited single-dimensional arrays and vice versa
This commit is contained in:
@@ -583,6 +583,44 @@ while($row = $sql->fetch())
|
||||
|
||||
}
|
||||
*/
|
||||
public function testToFlatArray()
|
||||
{
|
||||
$input = [
|
||||
'a' => [
|
||||
'b' => [
|
||||
'c' => 'value',
|
||||
],
|
||||
],
|
||||
];
|
||||
$expected = [
|
||||
'prepend/xyza/b/c' => 'value'
|
||||
];
|
||||
|
||||
$tp = $this->tp;
|
||||
$actual = $tp->toFlatArray($input, 'prepend/xyz');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
public function testFromFlatArray()
|
||||
{
|
||||
$input = [
|
||||
'prepend/xyza/b/c' => 'value'
|
||||
];
|
||||
$expected = [
|
||||
'a' => [
|
||||
'b' => [
|
||||
'c' => 'value',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$tp = $this->tp;
|
||||
$actual = $tp->fromFlatArray($input, 'prepend/xyz');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
public function testToForm()
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user