From: David Barratt Date: Mon, 9 Jul 2018 14:30:06 +0000 (-0400) Subject: Add a method to HTMLForm that allows the preText to be accessed externally. X-Git-Tag: 1.34.0-rc.0~4841^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=d609da624b74f57030655112a26fb0228a24b11a;p=lhc%2Fweb%2Fwiklou.git Add a method to HTMLForm that allows the preText to be accessed externally. Currently there is no way to access the preText outside of an HTMLForm. Adding a getPreText method to HTMLForm so the preText is accessible. Bug: T199115 Change-Id: I937028e7025b4a7b5d333e9bf5a25920f6a88316 --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index cec3bfb1d4..442a7cf6fa 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -752,6 +752,17 @@ class HTMLForm extends ContextSource { return $this; } + /** + * Get the introductory message HTML. + * + * @since 1.32 + * + * @return string + */ + public function getPreText() { + return $this->mPre; + } + /** * Add HTML to the header, inside the form. * diff --git a/tests/phpunit/includes/htmlform/HTMLFormTest.php b/tests/phpunit/includes/htmlform/HTMLFormTest.php index 05e15a33d6..06772e5e68 100644 --- a/tests/phpunit/includes/htmlform/HTMLFormTest.php +++ b/tests/phpunit/includes/htmlform/HTMLFormTest.php @@ -54,4 +54,11 @@ class HTMLFormTest extends MediaWikiTestCase { $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) ); } + public function testGetPreText() { + $preText = 'TEST'; + $form = $this->newInstance(); + $form->setPreText( $preText ); + $this->assertSame( $preText, $form->getPreText() ); + } + }