Add a method to HTMLForm that allows the preText to be accessed externally.
authorDavid Barratt <dbarratt@wikimedia.org>
Mon, 9 Jul 2018 14:30:06 +0000 (10:30 -0400)
committerDavid Barratt <dbarratt@wikimedia.org>
Mon, 9 Jul 2018 14:42:19 +0000 (10:42 -0400)
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
tests/phpunit/includes/htmlform/HTMLFormTest.php

index cec3bfb..442a7cf 100644 (file)
@@ -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.
         *
index 05e15a3..06772e5 100644 (file)
@@ -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() );
+       }
+
 }