4

Hey, Im new to the whole PHPUnit and would like to test my code against a database, from reading all the stuff on the phpunit.de, it talks about a seed.xml file.

Can someone just clarify, do i need to create this dataset myself using a mysqldump command, or does it create it for me at the beginning of the test?

Many thanks in advance

1
  • hey post the link when you get any answers Commented Dec 7, 2010 at 12:51

1 Answer 1

4

I am just now researching this myself and came across this blog post:

http://matthewturland.com/2010/01/04/database-testing-with-phpunit-and-mysql/

So if you choose to accept the PHPUnit >= 3.5.0 requirements, you can use

mysqldump --xml -t -u username -p database

to create seed.xml and then load it as a dataset for DBUnit with

$dataSet = $this->createMySQLXMLDataSet('/path/to/seed.xml');
Sign up to request clarification or add additional context in comments.

2 Comments

I've done this and get error messages like RuntimeException: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE4 0x6B 0x6F 0x77 PCDATA invalid Char value 25 PCDATA invalid Char value 20 PCDATA invalid Char value 12 PCDATA invalid Char value 31 Premature end of data in tag field line 40095 Premature end of data in tag row line 40091 Premature end of data in tag table_data line 40090 Premature end of data in tag database line 3 Premature end of data in tag mysqldump line 2
It sounds like your dump file is not valid UTF-8 encoded. Check the encoding of your MySQL database. Some googling leads me to believe that you can convert the dump file if you know the source encoding by using the iconv utility, see docs.moodle.org/24/en/Converting_files_to_UTF-8 But I expect things will be a lot easier if you convert your database to use UTF-8 first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.