| 1 |
lars |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// $Id: getElement.php,v 1.3 2004/12/21 17:06:02 dufuz Exp $
|
|
|
4 |
//
|
|
|
5 |
|
|
|
6 |
require_once 'UnitTest.php';
|
|
|
7 |
|
|
|
8 |
class tests_getElement extends UnitTest
|
|
|
9 |
{
|
|
|
10 |
/**
|
|
|
11 |
* There was a bug when we mapped column names, especially when we mapped
|
|
|
12 |
* a column to the same name as the column. We check this here too.
|
|
|
13 |
*
|
|
|
14 |
*
|
|
|
15 |
*/
|
|
|
16 |
function test_MemoryDBnested()
|
|
|
17 |
{
|
|
|
18 |
$tree = $this->getMemoryDBnested();
|
|
|
19 |
$tree->update(3, array('comment' => 'PEAR rulez'));
|
|
|
20 |
$tree->setup();
|
|
|
21 |
$actual = $tree->getElement(3);
|
|
|
22 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
23 |
|
|
|
24 |
$tree->setOption('columnNameMaps', array('comment' => 'comment'));
|
|
|
25 |
$actual = $tree->getElement(3);
|
|
|
26 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
27 |
|
|
|
28 |
$tree->setOption('columnNameMaps', array('myComment' => 'comment'));
|
|
|
29 |
$actual = $tree->getElement(3);
|
|
|
30 |
$this->assertEquals('PEAR rulez', $actual['myComment']);
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
function test_MemoryMDBnested()
|
|
|
34 |
{
|
|
|
35 |
$tree = $this->getMemoryMDBnested();
|
|
|
36 |
$tree->update(3, array('comment' => 'PEAR rulez'));
|
|
|
37 |
$tree->setup();
|
|
|
38 |
$actual = $tree->getElement(3);
|
|
|
39 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
40 |
|
|
|
41 |
$tree->setOption('columnNameMaps', array('comment' => 'comment'));
|
|
|
42 |
$actual = $tree->getElement(3);
|
|
|
43 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
44 |
|
|
|
45 |
$tree->setOption('columnNameMaps', array('myComment' => 'comment'));
|
|
|
46 |
$actual = $tree->getElement(3);
|
|
|
47 |
$this->assertEquals('PEAR rulez', $actual['myComment']);
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
// do this for XML
|
|
|
51 |
|
|
|
52 |
// do this for Filesystem
|
|
|
53 |
|
|
|
54 |
// do this for DBsimple
|
|
|
55 |
|
|
|
56 |
// do this for DynamicDBnested
|
|
|
57 |
function test_DynamicDBnested()
|
|
|
58 |
{
|
|
|
59 |
$tree =& $this->getDynamicDBnested();
|
|
|
60 |
$tree->update(3, array('comment' => 'PEAR rulez'));
|
|
|
61 |
$actual = $tree->getElement(3);
|
|
|
62 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
63 |
|
|
|
64 |
$tree->setOption('columnNameMaps', array('comment' => 'comment'));
|
|
|
65 |
$actual = $tree->getElement(3);
|
|
|
66 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
67 |
|
|
|
68 |
$tree->setOption('columnNameMaps', array('myComment' => 'comment'));
|
|
|
69 |
$actual = $tree->getElement(3);
|
|
|
70 |
$this->assertEquals('PEAR rulez', $actual['myComment']);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
function test_DynamicMDBnested()
|
|
|
74 |
{
|
|
|
75 |
$tree =& $this->getDynamicMDBnested();
|
|
|
76 |
$tree->update(3, array('comment' => 'PEAR rulez'));
|
|
|
77 |
$actual = $tree->getElement(3);
|
|
|
78 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
79 |
|
|
|
80 |
$tree->setOption('columnNameMaps', array('comment' => 'comment'));
|
|
|
81 |
$actual = $tree->getElement(3);
|
|
|
82 |
$this->assertEquals('PEAR rulez', $actual['comment']);
|
|
|
83 |
|
|
|
84 |
$tree->setOption('columnNameMaps', array('myComment' => 'comment'));
|
|
|
85 |
$actual = $tree->getElement(3);
|
|
|
86 |
$this->assertEquals('PEAR rulez', $actual['myComment']);
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Empty the tree and add an element, retreive it and check if it is the one we added.
|
|
|
91 |
*
|
|
|
92 |
*
|
|
|
93 |
*/
|
|
|
94 |
function test_DynamicDBnestedEmptyTree()
|
|
|
95 |
{
|
|
|
96 |
$tree = Tree::setup('Dynamic_DBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
97 |
$tree->remove($tree->getRootId());
|
|
|
98 |
|
|
|
99 |
$tree = Tree::setup('Memory_DBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
100 |
$tree->setup();
|
|
|
101 |
$id = $tree->add(array('name' => 'Start'));
|
|
|
102 |
$tree->setup();
|
|
|
103 |
$el = $tree->getElement($id);
|
|
|
104 |
$this->assertEquals('Start', $el['name']);
|
|
|
105 |
$tree->remove($tree->getRootId());
|
|
|
106 |
|
|
|
107 |
$tree = Tree::setup('Dynamic_DBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
108 |
$id = $tree->add(array('name' => 'StartDyn'));
|
|
|
109 |
$el = $tree->getElement($id);
|
|
|
110 |
$this->assertEquals('StartDyn', $el['name']);
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
function test_DynamicMDBnestedEmptyTree()
|
|
|
114 |
{
|
|
|
115 |
$tree = Tree::setup('Dynamic_MDBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
116 |
$tree->remove($tree->getRootId());
|
|
|
117 |
|
|
|
118 |
$tree = Tree::setup('Memory_MDBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
119 |
$tree->setup();
|
|
|
120 |
$id = $tree->add(array('name' => 'Start'));
|
|
|
121 |
$tree->setup();
|
|
|
122 |
$el = $tree->getElement($id);
|
|
|
123 |
$this->assertEquals('Start', $el['name']);
|
|
|
124 |
$tree->remove($tree->getRootId());
|
|
|
125 |
|
|
|
126 |
$tree = Tree::setup('Dynamic_MDBnested', DB_DSN, array('table' => TABLE_TREENESTED));
|
|
|
127 |
$id = $tree->add(array('name' => 'StartDyn'));
|
|
|
128 |
$el = $tree->getElement($id);
|
|
|
129 |
$this->assertEquals('StartDyn', $el['name']);
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
?>
|