Added autoincrement ( Closes #1 )

Added getAttribute & getChildValue ( Closes #3 )
This commit is contained in:
Chouchen
2010-10-12 10:25:17 +00:00
parent 69b9eb42e2
commit f73fe22483
3 changed files with 128 additions and 19 deletions

View File

@@ -25,7 +25,7 @@ class TestOfLogging extends UnitTestCase {
$log->message('Trying to insert item "test" into "table1"');
$this->assertTrue($xmldbtest->insertItem('test', array('pwet'=>'cacahuete'), array('visibility'=>'true', 'x'=>'33'), 'table1'));
$log->message('Trying to do several select');
$this->assertEqual($xmldbtest->selectTable('table1', 'count'), 8);
$this->assertEqual($xmldbtest->selectAllFromTable('table1', 'count'), 8);
$this->assertEqual($xmldbtest->selectFromPK('table1', 'weather', 'count'), 1);
$this->assertEqual($xmldbtest->selectFromAttribute('table1', array('id'=>'weather'), 'count'),1);
$this->assertEqual($xmldbtest->selectFromChildren('table1',array('visibility'=>'true'),'count'), 6);
@@ -35,8 +35,8 @@ class TestOfLogging extends UnitTestCase {
$this->assertFalse($xmldbtest->insertItem('test', null, array('visibility'=>'true', 'x'=>'33'), 'table1'));
$this->assertTrue($xmldbtest->insertItem('test2', null, array('visibility'=>'true', 'x'=>'33'), 'table1'));
$log->message('Trying to do several updates');
$this->assertTrue($xmldbtest->updateNodeAttribute('table1', array('id', 'links'), array('id', 'zelda')));
$this->assertTrue($xmldbtest->updateNodeValue('table1', array('id', 'notes'), null, 'booga!'));
$this->assertTrue($xmldbtest->updateItemAttribute('table1', array('id', 'links'), array('id', 'zelda')));
$this->assertTrue($xmldbtest->updateItemValue('table1', array('id', 'notes'), null, 'booga!'));
$log->message('Trying to delete the item "clock" from "table1"');
//var_dump($xmldbtest->selectFromPK('table1', 'clock', 'node'), true);
//$this->assertTrue($xmldbtest->deleteNode($xmldbtest->selectFromPK('table1', 'clock', 'node')));
@@ -48,6 +48,36 @@ class TestOfLogging extends UnitTestCase {
$log->message('Trying to erase a DB');
$xmldbtest1->dropDatabase(true);
$xmldbtest2 = new XMLDB('database2.xml');
$this->assertTrue($xmldbtest2->isTableAI('table1'));
$this->assertTrue($xmldbtest2->insertItem(null, null, null,'table1'));
$this->assertEqual($xmldbtest2->getChildValue('sex', $xmldbtest2->selectFromPK('table1', '3', 'node')), 'M');
$this->assertTrue($xmldbtest2->createTable('table3', true, 2));
$personnes = array(
3 => array(
'nom' => 'Desmidt',
'prenom' => 'clément'
),
4 => array(
'nom' => 'Chou',
'prenom' => 'Chen'
),
5 => array(
'nom' => 'Votocek',
'prenom' => 'Sophie'
),
6 => array(
'nom' => 'Dupond',
'prenom' => 'Jean'
)
);
foreach($personnes as $personne){
$this->assertTrue($xmldbtest2->insertItem(null, null, $personne, 'table3'));
}
$this->assertTrue($xmldbtest2->deleteITem('table3', '4'));
$this->assertTrue($xmldbtest2->insertItem(null, null, array('visibility'=>'true', 'x'=>'31'), 'table3'));
//$this->assertTrue($xmldbtest2->insertItem(null, null, array('visibility'=>'true', 'x'=>'33'), 'table3'));
//$this->assertEqual($xmldbtest2->getAttribute('aivalue', $xmldbtest2->selectTable('table3')), 5);
/*$log->message('Trying to select w/o anything');
$xmldbtest->select();*/
}