Skip to content

Commit beabe4b

Browse files
author
Malte Riesch
committed
added methods PsvTree::toArray and getTableNames
1 parent e9f44cb commit beabe4b

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

lib/TestDbAcle/Psv/PsvTree.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,18 @@ function getTables()
2828
{
2929
return $this->tables;
3030
}
31+
32+
function toArray()
33+
{
34+
$out = array();
35+
foreach ($this->getTableNames() as $table) {
36+
$out[$table] = $this->getTable($table)->toArray();
37+
}
38+
return $out;
39+
}
40+
41+
function getTableNames()
42+
{
43+
return array_keys($this->tables);
44+
}
3145
}

tests/TestDbAcle/Psv/PsvParserTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,45 @@ function test_parsePsvTree() {
187187
'identifiedBy' => array('first_name','last_name') ), $parsedTree->getTable('expression1')->getMeta()->toArray());
188188

189189
$this->assertEquals(array(), $parsedTree->getTable('expression2')->getMeta()->toArray());
190+
191+
$this->assertEquals(array (
192+
'expression1' =>
193+
array (
194+
0 =>
195+
array (
196+
'id' => '10',
197+
'first_name' => 'john',
198+
'last_name' => '[miller]',
199+
),
200+
1 =>
201+
array (
202+
'id' => '20',
203+
'first_name' => 'stu',
204+
'last_name' => 'Smith"',
205+
),
206+
),
207+
'expression2' =>
208+
array (
209+
0 =>
210+
array (
211+
'col1' => '1',
212+
'col2' => 'moo',
213+
'col3' => 'foo',
214+
),
215+
1 =>
216+
array (
217+
'col1' => '30',
218+
'col2' => 'miaow',
219+
'col3' => 'boo',
220+
),
221+
),
222+
'empty' =>
223+
array (
224+
),
225+
), $parsedTree->toArray());
226+
227+
$this->assertEquals(array('expression1','expression2','empty'), $parsedTree->getTableNames());
228+
190229
}
191230

192231
}

0 commit comments

Comments
 (0)