/** * Test that XML generated from response matches expected. * * @dataProvider responseArrayProvider **/ public function testExpectedXML($response, $expectedXML) { $outputXML = new Frapi_Output_XML(); try { $outputXML->populateOutput($response); } catch (Frapi_Output_XML_Exception $e) { if ($expectedXML !== false) { $this->fail('Expected Frapi_Output_XML_Exception because of invalid element names.'); } } if ($expectedXML !== false) { $generatedXML = $outputXML->executeOutput(); $this->assertXMLStringEqualsXMLString($expectedXML, $generatedXML); try { simplexml_load_string($generatedXML); } catch (Exception $e) { $this->fail('Invalid XML generated.'); } } }
/** * Test the XML output of an empty response from action. **/ public function testCustomTemplate() { $outputXML = new Frapi_Output_XML(); $outputXML->populateOutput(array('custom'), 'CustomTesting2'); $this->assertXMLStringEqualsXMLString('<response><custom /></response>', $outputXML->executeOutput()); }