0

Edit:

As @nigelRen pointed out, the problem was the quotes. I copied my XML from the DBUnit documentation as a starting point, and it appears the double quote characters that it came with were not the same as the double quote characters I would type in my editor. Overtyping them fixes the issue.


I am new to using PHPUnit and am now augmenting with DBUnit. I have created a test database and am using createFlatXMLDataSet to populate it with data in the getDataSet() test method, per the DBUnit docs.

It seems my XML File is improperly formatted, judging by a litany of LibXMLErrors:

RuntimeException: LibXMLError Object
   │ (
   │     [level] => 3
   │     [code] => 33
   │     [column] => 15
   │     [message] => String not started expecting ' or "
   │ 
   │     [file] => /Users/lookdangerous/mono/master/php/tests/customer-seed.xml
   │     [line] => 1
   │ )
   │ LibXMLError Object
   │ (
   │     [level] => 3
   │     [code] => 96
   │     [column] => 15
   │     [message] => Malformed declaration expecting version
   │ 
   │     [file] => /Users/lookdangerous/mono/master/php/tests/customer-seed.xml
   │     [line] => 1
   │ )
   │ LibXMLError Object
   │ (
   │     [level] => 3
   │     [code] => 65
   │     [column] => 15
   │     [message] => Blank needed here
   │ 
   │     [file] => /Users/lookdangerous/mono/master/php/tests/customer-seed.xml
   │     [line] => 1
   │ )

(This is only a few of the many I am receiving. )

customer-seed.xml:

<?xml version=“1.0” encoding="UTF-8" ?>
<dataset>
    <customers
    GUID=“fe70e6fe-3e7f-4aa3-bf98-d48ed08ba80b”
    ClientID=“ANDE8834”
    />
    <customers
    GUID=“9f3d1594-a743-41c3-9787-2f8d916287a3”
    ClientID="FRAN3987"
    />
  <dependents />
  <rentals />
  <businesses />
</dataset>

And finally, the code calling the function:

return $this->createFlatXMLDataSet(dirname(__FILE__).'/customer-seed.xml');

It at first seemed like a problem with magic_qutoes, per this stack overflow question and this one, but then I realized I am using PHP 7+ so it should not apply.

It seems like the behavior, though, is as if magic quotes were turned on. I also questioned file encoding, and added the encoding tag as seen above to no avail.

Jade Steffen
  • 130
  • 2
  • 10
  • Can you check the quotes your using - i.e. `“1.0”` and the quotes on the attributes `GUID` – Nigel Ren Oct 28 '18 at 18:18
  • @NigelRen good eye! This type of thing has happened to me before, mostly when copying and pasting code from various online doc sources. Looks like the quotes I was using were something different than the regular double quotes... Again, good eye! If you like, write an answer saying something similar below and I will accept it. – Jade Steffen Oct 28 '18 at 18:20

0 Answers0