dbunit icon indicating copy to clipboard operation
dbunit copied to clipboard

Multiple data set files support in PHPUnit_Extensions_Database_TestCase

Open sebastianbergmann opened this issue 14 years ago • 4 comments

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

sebastianbergmann avatar May 25 '10 05:05 sebastianbergmann

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 avatar Oct 19 '10 03:10 elyobo

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

elyobo avatar Oct 19 '10 03:10 elyobo

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 avatar Oct 24 '10 23:10 elyobo

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

  • https://github.com/elyobo/dbunit

elyobo avatar Apr 05 '11 02:04 elyobo