expectException(new Exception('uhoh, no table selected')); @unlink('test.log'); $log = new Log('test.log'); $log->message('creating "test.xml" with a table'); $this->assertTrue($xmldbtest1 = new XMLDB('test.xml', 'id', true)); $this->assertTrue($xmldbtest1->createTable('table1')); //$xmldbtest = new XMLDB('text.xml'); //$log->message('Trying to load an inexistant DB'); //$this->assertFalse($xmldbtest->isLoaded()); $log->message('Trying to load "database.xml"'); $xmldbtest = new XMLDB('database.xml'); $this->assertTrue($xmldbtest->isLoaded()); $log->message('Trying to create 2 wrong tables'); $this->assertFalse($xmldbtest->createTable('*')); $this->assertFalse($xmldbtest->createTable('table1')); $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->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); $this->assertEqual($xmldbtest->selectFromChildren('*',array('visibility'=>'true'),'count'), 8); $this->assertEqual($xmldbtest->selectFromChildren('table1',array('visibility'=>'true', 'x'=>'32'),'count'), 1); $log->message('Trying to do several inserts'); $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!')); $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'))); $this->assertTrue($xmldbtest->deleteItem('table1','clock')); //var_dump($xmldbtest->selectFromPK('table1', 'search', 'node')->item(0)); $log->message('Trying to move an element to another table'); $this->assertTrue($xmldbtest->move( $xmldbtest->selectFromPK('table1', 'search', 'node'), 'table2')); $log->message('Trying to erase a DB'); $xmldbtest1->dropDatabase(true); /*$log->message('Trying to select w/o anything'); $xmldbtest->select();*/ } } $test = new TestOfLogging; $test->test();