jenkins-bot has submitted this change and it was merged. Change subject: Add Message test for implicit formatting ......................................................................
Add Message test for implicit formatting Change-Id: Ia6ec10d0d6da8c2b323054642e206c722d17f0b0 --- M tests/phpunit/includes/MessageTest.php 1 file changed, 29 insertions(+), 0 deletions(-) Approvals: Anomie: Looks good to me, approved Thiemo Mättig (WMDE): Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/tests/phpunit/includes/MessageTest.php b/tests/phpunit/includes/MessageTest.php index 4c689ab..9b9a73a 100644 --- a/tests/phpunit/includes/MessageTest.php +++ b/tests/phpunit/includes/MessageTest.php @@ -256,6 +256,35 @@ $this->assertEquals( $expect, $msg->__toString() ); } + public static function provideToString_raw() { + return [ + [ '<span>foo</span>', '<span>foo</span>', 'parse' ], + [ '<span>foo</span>', '<span>foo</span>', 'escaped' ], + [ '<span>foo</span>', '<span>foo</span>', 'plain' ], + [ '<script>alert(1)</script>', '<script>alert(1)</script>', 'parse' ], + [ '<script>alert(1)</script>', '<script>alert(1)</script>', 'escaped' ], + [ '<script>alert(1)</script>', '<script>alert(1)</script>', 'plain' ], + ]; + } + + /** + * @covers Message::toString + * @covers Message::__toString + * @dataProvider provideToString_raw + */ + public function testToString_raw( $key, $expect, $format ) { + // make the message behave like RawMessage and use the key as-is + $msg = $this->getMockBuilder( Message::class )->setMethods( [ 'fetchMessage' ] ) + ->setConstructorArgs( [ $key ] ) + ->getMock(); + $msg->expects( $this->any() )->method( 'fetchMessage' )->willReturn( $key ); + /** @var Message $msg */ + $msg->$format(); + $this->assertEquals( $expect, $msg->toString() ); + $this->assertEquals( $expect, $msg->__toString() ); + $this->assertEquals( $expect, $msg->toString() ); + } + /** * @covers Message::inLanguage */ -- To view, visit https://gerrit.wikimedia.org/r/320563 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia6ec10d0d6da8c2b323054642e206c722d17f0b0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits