[MediaWiki-commits] [Gerrit] Get innerHTML correctly in DI node assertions - change (mediawiki...DonationInterface)
Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/150897 Change subject: Get innerHTML correctly in DI node assertions .. Get innerHTML correctly in DI node assertions Change-Id: I533f60c233a590f651b689741e45630697fa9128 --- M tests/Adapter/WorldPay/WorldPayTestCase.php M tests/DonationInterfaceTestCase.php 2 files changed, 11 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/97/150897/1 diff --git a/tests/Adapter/WorldPay/WorldPayTestCase.php b/tests/Adapter/WorldPay/WorldPayTestCase.php index 6131732..b8c50d0 100644 --- a/tests/Adapter/WorldPay/WorldPayTestCase.php +++ b/tests/Adapter/WorldPay/WorldPayTestCase.php @@ -135,7 +135,7 @@ ), 'informationsharing' => array ( 'nodename' => 'p', - 'innerhtml' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone. For more information please read our donor policy.', + 'innerhtml' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone. For more information please read our donor policy.', ), ); diff --git a/tests/DonationInterfaceTestCase.php b/tests/DonationInterfaceTestCase.php index fa8f751..f71dfb7 100644 --- a/tests/DonationInterfaceTestCase.php +++ b/tests/DonationInterfaceTestCase.php @@ -396,10 +396,10 @@ $this->assertEquals( $expected, $input_node->nodeName, "The node with id '$id' is not an '$expected'. It is a " . $input_node->nodeName ); break; case 'innerhtml': - $this->assertEquals( $expected, $input_node->nodeValue, "The node with id '$id' does not have value '$expected'. It has value " . $input_node->nodeValue ); + $this->assertEquals( $expected, self::getInnerHTML( $input_node ), "The node with id '$id' does not have value '$expected'. It has value " . self::getInnerHTML( $input_node ) ); break; case 'innerhtmlmatches': - $this->assertEquals( 1, preg_match($expected, $input_node->nodeValue), "Value of the node with id '$id' does not match pattern '$expected'. It has value " . $input_node->nodeValue ); + $this->assertEquals( 1, preg_match( $expected, self::getInnerHTML( $input_node ) ), "Value of the node with id '$id' does not match pattern '$expected'. It has value " . self::getInnerHTML( $input_node ) ); break; case 'value': $this->assertEquals( $expected, $input_node->getAttribute('value'), "The node with id '$id' does not have value '$expected'. It has value " . $input_node->getAttribute('value') ); @@ -483,4 +483,12 @@ return $return; } + static function getInnerHTML( $node ) { + $innerHTML = ''; + $children = $node->childNodes; + foreach ( $children as $child ) { + $innerHTML .= $child->ownerDocument->saveXML( $child ); + } + return $innerHTML; + } } -- To view, visit https://gerrit.wikimedia.org/r/150897 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I533f60c233a590f651b689741e45630697fa9128 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Get innerHTML correctly in DI node assertions - change (mediawiki...DonationInterface)
jenkins-bot has submitted this change and it was merged. Change subject: Get innerHTML correctly in DI node assertions .. Get innerHTML correctly in DI node assertions Change-Id: I533f60c233a590f651b689741e45630697fa9128 --- M tests/Adapter/WorldPay/WorldPayTestCase.php M tests/DonationInterfaceTestCase.php 2 files changed, 11 insertions(+), 3 deletions(-) Approvals: Awight: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/Adapter/WorldPay/WorldPayTestCase.php b/tests/Adapter/WorldPay/WorldPayTestCase.php index 10a22fd..389cd3c 100644 --- a/tests/Adapter/WorldPay/WorldPayTestCase.php +++ b/tests/Adapter/WorldPay/WorldPayTestCase.php @@ -140,7 +140,7 @@ ), 'informationsharing' => array ( 'nodename' => 'p', - 'innerhtml' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone. For more information please read our donor policy.', + 'innerhtml' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone. For more information please read our donor policy.', ), ); diff --git a/tests/DonationInterfaceTestCase.php b/tests/DonationInterfaceTestCase.php index ab26907..73825fa 100644 --- a/tests/DonationInterfaceTestCase.php +++ b/tests/DonationInterfaceTestCase.php @@ -401,10 +401,10 @@ $this->assertEquals( $expected, $input_node->nodeName, "The node with id '$id' is not an '$expected'. It is a " . $input_node->nodeName ); break; case 'innerhtml': - $this->assertEquals( $expected, $input_node->nodeValue, "The node with id '$id' does not have value '$expected'. It has value " . $input_node->nodeValue ); + $this->assertEquals( $expected, self::getInnerHTML( $input_node ), "The node with id '$id' does not have value '$expected'. It has value " . self::getInnerHTML( $input_node ) ); break; case 'innerhtmlmatches': - $this->assertEquals( 1, preg_match($expected, $input_node->nodeValue), "Value of the node with id '$id' does not match pattern '$expected'. It has value " . $input_node->nodeValue ); + $this->assertEquals( 1, preg_match( $expected, self::getInnerHTML( $input_node ) ), "Value of the node with id '$id' does not match pattern '$expected'. It has value " . self::getInnerHTML( $input_node ) ); break; case 'value': $this->assertEquals( $expected, $input_node->getAttribute('value'), "The node with id '$id' does not have value '$expected'. It has value " . $input_node->getAttribute('value') ); @@ -488,4 +488,12 @@ return $return; } + static function getInnerHTML( $node ) { + $innerHTML = ''; + $children = $node->childNodes; + foreach ( $children as $child ) { + $innerHTML .= $child->ownerDocument->saveXML( $child ); + } + return $innerHTML; + } } -- To view, visit https://gerrit.wikimedia.org/r/150897 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I533f60c233a590f651b689741e45630697fa9128 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg Gerrit-Reviewer: AndyRussG Gerrit-Reviewer: Awight Gerrit-Reviewer: Ejegg Gerrit-Reviewer: Ssmith Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits