public function testParseData() { $ary = array(array('name' => 'Test1', 'email' => '*****@*****.**'), array('name' => 'Test2', 'email' => '*****@*****.**')); $d = new Data($ary); $d->setTable('users')->setIdQuote('`'); $this->assertContains('INSERT INTO `users` (`name`, `email`) VALUES', $d->parseData('sql')); $this->assertContains('<name>Test1</name>', $d->parseData('xml')); $this->assertContains('Test1,test1@test.com', $d->parseData('csv')); }
$xml = $data->parseFile(); $data = new Data('../assets/files/test.yml'); $yml = $data->parseFile(); echo 'CSV data to XML file<br />-------------------<br />' . PHP_EOL; $data = new Data($csv); $obj = $data->parseData('xml'); echo $obj; echo PHP_EOL . '<br /><br />' . PHP_EOL; echo 'SQL data to CSV file<br />-------------------<br />' . PHP_EOL; $data = new Data($sql); $obj = $data->parseData('csv'); echo $obj; echo PHP_EOL . '<br /><br />' . PHP_EOL; echo 'SQL data to YAML file<br />-------------------<br />' . PHP_EOL; $data = new Data($sql); $obj = $data->parseData('yaml'); echo $obj; echo PHP_EOL . '<br /><br />' . PHP_EOL; echo 'XML data to SQL file<br />-------------------<br />' . PHP_EOL; $data = new Data($xml); $data->setTable('users')->setIdQuote('`'); $obj = $data->parseData('sql'); echo $obj; echo PHP_EOL . '<br /><br />' . PHP_EOL; echo 'YAML data to JSON file<br />-------------------<br />' . PHP_EOL; $data = new Data($yml); $obj = $data->parseData('json'); echo $obj; } catch (\Exception $e) { echo $e->getMessage(); }