Convert phpmyadmin to phpunit xml format

It is always a pain to create datasets for testing. I know the code should make it possible to test without using the database, but this is not always the case. Phpmyadmin offers a good possibility to create datasets by exporting the needed data from a database. The problem here is that the exported format does not match the format needed for phpunit. After digging a while in the net I found out, that there are converters to do this, but they are for older versions of phpmyadmin. Since version 3.3.0 they changed their xml format.

So I decided to create my own converter:

Get it

I put it on GitHub, feel free to use and change it as you like:



The converter offers you to combine different tables into one dataset.

Let’s say you don’t want to create a database copy for the test (which should be usually the case) you just make a simple selection of the values that you need for the test and export it as xml file. You do this for all the tables and columns that you need and you end up with some xml files. Put the path to each file as parameter into the function and wait a little. The function will create a output file with all the datasets combined into one, which is ready to be used with php unit

Have fun.