From d609da624b74f57030655112a26fb0228a24b11a Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 9 Jul 2018 10:30:06 -0400 Subject: [PATCH] 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 --- includes/htmlform/HTMLForm.php | 11 +++++++++++ tests/phpunit/includes/htmlform/HTMLFormTest.php | 7 +++++++ 2 files changed, 18 insertions(+) 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() ); + } + } -- 2.20.1