Mysqldump xml format and dbunit expected xml format in phpunit test in php

I work in phpunit testing with dbunit. This is my first time test in php.

I create xml with this command:

mysqldump --xml -t -u username -p database > seed.xml 

After that, according to the doc, the xml should be in the format below:

<?xml version="1.0" ?>
<dataset>
    <guestbook id="1" content="Hello buddy!" user="joe" created="2010-04-24 17:15:23" />
    <guestbook id="2" content="I like it!" created="2010-04-26 12:14:20" />
</dataset>

But in my generated xml, it looks like this:

 <?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="demo_app">
    <table_data name="test">
    <row>
        <field name="id">1</field>
    </row>
    </table_data>
    <table_data name="test2">
    <row>
        <field name="id">1</field>
        <field name="name">asdas</field>
    </row>
    <row>
        <field name="id">2</field>
        <field name="name">asDASD</field>
    </row>
    </table_data>
</database>
</mysqldump>

When I try to run this in my test class:

$this->createMySQLXMLDataSet('seed.xml');

I get this error:

PHPUnit_Extensions_Database_Exception: root element of flat xml dataset file must be called

I am using phpunit 4.1.0 and dbunit 1.3

How can I create xml in the expected format or how can I get rid of this problem?

+4
source share
1 answer

, , Flat XML, createMySQLXMLDataSet().

, , , createFlatXmlDataSet() .

, mysqldump, createMySQLXMLDataSet().

+1

Source: https://habr.com/ru/post/1540494/


All Articles