sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

Multiple data set files support in PHPUnit_Extensions_Database_TestCase #6

Open sebastianbergmann opened 14 years ago

sebastianbergmann commented 14 years ago

Copied from http://www.phpunit.de/ticket/724

elyobo commented 14 years ago

I have the same problem; I have some data which is common to several different tests, and when I want to change it I need to go modify it in several different places.

It seems to me that this would be easily by supporting external html entities; this requires only one change to the simplexml_load_file call, adding the LIBXML_NOENT argument.

We can then do things like

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE dataset [
    <!ENTITY someFileOne SYSTEM "./someFileOne.xml">
    <!ENTITY someFileTwo SYSTEM "./someFileTwo.xml">
]>
<dataset>
    &someFileOne;
    &someFileTwo;
</dataset>

I have changed the simplexml_load_file call from $this->xmlFileContents = @simplexml_load_file($xmlFile); to $this->xmlFileContents = @simplexml_load_file($xmlFile, null, LIBXML_NOENT);

and it seems to work fine (although my testing is very limited so far).

elyobo commented 14 years ago

Perhaps this can be enabled as an option when the dataset is created if there are compatibiltiy concerns.

elyobo commented 14 years ago

I'm not familiar with git, so I'm not sure how to provide it, but I have created a patch which adds an option to process the entities when creating the datasets; the change is trivial. If anyone can explain how I can attach a patch (or what other process I should follow) I'll provide the patch.

elyobo commented 13 years ago

I've implemented the change in my fork if that helps any other users that would like this simple feature.