]>
My para
Ampersand & is retained and not double encoded
XML
;
$expected = [
'result' => [
'My para',
'Ampersand & is retained and not double encoded'
]
];
$formatter = new XMLDataFormatter();
$actual = $formatter->convertStringToArray($inputXML);
$this->assertEquals($expected, $actual);
}
/**
* Tests {@link Convert::xml2array()} if an exception the contains a reference to a removed
*/
public function testConvertStringToArrayEntityException()
{
$inputXML = <<
]>
Now include &long; lots of times to expand the in-memory size of this XML structure
&long;&long;&long;
XML;
$this->expectException(Exception::class);
$this->expectExceptionMessage('String could not be parsed as XML');
$formatter = new XMLDataFormatter();
$formatter->convertStringToArray($inputXML);
}
/**
* Tests {@link Convert::xml2array()} if an exception the contains a reference to a multiple removed
*/
public function testConvertStringToArrayMultipleEntitiesException()
{
$inputXML = <<
]>
Now include &long; and &short; lots of times
&long;&long;&long;&short;&short;&short;
XML;
$this->expectException(Exception::class);
$this->expectExceptionMessage('String could not be parsed as XML');
$formatter = new XMLDataFormatter();
$formatter->convertStringToArray($inputXML);
}
}