Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/49401


Change subject: Adding phpunittest
......................................................................

Adding phpunittest

Add test cases for the MathSource class and
register hook for loading these tests.
Furthermore a hint
how to run the test cases was added to the readme file.

Change-Id: Ie58a273326e0353dfa4437b3de21a2393adb5a87
---
M Math.hooks.php
M README
A tests/MathSourceTest.php
3 files changed, 53 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/01/49401/1

diff --git a/Math.hooks.php b/Math.hooks.php
index ab61f10..a70da28 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -162,4 +162,16 @@
                $wgMathPath = '/images/math';
                return true;
        }
+
+       /**
+        * Links to the unit test files for the test cases.
+        *
+        * @param string $files
+        * @return boolean (true)
+        */
+       static function onRegisterUnitTests( &$files ) {
+               $testDir = __DIR__ . '/tests/';
+               $files = array_merge( $files, glob( "$testDir/*Test.php" ) );
+               return true;
+       }
 }
diff --git a/README b/README
index f7c6493..59fc505 100644
--- a/README
+++ b/README
@@ -1,9 +1,13 @@
-This version (for MediaWiki 1.19) has some changes since previous versions:
-
-* rendering options have been reduced to just 'Always PNG' and 'Leave it as 
TeX'
-** all other rendering options will merge to PNG.
-* initial experimental support for integrating MathJax client-side rendering
-
-See the README in the math subdirectory for more info on setting up the
-low-level conversion tools.
-
+This version (for MediaWiki 1.19) has some changes since previous versions:
+
+* rendering options have been reduced to just 'Always PNG' and 'Leave it as 
TeX'
+** all other rendering options will merge to PNG.
+* initial experimental support for integrating MathJax client-side rendering
+
+See the README in the math subdirectory for more info on setting up the
+low-level conversion tools.
+
+For testing your installation run
+php tests/phpunit/phpunit.php extensions/Math/tests/
+from your MediWiki home path.
+
diff --git a/tests/MathSourceTest.php b/tests/MathSourceTest.php
new file mode 100644
index 0000000..b74a7f8
--- /dev/null
+++ b/tests/MathSourceTest.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Test the TeX source output format.
+ * 
+ * @group Math
+ */
+class MathSourceTest extends MediaWikiTestCase {
+
+       /**
+        * Checks the basic functionallity
+        * i.e. if the span element is generated right.
+        */
+       public function simpleTest(){
+               $real=MathRenderer::renderMath("a+b",array(),MW_MATH_SOURCE);
+               $this->assertEquals('<span class="tex" dir="ltr">$ a+b 
$</span>', $real
+                       , "Rendering of a+b in plain Text mode");
+       }
+
+       /**
+        * Checks if newlines are converted to spaces correctly.
+        */
+       public function testNewLines(){
+               $real=MathRenderer::renderMath("a\n b",array(),MW_MATH_SOURCE);
+               $this->assertSame('<span class="tex" dir="ltr">$ a  b 
$</span>', $real
+                       , "converting newlines to spaces");
+       }
+
+}
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie58a273326e0353dfa4437b3de21a2393adb5a87
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

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

Reply via email to