Frédéric Wang has submitted this change and it was merged.

Change subject: Fix: id-attribute
......................................................................


Fix: id-attribute

Id attribute was read wrong place

Change-Id: I6f2671a322f637a1d8e0c88833ce4456d188829b
---
M MathRenderer.php
A tests/MathIdTest.php
2 files changed, 21 insertions(+), 4 deletions(-)

Approvals:
  Frédéric Wang: Looks good to me, approved



diff --git a/MathRenderer.php b/MathRenderer.php
index 58a317a..8e46583 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -76,6 +76,9 @@
                $this->userInputTex = $tex;
                $this->tex = $tex;
                $this->params = $params;
+               if ( isset( $params['id'] ) ) {
+                       $this->id = $params['id'];
+               }
        }
 
        /**
@@ -139,10 +142,7 @@
                                $tex = '{\textstyle ' . $tex . '}';
                        }
                }
-               $id = null;
-               if ( isset( $params['id'] ) ) {
-                       $id = $params['id'];
-               }
+
                if ( isset( $params['forcemathmode'] ) ) {
                        $mode = $params['forcemathmode'];
                }
diff --git a/tests/MathIdTest.php b/tests/MathIdTest.php
new file mode 100644
index 0000000..c7c5719
--- /dev/null
+++ b/tests/MathIdTest.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Test the Id feature
+ * @group Math
+ */
+class MathIdTest extends MediaWikiTestCase {
+
+       /**
+        * Checks if the id specified as attribute is set in the renderer object
+        */
+       public function testBasics() {
+               define( 'RANDOM_ID', 'a_random_id' );
+               $renderer = MathRenderer::getRenderer( "a+b", array( 'id' => 
RANDOM_ID ) );
+               $this->assertEquals( RANDOM_ID, $renderer->getId() );
+       }
+
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/148535
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6f2671a322f637a1d8e0c88833ce4456d188829b
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Frédéric Wang <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to