assertXmlStringEqualsXmlString() public static method

Asserts that two XML documents are equal.
public static assertXmlStringEqualsXmlString ( string $expectedXml, string $actualXml, string $message = '' )
$expectedXml string
$actualXml string
$message string
Exemplo n.º 1
0
 public static function assertEquals(TestRequestResponse $expected, TestRequestResponse $actual, $message = false)
 {
     $expectedText = $expected->getResponseText();
     $actualText = $actual->getResponseText();
     if ($expected->requestUrl['format'] == 'xml') {
         Asserts::assertXmlStringEqualsXmlString($expectedText, $actualText, $message);
     } else {
         Asserts::assertEquals(strlen($expectedText), strlen($actualText), $message);
         Asserts::assertEquals($expectedText, $actualText, $message);
     }
 }
Exemplo n.º 2
0
 public static function assertEquals(Response $expected, Response $actual, $message = false)
 {
     $expectedText = $expected->getResponseText();
     $actualText = $actual->getResponseText();
     if ($expected->requestUrl['format'] == 'xml') {
         Asserts::assertXmlStringEqualsXmlString($expectedText, $actualText, $message);
         return;
     }
     // check content size to get quick feedback and avoid lengthy diff
     $checkSizeFirst = array('pdf', 'csv', 'html');
     if (!empty($expected->requestUrl['reportFormat']) && in_array($expected->requestUrl['reportFormat'], $checkSizeFirst)) {
         Asserts::assertEquals(strlen($expectedText), strlen($actualText), $message);
     }
     Asserts::assertEquals($expectedText, $actualText, $message);
 }
Exemplo n.º 3
0
 /**
  * @dataProvider readerDataProvider
  */
 public function testReadValidConfig($files, $expectedFile)
 {
     $this->_fileResolverMock->expects($this->once())->method('get')->with('mview.xml', 'scope')->will($this->returnValue($files));
     $constraint = function (\DOMDocument $actual) use($expectedFile) {
         try {
             $expected = file_get_contents(__DIR__ . '/../_files/' . $expectedFile);
             \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML());
             return true;
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             return false;
         }
     };
     $expectedResult = new \stdClass();
     $this->_converter->expects($this->once())->method('convert')->with($this->callback($constraint))->will($this->returnValue($expectedResult));
     $this->assertSame($expectedResult, $this->_model->read('scope'));
 }
Exemplo n.º 4
0
 public function testRead()
 {
     $this->read->expects($this->at(0))->method('readAll')->will($this->returnValue(file_get_contents($this->_paths[0])));
     $this->read->expects($this->at(1))->method('readAll')->will($this->returnValue(file_get_contents($this->_paths[1])));
     $this->_moduleDirResolver->expects($this->at(0))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleOne/etc/email_templates_one.xml')->will($this->returnValue('Fixture_ModuleOne'));
     $this->_moduleDirResolver->expects($this->at(1))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleTwo/etc/email_templates_two.xml')->will($this->returnValue('Fixture_ModuleTwo'));
     $constraint = function (\DOMDocument $actual) {
         try {
             $expected = file_get_contents(__DIR__ . '/_files/email_templates_merged.xml');
             $expectedNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $expected, 1);
             $actualNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $actual->saveXML(), 1);
             \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedNorm, $actualNorm);
             return true;
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             return false;
         }
     };
     $expectedResult = new \stdClass();
     $this->_converter->expects($this->once())->method('convert')->with($this->callback($constraint))->will($this->returnValue($expectedResult));
     $this->assertSame($expectedResult, $this->_model->read('scope'));
 }
Exemplo n.º 5
0
/**
 * Asserts that two XML documents are equal.
 *
 * @param  string $expectedXml
 * @param  string $actualXml
 * @param  string $message
 * @since  Method available since Release 3.1.0
 */
function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '')
{
    return PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message);
}
Exemplo n.º 6
0
 /**
  * Checks XML response equals provided XML.
  * Comparison is done by canonicalizing both xml`s.
  *
  * Parameters can be passed either as DOMDocument, DOMNode, XML string, or array (if no attributes).
  *
  * @param $xml
  * @part xml
  */
 public function seeXmlResponseEquals($xml)
 {
     \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($this->response, $xml);
 }
Exemplo n.º 7
0
 /**
  * Checks XML response equals provided XML.
  * Comparison is done by canonicalizing both xml`s.
  *
  * Parameters can be passed either as DOMDocument, DOMNode, XML string, or array (if no attributes).
  *
  * @param $xml
  * @part xml
  */
 public function seeXmlResponseEquals($xml)
 {
     \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($this->connectionModule->_getResponseContent(), $xml);
 }
Exemplo n.º 8
0
 public function isEqualToXmlString($xmlString)
 {
     Assert::assertXmlStringEqualsXmlString($xmlString, $this->actual, $this->description);
     return $this;
 }
Exemplo n.º 9
0
 public function equalsXmlString($xmlString)
 {
     a::assertXmlStringEqualsXmlString($xmlString, $this->actual, $this->description);
 }
Exemplo n.º 10
0
 /**
  * Expect that two XML documents are equal.
  *
  * @param string $expectedXml
  * @param string $message
  *
  * @return Expect
  */
 public function toEqualXml($expectedXml, $message = '')
 {
     Assert::assertXmlStringEqualsXmlString($expectedXml, $this->value, $message);
     return $this;
 }