'; if($xmldbtest1 = new XMLDB('test.xml', 'id', true)) echo "ok"; else echo "ko"; echo '
Creating new table (should be "ok" adding table1 in test)
'; if($xmldbtest1->createTable('table1')) echo "ok"; else echo "ko"; echo '
loading an inexistant DB (error)
'; $xmldbtest = new XMLDB('text.xml'); if(!$xmldbtest->isLoaded()){ echo '

can\'t load test.xml
'; $xmldbtest = new XMLDB('database.xml'); if($xmldbtest->isLoaded()){ // Testing select($from, $attributeName = null, $attributeValue = null, $childName = null, $childValue = null) echo 'Testing empty select (exception)
'; try { $xmldbtest->select(); } catch(Exception $e){ echo $e->getMessage().'

'; } echo '
Creating new table name "*" (should be "ko" table already exist)
'; if($xmldbtest->createTable('*')) echo "ok"; else echo "ko"; echo '
Creating new table (should be "ko" table already exist)
'; if($xmldbtest->createTable('table1')) echo "ok"; else echo "ko"; echo '
Testing insertNode at XML root (should insert an item named "test" into table1)
'; if($xmldbtest->insertNode(array('name'=>'item', 'attributes'=>array('id'=>'test'), 'childs'=>array('visibility'=>'true', 'x'=>'33')), 'table1')) echo "ok

"; else echo "ko

"; echo 'Testing select (should give 8 results - 7 from the file + 1 we created earlier)
'; $result = $xmldbtest->select('table1'); echo count($result).' results

'; echo 'Testing select id=weather with pk (should find 1 result)
'; $result = $xmldbtest->selectFromPK('table1', 'weather'); echo count($result).' results

'; echo 'Testing select id=weather (should find 1 result)
'; $result = $xmldbtest->select('table1', null, array('id'=>'weather')); echo count($result).' results

'; echo 'Testing select visibility = true (should throw 6 results - 5 from the base file + 1 we created)
'; $result = $xmldbtest->select('table1', null,null,array('visibility'=>'true')); echo count($result).' results

'; echo 'Testing select visibility = true on all tables (should find 8 results - 7 from the base file + 1 we created)
'; $result = $xmldbtest->select('*', null,null,array('visibility'=>'true')); echo count($result).' results

'; echo 'Testing select visibility = true and x = 32 (experimental - should find 1)
'; $result = $xmldbtest->selectFromChilds('table1',array('visibility'=>'true', 'x'=>'32')); echo count($result).' results

'; echo '
Testing insertNode that already exist (should do "ko")
'; if($xmldbtest->insertNode(array('name'=>'item', 'attributes'=>array('id'=>'test'), 'childs'=>array('visibility'=>'true', 'x'=>'33')), 'table1')) echo "ok

"; else echo "ko

"; echo '
Testing insertNode that doesn\'t exist (should do "ok")
'; if($xmldbtest->insertNode(array('name'=>'item', 'attributes'=>array('id'=>'test2'), 'childs'=>array('visibility'=>'true', 'x'=>'33')), 'table1')) echo "ok

"; else echo "ko

"; echo '
Testing updatingNodeAttribute with no insert (should be ok and change the item "links" into "zelda" haha)
'; if($xmldbtest->updateNodeAttribute('table1', array('id', 'links'), array('id', 'zelda'))) echo "ok

"; else echo "ko

"; echo '
Testing updateNodeValue via attribute (should be ok - inserting "booga!" into the item named "notes")
'; if($xmldbtest->updateNodeValue('table1', array('id', 'notes'), null, 'booga!')) echo "ok

"; else echo "ko

"; echo '
Testing deleteNode via pk (should be ok - deleting the item clock into table1)
'; if($xmldbtest->deleteNode('table1', 'clock', null)) echo "ok

"; else echo "ko

"; }else{ exit("can't load config.xml either"); } }