guzzle/guzzle — pull request #374 by Danack (2013-07-11 10:20:21+00:00)
Title: Used correct encoding for test setup and expectation.

The XmlVisitorTest was not running for on OSX + 5.4, but was running fine for all versions of Linux.

I investigated this and it appears to be a bug on OSX in the libxml2 library which PHP uses in XMLWriter. If you call xmlwriter->startDocument with the non-standard spelling of 'utf8' it silently corrects it to 'UTF-8'. XMLWriter does not do this on Centos or Travis.

I think changing the test to use the correct spelling is the right thing to do. Even though it's not needed for Linux, it's nice for OSX people to be able to run the tests and there's almost zero chance of getting this fixed through the libxml2 library within a year.

For reference here is a minimal test of the different behaviour.

$writer = new XMLWriter();
$writer->openMemory();
$encoding = "utf8";

$writer->startDocument('1.0', $encoding);
$writer->startElement('foo');
$output = $writer->outputMemory();
echo $output;

# Mac OSX PHP5.4