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); } }
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); }
/** * @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')); }
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')); }
/** * 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); }
/** * 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); }
/** * 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); }
public function isEqualToXmlString($xmlString) { Assert::assertXmlStringEqualsXmlString($xmlString, $this->actual, $this->description); return $this; }
public function equalsXmlString($xmlString) { a::assertXmlStringEqualsXmlString($xmlString, $this->actual, $this->description); }
/** * 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; }