Physikerwelt has uploaded a new change for review.

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

Change subject: Remove deprecated DB2 and XQuery support
......................................................................

Remove deprecated DB2 and XQuery support

* README is completely outdated

Change-Id: If1677c5ec94cfb0b2e6112c1d088963de8910c0f
---
M MathSearch.php
D MathSearchApi.php
D README
D XQueryGenerator.php
D XQueryGeneratorBaseX.php
D XQueryGeneratorDB2.php
D includes/engines/MathEngineDB2.php
D tests/BaseXSimpleTest.php
D tests/MathDB2ConnectionTest.php
M tests/MathEngineTest.php
D tests/MathXQueryTest.php
11 files changed, 0 insertions(+), 863 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/03/193103/1

diff --git a/MathSearch.php b/MathSearch.php
index 4f5e683..8db6a09 100644
--- a/MathSearch.php
+++ b/MathSearch.php
@@ -26,8 +26,6 @@
        'descriptionmsg' => 'mathsearch-desc',
        'version' => '0.2.0',
 );
-/** @var String the IBM DB connection string*/
-$wgMathSearchDB2ConnStr = false;
 /** @var String URL of MathWebSearch instance */
 $wgMathSearchMWSUrl = 'http://localhost:9090/';
 /** @var boolean if true the observation is updated everytime the SpecialPage 
formulainfo is shown. */
@@ -42,18 +40,13 @@
 $wgAutoloadClasses['FormulaInfo'] = $dir . 'FormulaInfo.php';
 $wgAutoloadClasses['MathObject'] = $dir . 'MathObject.php';
 $wgAutoloadClasses['MathQueryObject'] = $dir . 'MathQueryObject.php';
-$wgAutoloadClasses['XQueryGenerator'] = $dir . 'XQueryGenerator.php';
-$wgAutoloadClasses['XQueryGeneratorDB2'] = $dir . 'XQueryGeneratorDB2.php';
-$wgAutoloadClasses['XQueryGeneratorBaseX'] = $dir . 'XQueryGeneratorBaseX.php';
 $wgAutoloadClasses['GetEquationsByQuery'] = $dir . 'GetEquationsByQuery.php';
 $wgAutoloadClasses['SpecialMathDebug'] = $dir . 'SpecialMathDebug.php';
 $wgAutoloadClasses['SpecialMathIndex'] = $dir . 'SpecialMathIndex.php';
 $wgAutoloadClasses['SpecialDisplayTopics'] = $dir . 
'/includes/special/SpecialDisplayTopics.php';
 $wgAutoloadClasses['MathEngineMws'] = $dir . 
'/includes/engines/MathEngineMws.php';
-$wgAutoloadClasses['MathEngineDB2'] = $dir . 
'/includes/engines/MathEngineDB2.php';
 $wgAutoloadClasses['MathEngineBaseX'] = $dir . 
'/includes/engines/MathEngineBaseX.php';
 $wgAutoloadClasses['MathEngineRest'] = $dir . 
'/includes/engines/MathEngineRest.php';
-$wgAutoloadClasses['MathSearchApi'] = $dir . 'MathSearchApi.php';
 $wgAutoloadClasses['ImportCsv'] = $dir . 'includes/ImportCsv.php';
 $wgAutoloadClasses['MathSearchUtils'] = $dir . 'includes/MathSearchUtils.php';
 
@@ -82,8 +75,6 @@
 $wgHooks['MathFormulaRendered']['addLink'] = 
'MathSearchHooks::addLinkToFormulaInfoPage';
 $wgHooks['UnitTestsList'][] = 'MathSearchHooks::onRegisterUnitTests';
 $wgHooks['ParserFirstCallInit'][] = 'MathSearchHooks::onParserFirstCallInit';
-
-$wgMathSearchDB2Table = 'math';
 
 $wgMathSearchBaseXBackendUrl = 'http://localhost:10043/mwsquery';
 
diff --git a/MathSearchApi.php b/MathSearchApi.php
deleted file mode 100644
index 3fb1350..0000000
--- a/MathSearchApi.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Moritz
- * Date: 13.05.14
- * Time: 21:33
- */
-class MathSearchApi extends ApiBase {
-       public function execute() {
-               $mathPattern = $this->getMain()->getVal('mathpattern');
-               $mathEngine = $this->getMain()->getVal('mathengine');
-               $query = new MathQueryObject( $mathPattern );
-               switch ( $mathEngine ){
-                       case 'db2':
-                               $query->setXQueryDialect( 'db2' );
-                               break;
-                       case 'basex':
-                               $query->setXQueryDialect( 'basex' );
-               }
-               //$cQuery = $query->getCQuery();
-                       $this->getResult()->addValue( null, 'xquery', array ( 
'dialect' => $mathEngine ,
-                       'xQuery'=>$query->getXQuery()) );
-       }
-
-       // Description
-       public function getDescription() {
-               return 'Convert mathpattern to xquery';
-       }
-
-       // Describe the parameter
-       public function getParamDescription() {
-               return array_merge( parent::getParamDescription(), array(
-                       'mathpattern' => 'mathpattern',
-                       'mathengine' => 'xquery dialect'
-               ) );
-       }
-
-       // Get examples
-       public function getExamples() {
-               return array(
-                       
'api.php?action=mathquery&mathpattern=\sin(?x^2)&mathengine=basex'
-                       => 'Generate the XQueryExpression for fquery 
$\sin(?x^2)$ in BaseX dialect.'
-               );
-       }
-}
\ No newline at end of file
diff --git a/README b/README
deleted file mode 100644
index 12fab4b..0000000
--- a/README
+++ /dev/null
@@ -1,14 +0,0 @@
-Requires:
--MWSearch
--MathWebSearch
-
-For the XQueryGenerator you need to install
-zorba to
-http://zorbawebsite2.my28msec.com/html/documentation/2.8.0/zorba/php_ubuntu_tutorial
-so that XQueryProcessor.php is located in the subdirectory
-'modules/Zorba/XQueryProcessor.php'
-
-To install baseX run
-
-sudo apt-get install basex
-
diff --git a/XQueryGenerator.php b/XQueryGenerator.php
deleted file mode 100644
index d829e9c..0000000
--- a/XQueryGenerator.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-
-/**
- * MediaWiki MathSearch extension
- *
- * (c) 2012 Moritz Schubotz
- * GPLv2 license; info in main package.
- *
- * 2012/04/25 Changed LaTeXML for the MathML rendering which is passed to 
MathJAX
- * @file
- * @ingroup extensions
- */
-abstract class XQueryGenerator {
-
-       private $qvar = array();
-       private $relativeXPath = '';
-       private $lengthConstraint = '';
-       /** @var DOMDocument the MWS XML */
-       private $xml ;
-
-       /**
-        *
-        * @param String $cmmlQueryString that contains the MathML query 
expression
-        */
-       public function __construct( $cmmlQueryString ){
-               $this->xml = new DOMDocument();
-               $this->xml->preserveWhiteSpace = false;
-               $this->xml->loadXML($cmmlQueryString);
-       }
-
-       /**
-        * @return String the XQueryExpression.
-        */
-       public function getXQuery()
-       {
-               $fixedConstraints = 
$this->generateConstraint($this->xml->getElementsByTagName('expr')->item(0), 
true);
-               $qvarConstraintString = '';
-               foreach ($this->qvar as $key => $value) {
-                       $addstr = '';
-                       $newContent = false;
-                       if (sizeof($value) > 1) {
-                               $first = $value[0];
-                               if ($qvarConstraintString) {
-                                       $addstr .= "\n  and ";
-                               }
-                               $lastSecond = '';
-                               foreach ($value as $second) {
-                                       if ($second != $first) {
-                                               if ($lastSecond) {
-                                                       $addstr .= ' and ';
-                                               }
-                                               $addstr .= '$x' . $first . ' = 
$x' . $second;
-                                               $lastSecond = $second;
-                                               $newContent = true;
-                                       }
-                               }
-                       }
-                       if ( $newContent ){
-                               $qvarConstraintString .= $addstr;
-                       }
-               }
-               $query = 'for $x in $m//*:' .
-                       
$this->xml->getElementsByTagName('expr')->item(0)->firstChild->localName . 
PHP_EOL .
-                       $fixedConstraints . PHP_EOL .
-                       ' where' . PHP_EOL .
-                       $this->lengthConstraint .
-                       ((( $qvarConstraintString && $this->lengthConstraint) ? 
' and '  : '')) .
-                       $qvarConstraintString . PHP_EOL .
-                       ' return' . PHP_EOL;
-               return $this->getHeader() . $query . $this->getFooter();
-       }
-       /**
-        *
-        * @param DOMNode $node
-        * @return string
-        */
-       private function generateConstraint($node, $isRoot=false) {
-               $i = 0;
-               $out = "";
-               $hastext = false;
-               foreach ($node->childNodes as $child) {
-                       if ($child->nodeName == "mws:qvar") {
-                               $i++;
-                               $qvarname = (string) $child->textContent;
-                               if (array_key_exists($qvarname, $this->qvar)) {
-                                       $this->qvar[$qvarname][] = 
$this->relativeXPath . "/*[" . $i . "]";
-                               } else {
-                                       $this->qvar[$qvarname] = 
array($this->relativeXPath . "/*[" . $i . "]");
-                               }
-                       } else {
-                               if ($child->nodeType == XML_ELEMENT_NODE) {
-                                       $i++;
-                                       //$out .= './text() = 
\''.$node->nodeValue . '\'';
-                                       if ($hastext) {
-                                               $out .= ' and ';
-                                       }
-                                       if(!$isRoot){
-                                               $out .= '*[' . $i . ']/name() 
=\'' . $child->localName . '\'';
-                                       }
-                                       $hastext = true;
-                                       if ( $child->hasChildNodes() ) {
-                                               if(!$isRoot){
-                                                       
$this->relativeXPath.="/*[" . $i . "]";
-                                                       $out .= ' and *[' . $i 
. "]";
-                                               }
-                                               $out .= 
'['.$this->generateConstraint($child) .']';
-                                       }
-                               } elseif( $child->nodeType == XML_TEXT_NODE  ){
-                                       $out .= './text() = \''. 
$child->nodeValue. '\'';
-                               }
-                       }
-               }
-               if(  !$isRoot ){
-                       if($this->lengthConstraint == ''){
-                               $this->lengthConstraint .='fn:count($x' . 
$this->relativeXPath . '/*) = ' . $i  . "\n";
-                       }else{
-                               $this->lengthConstraint .=' and fn:count($x' . 
$this->relativeXPath . '/*) = ' . $i  . "\n";
-                       }
-               }
-               if ($this->relativeXPath) {
-                       $this->relativeXPath = substr($this->relativeXPath, 0, 
strrpos($this->relativeXPath, "/"));
-               }
-               /*if ($out != ""){
-                       $out = '['. $out . ']';
-               }*/
-
-
-               return $out;
-       }
-       private function hasChild($p) {
-               if ($p->hasChildNodes()) {
-                       foreach ($p->childNodes as $c) {
-                               if ($c->nodeType == XML_ELEMENT_NODE)
-                                       return true;
-                       }
-               }
-               return false;
-       }
-       abstract protected function getHeader();
-       abstract protected function getFooter();
-}
diff --git a/XQueryGeneratorBaseX.php b/XQueryGeneratorBaseX.php
deleted file mode 100644
index cfe755a..0000000
--- a/XQueryGeneratorBaseX.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * MediaWiki MathSearch extension
- *
- * (c) 2014 Moritz Schubotz
- * GPLv2 license; info in main package.
- * 
- * @file
- * @ingroup extensions
- */
-class XQueryGeneratorBaseX extends XQueryGenerator {
-       /**
-        * 
-        * @return string
-        */
-       protected function getHeader(){
-               return 'declare default element namespace 
"http://www.w3.org/1998/Math/MathML";;
-for $m in //*:expr return
-';
-       }
-
-       /**
-        * 
-        * @return string
-        */
-       protected function getFooter(){
-               return ' <a 
href="http://demo.formulasearchengine.com/index.php?curid={$m/@url}";>result</a>';
-       }
-}
\ No newline at end of file
diff --git a/XQueryGeneratorDB2.php b/XQueryGeneratorDB2.php
deleted file mode 100644
index b5fd847..0000000
--- a/XQueryGeneratorDB2.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * MediaWiki MathSearch extension
- *
- * (c) 2014 Moritz Schubotz
- * GPLv2 license; info in main package.
- * 
- * @file
- * @ingroup extensions
- */
-class XQueryGeneratorDB2 extends XQueryGenerator {
-       /**
-        * 
-        * @global type $wgMathSearchDB2Table
-        * @return string
-        */
-       protected function getHeader(){
-               global $wgMathSearchDB2Table;
-               return 'xquery declare default element namespace 
"http://www.w3.org/1998/Math/MathML";;'.
-                       "\n for \$m in 
db2-fn:xmlcolumn(\"$wgMathSearchDB2Table.math_mathml\") return\n";
-       }
-
-       /**
-        * 
-        * @return string
-        */
-       protected function getFooter(){
-               return 'data($m/*[1]/@alttext)';
-       }
-}
\ No newline at end of file
diff --git a/includes/engines/MathEngineDB2.php 
b/includes/engines/MathEngineDB2.php
deleted file mode 100644
index 3a96854..0000000
--- a/includes/engines/MathEngineDB2.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-
-/**
- * MediaWiki MathSearch extension
- *
- * (c) 2014 Moritz Schubotz
- * GPLv2 license; info in main package.
- *
- * @file
- * @ingroup extensions
- */
-class MathEngineDB2 {
-       /** @var MathQueryObject the query to be answered*/
-       protected $query;
-       protected $size = false;
-       protected $resultSet;
-       protected $relevanceMap;
-
-    /**
-        * 
-        * @return MathQueryObject
-        */
-       public function getQuery() {
-               return $this->query;
-       }
-
-       function __construct(MathQueryObject $query) {
-               $this->query = $query;
-       }
-       public function getSize() {
-               return $this->size;
-       }
-
-       public function getResultSet() {
-               return $this->resultSet;
-       }
-
-       public function getRelevanceMap() {
-               return $this->relevanceMap;
-       }
-
-               /**
-        * 
-        * @param MathQueryObject $query
-        * @return \MathSearchEngine
-        */
-       public function setQuery(MathQueryObject $query) {
-               $this->query = $query;
-               return $this;
-       }
-
-
-    /**
-     *
-     * @param XQueryGenartorDB2 $query
-     * @return \DB2
-     */
-    public function setDBQuery(XQueryGeneratorDB2 $query){
-        $this->query = $query;
-        return $this;
-    }
-
-
-
-
-               /**
-        * Posts the query to mwsd and evaluates the result data
-        * @return boolean
-        */
-       function postQuery() {
-
-        global $wgMathSearchMWSUrl, $wgMathDebug;
-               global $wgMathSearchDB2ConnStr;
-               if ( ! MathSearchHooks::isDB2Supported() ) {
-                       throw new MWException( 'DB2 php client is not 
installed.' );
-               }
-               $conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
-               $stmt = db2_exec($conn, $this->query->getXQuery() );
-
-               $this->size = db2_num_rows ( $stmt );
-               wfDebugLog( "MathSearch", $this->size . " results retrieved 
from $wgMathSearchMWSUrl." );
-               if ($this->size ==-1) {
-                       return true;
-               }
-
-               $this->relevanceMap = array();
-               $this->resultSet = array();
-
-               $texResults = array();
-               $moArray = array();
-               while($row = db2_fetch_row( $stmt ) ){
-                       //FIXME: tex is not a really good key for lookup change 
to the md5 inputhash
-                       // than use $mo = MathObject::newFromMd5($theMD5) to 
get the MathObject
-                       $tex =   db2_result( $stmt, 0 );
-                       $tex = str_replace( '<?xml version="1.0" 
encoding="UTF-8" ?>' , '' , $tex );
-                       $texResults[] = $tex;
-
-
-                       $mo = new MathObject($tex);
-            //$md = MathObject::newFromMd5($tex);
-                       $mo->readFromDatabase();
-
-                       $all  = $mo->getAllOccurences();
-
-                       array_push($moArray, $all);
-               }
-               //@var $mo MathObject
-               foreach ($moArray as $mo) {
-
-           $this->relevanceMap[$mo->getPageID()]=true;
-                       //$this->resultSet[(string) $mo->getPageID()][(string) 
$mo->getAnchorID()][] = array( "xpath" => '/', "mappings" => array() ); // 
,"original"=>$page->asXML()
-               }
-
-               //$this->processMathResults( $xres );
-               return true;
-
-       }
-}
\ No newline at end of file
diff --git a/tests/BaseXSimpleTest.php b/tests/BaseXSimpleTest.php
deleted file mode 100644
index 5ae4d15..0000000
--- a/tests/BaseXSimpleTest.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * Test the db2 access of  MathSearch.
- *
- * @group MathSearch
- * @group Database
- */
-class BaseXSimpleTest extends MediaWikiTestCase {
-       private $phpErrorLevel = -1;
-
-       protected function setUp(){
-               global $wgMathSearchBaseXSupport;
-               if ( ! $wgMathSearchBaseXSupport ) {
-                       $this->markTestSkipped( 'This server does not support 
baseX.' );
-               }
-               $this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
-               parent::setUp();
-       }
-
-       public function  testCreateDB(){
-               $session = new BaseXSession();
-               $this->assertType("null", $session->info() ,"");
-               $session->execute("create db MathSearchUnitTest <root><user>
-  <username>Username1</username><password>Password1</password>
-  
</user><user><username>Username2</username><password>Password2</password></user></root>");
-               $this->assertContains('created in',$session->info());
-               $session->close();
-       }
-
-       public function  testReadFromDB(){
-               $session = new BaseXSession();
-               $session->execute("open MathSearchUnitTest");
-               $this->assertContains('opened in',$session->info());
-               $res = $session->execute("xquery .");
-               $this->assertContains('Username2',$res);
-               $session->close();
-       }
-}
\ No newline at end of file
diff --git a/tests/MathDB2ConnectionTest.php b/tests/MathDB2ConnectionTest.php
deleted file mode 100644
index 2f0666d..0000000
--- a/tests/MathDB2ConnectionTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-/**
- * Test the db2 access of  MathSearch.
- *
- * @group MathSearch
- * @group Database
- */
-class MathD2ConnectionTest extends MediaWikiTestCase {
-       private $phpErrorLevel = -1;
-       protected function setUp(){
-               if ( ! MathSearchHooks::isDB2Supported() ) {
-                       $this->markTestSkipped( 'DB2 php client is not 
installed.' );
-               }
-               $this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
-               parent::setUp();
-       }
-       protected function tearDown(){
-               ini_set( 'error_reporting', $this->phpErrorLevel );
-       }
-       public function testConnect() {
-               global $wgMathSearchDB2ConnStr;
-               if ( $wgMathSearchDB2ConnStr !== false ) {
-
-                       $conn = db2_connect( $wgMathSearchDB2ConnStr, '', '' );
-                       $this->assertInternalType( 'resource', $conn, 
'Connection failed.' );
-                       db2_close( $conn );
-               } else {
-                       $message = <<<'EOT'
-Add something like that to LocalSettings.php
-$database = 'SAMPLE';
-$user = 'db2inst1';
-$password = 'ibmdb2';
-$hostname = 'localhost';
-$port = 50000;
-$wgMathSearchDB2ConnStr = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
-  "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
-EOT;
-                       echo $message;
-               }
-       }
-
-       public function testBasicSQL(){
-               global $wgMathSearchDB2ConnStr;
-               $conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
-               $stmt = db2_exec($conn,'select "math_tex" from "math"');
-               $this->assertInternalType( 'resource', $stmt, 'Connection 
failed.' );
-               /*while($row = db2_fetch_object($stmt)){
-                       printf("$row->math_tex\n");
-               }*/
-       }
-       private $testquery = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:ci
-[./text() = 'E']
- where
-fn:count($x/*) = 0
-
- return
-data($m/*[1]/@alttext)
-EOT;
-       public  function testBasicXQuery(){
-               global $wgMathSearchDB2ConnStr;
-               if ( ! MathSearchHooks::isDB2Supported() ) {
-                       $this->markTestSkipped( 'DB2 php client is not 
installed.' );
-               }
-               $conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
-               $stmt = db2_exec($conn,$this->testquery);
-               $row = db2_fetch_row($stmt);
-               $this->assertEquals('<?xml version="1.0" encoding="UTF-8" 
?>{\displaystyle E=mc^{2}}', db2_result($stmt,0));
-
-       }
-}
\ No newline at end of file
diff --git a/tests/MathEngineTest.php b/tests/MathEngineTest.php
index 7c72f70..f8759df 100644
--- a/tests/MathEngineTest.php
+++ b/tests/MathEngineTest.php
@@ -6,85 +6,6 @@
 
 class MathEngineTest extends MediaWikiTestCase {
 
-
-
-       private $stmt= <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:apply
-[*[1]/name() ='eq' and *[2]/name() ='ci' and *[2][./text() = 'E'] and 
*[3]/name() ='apply' and *[3][*[1]/name() ='times' and *[2]/name() ='ci' and 
*[2][./text() = 'm'] and *[3]/name() ='apply' and *[3][*[1]/name() ='csymbol' 
and *[1][./text() = 'superscript'] and *[2]/name() ='ci' and *[2][./text() = 
'c'] and *[3]/name() ='cn' and *[3][./text() = '2']]]]
- where
-fn:count($x/*[2]/*) = 0
- and fn:count($x/*[3]/*[2]/*) = 0
- and fn:count($x/*[3]/*[3]/*[1]/*) = 0
- and fn:count($x/*[3]/*[3]/*[2]/*) = 0
- and fn:count($x/*[3]/*[3]/*[3]/*) = 0
- and fn:count($x/*[3]/*[3]/*) = 3
- and fn:count($x/*[3]/*) = 3
- and fn:count($x/*) = 3
-
- return
-data($m/*[1]/@alttext)
-EOT;
-
-       private $stmt2= <<<'EOT'
-<?xml version="1.0"?>
-    <mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-        <mws:expr>
-            <m:apply xml:id="p1.1.m1.1.6.cmml" xref="p1.1.m1.1.6">
-                <m:eq xml:id="p1.1.m1.1.2.cmml" xref="p1.1.m1.1.2"/>
-                <m:ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">E</m:ci>
-                <m:apply xml:id="p1.1.m1.1.6.1.cmml" xref="p1.1.m1.1.6.1">
-                    <m:times xml:id="p1.1.m1.1.6.1.1.cmml" 
xref="p1.1.m1.1.6.1.1"/>
-                    <m:ci xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">m</m:ci>
-                    <m:apply xml:id="p1.1.m1.1.6.1.2.cmml" 
xref="p1.1.m1.1.6.1.2">
-                        <m:csymbol cd="ambiguous" 
xml:id="p1.1.m1.1.6.1.2.1.cmml">superscript</m:csymbol>
-                        <m:ci xml:id="p1.1.m1.1.4.cmml" 
xref="p1.1.m1.1.4">c</m:ci>
-                        <m:cn type="integer" xml:id="p1.1.m1.1.5.1.cmml" 
xref="p1.1.m1.1.5.1">2</m:cn>
-                    </m:apply>
-                </m:apply>
-            </m:apply>
-        </mws:expr>
-    </mws:query>
-EOT;
-
-
-       private $sel = "SELECT
-        `mathindex`.`mathindex_revision_id` AS `mathindex_revision_id`,
-        `mathindex`.`mathindex_anchor` AS `mathindex_anchor`,
-        `mathindex`.`mathindex_inputhash` AS `mathindex_inputhash`,
-        `mathindex`.`mathindex_timestamp` AS `mathindex_timestamp`,
-        `math`.`math_inputhash` AS `math_inputhash`,
-        `math`.`math_mathml` AS `math_mathml`,
-        `math`.`math_outputhash` AS `math_outputhash`,
-        `math`.`math_html_conservativeness` AS `math_html_conservativeness`,
-        `math`.`math_html` AS `math_html`
-        FROM (`mathindex` JOIN `math` ON((`mathindex`.`mathindex_revision_id` 
= `mathindex`.`mathindex_anchor`)))";
-
-
-
-
-
-       protected function setUp(){
-               if ( ! MathSearchHooks::isDB2Supported() ) {
-                       $this->markTestSkipped( 'DB2 php client is not 
installed.' );
-               }
-               parent::setUp();
-               $this->getTestResultObject()->setTimeoutForLargeTests(60);
-       }
-
-       /**
-        *
-        */
-       public function testDirectDB2Query(){
-               global $wgMathSearchDB2ConnStr;
-               $conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
-
-               $stmt = db2_exec($conn, $this->stmt );
-               $this->assertEquals(1, db2_num_fields ( $stmt ) );
-               db2_close( $conn );
-       }
-
        public function testHash(){
                $test_tex = 'E=mc^2';
                $test_hash = '826676a6a5ad24552f0d5af1593434cc';
@@ -92,111 +13,5 @@
                $realHash = $renderer->getMd5();
                $this->assertEquals($realHash,$test_hash,'wrong hash');
        }
-       public function testGetAllOcc(){
-               global $wgMathSearchDB2ConnStr;
-               $conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
-               $stmt = db2_exec($conn, $this->stmt );
-               $hash = '826676a6a5ad24552f0d5af1593434cc';
-
-               $moArray=array();
-               while($row = db2_fetch_row( $stmt ) ){
-                       $tex =   db2_result( $stmt, 0 );
-                       $tex = str_replace( '<?xml version="1.0" 
encoding="UTF-8" ?>' , '' , $tex );
-                       $this->assertEquals($tex, '{\displaystyle E=mc^{2}}');
-
-
-
-                       $mo = MathObject::newFromMd5($hash);
-
-                       $rFD = $mo->readFromDatabase();
-                       $this->assertTrue( $rFD, 'readFromDatabase() was not 
successful');
-
-
-                       //create the MathObject out of the tex
-                       /*
-                               $mo = new MathObject($tex);
-                               $test= $mo->readFromDatabase();
-                               
$this->assertEquals($test,true,'readFromDatabase() was not successful');
-                               */
-
-
-
-                       $all  = $mo->getAllOccurences( false );
-                       $this->assertType( 'array', $all, 'getAllOccurences() 
return false');
-
-                       array_push($moArray, $all);
-
-               }
-               //Fixme: Test the content of $moArray
-               //$this->assertEquals('content', $moArray[0]);
-       }
-
-
-       /**
-        * Function to test the class MathEngineDB2
-        * @Large
-        */
-       public function testMathEngineDB2(){
-               $query = new XQueryGeneratorDB2($this->stmt2);
-               $this->assertEquals($this->stmt, $query->getXQuery() , "XQuery 
expression did not match");
-               $qo = new MathQueryObject();
-               $qo->setXQueryGenerator($query);
-               $eng = new MathEngineDB2($qo);
-               //$this->assertEquals($query,$eng->getQuery()->getXQuery());
-               $this->assertEquals($qo, $eng->getQuery() , "XQuery expression 
did not match");
-               //$eng->postQuery();
-
-
-               /*
-                * Fixme: If everything is fine until here try this:
-                *
-                               $map = $eng->getRelevanceMap();
-
-                               $this->assertTrue($map[1]);
-                               $this->asserFalse($map[2]);
-               */
-
-       }
-
-
-
-       /**
-        * Function to test the join of math and mathindex from MySQL
-        * @TODO: I think we don't need that test.
-        * @markTestSkipped
-        */
-       public function testJoin(){
-               $this->markTestSkipped('Skipping test');
-
-               $con = mysqli_connect('localhost','root','vagrant','wiki', 
3306);
-
-               // Check connection
-               if (mysqli_connect_errno()) {
-                       echo "Failed to connect to MySQL:". 
mysqli_connect_error();
-               }
-
-               $result = mysqli_query($con, $this->sel);
-
-               // Check result from query
-               if($result == false){
-                       echo "Failed to execute query!";
-               }
-
-               while($row = mysqli_fetch_array($result)){
-                       $this->assertEquals($row['mathindex_revision_id'], 1);
-                       //echo $row['mathindex_revision_id'] . " " . 
$row['mathindex_anchor'] . " " . $row['math_html_conservativeness']. "\n";
-               }
-
-               mysqli_close($con);
-
-
-       }
-
-
-
-
-
-
-
 
 }
\ No newline at end of file
diff --git a/tests/MathXQueryTest.php b/tests/MathXQueryTest.php
deleted file mode 100644
index b969c0c..0000000
--- a/tests/MathXQueryTest.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<?php
-
-/**
- * Test the db2 access of  MathSearch.
- *
- * @group MathSearch
- * @group Database
- */
-class MathXQueryTest extends MediaWikiTestCase {
-
-       private $q1 = <<<'EOT'
-<?xml version="1.0"?>
-<mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-       <mws:expr>
-               <m:ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">E</m:ci>
-       </mws:expr>
-</mws:query>
-EOT;
-
-       private $q2 = <<<'EOT'
-<?xml version="1.0"?>
-<mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-  <mws:expr>
-    <m:apply xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">
-      <m:csymbol cd="ambiguous" 
xml:id="p1.1.m1.1.3.1.cmml">superscript</m:csymbol>
-      <m:ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">c</m:ci>
-      <m:cn type="integer" xml:id="p1.1.m1.1.2.1.cmml" 
xref="p1.1.m1.1.2.1">2</m:cn>
-    </m:apply>
-  </mws:expr>
-</mws:query>
-EOT;
-
-       private $q3 = <<<'EOT'
-<?xml version="1.0"?>
-<mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-  <mws:expr>
-    <m:apply xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">
-      <m:sin xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1"/>
-      <m:ci xml:id="p1.1.m1.1.2.cmml" xref="p1.1.m1.1.2">x</m:ci>
-    </m:apply>
-  </mws:expr>
-</mws:query>
-EOT;
-       private $qqx2 = <<<'EOT'
-<?xml version="1.0"?>
-<mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-  <mws:expr>
-    <m:apply xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">
-      <m:csymbol cd="ambiguous" 
xml:id="p1.1.m1.1.3.1.cmml">superscript</m:csymbol>
-      <mws:qvar>x</mws:qvar>
-      <m:cn type="integer" xml:id="p1.1.m1.1.2.1.cmml" 
xref="p1.1.m1.1.2.1">2</m:cn>
-    </m:apply>
-  </mws:expr>
-</mws:query>
-EOT;
-       private $qqx2x = <<<'EOT'
-<?xml version="1.0"?>
-<mws:query xmlns:mws="http://search.mathweb.org/ns"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; limitmin="0" answsize="30">
-  <mws:expr>
-    <m:apply xml:id="p1.1.m1.1.5.cmml" xref="p1.1.m1.1.5">
-      <m:plus xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3"/>
-      <m:apply xml:id="p1.1.m1.1.5.1.cmml" xref="p1.1.m1.1.5.1">
-        <m:csymbol cd="ambiguous" 
xml:id="p1.1.m1.1.5.1.1.cmml">superscript</m:csymbol>
-        <mws:qvar>x</mws:qvar>
-        <m:cn type="integer" xml:id="p1.1.m1.1.2.1.cmml" 
xref="p1.1.m1.1.2.1">2</m:cn>
-      </m:apply>
-      <mws:qvar>x</mws:qvar>
-    </m:apply>
-  </mws:expr>
-</mws:query>
-EOT;
-       private $r1 = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:ci
-[./text() = 'E']
- where
-fn:count($x/*) = 0
-
- return
-data($m/*[1]/@alttext)
-EOT;
-
-       private $r2 = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:apply
-[*[1]/name() ='csymbol' and *[1][./text() = 'superscript'] and *[2]/name() 
='ci' and *[2][./text() = 'c'] and *[3]/name() ='cn' and *[3][./text() = '2']]
- where
-fn:count($x/*[1]/*) = 0
- and fn:count($x/*[2]/*) = 0
- and fn:count($x/*[3]/*) = 0
- and fn:count($x/*) = 3
-
- return
-data($m/*[1]/@alttext)
-EOT;
-
-       private $r3 = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:apply
-[*[1]/name() ='sin' and *[2]/name() ='ci' and *[2][./text() = 'x']]
- where
-fn:count($x/*[2]/*) = 0
- and fn:count($x/*) = 2
-
- return
-data($m/*[1]/@alttext)
-EOT;
-
-
-       private $rqx2 = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:apply
-[*[1]/name() ='csymbol' and *[1][./text() = 'superscript'] and *[3]/name() 
='cn' and *[3][./text() = '2']]
- where
-fn:count($x/*[1]/*) = 0
- and fn:count($x/*[3]/*) = 0
- and fn:count($x/*) = 3
-
- return
-data($m/*[1]/@alttext)
-EOT;
-       private $rqx2x = <<<'EOT'
-xquery declare default element namespace "http://www.w3.org/1998/Math/MathML";;
- for $m in db2-fn:xmlcolumn("math.math_mathml") return
-for $x in $m//*:apply
-[*[1]/name() ='plus' and *[2]/name() ='apply' and *[2][*[1]/name() ='csymbol' 
and *[1][./text() = 'superscript'] and *[3]/name() ='cn' and *[3][./text() = 
'2']]]
- where
-fn:count($x/*[2]/*[1]/*) = 0
- and fn:count($x/*[2]/*[3]/*) = 0
- and fn:count($x/*[2]/*) = 3
- and fn:count($x/*) = 3
- and $x/*[2]/*[2] = $x/*[3]
- return
-data($m/*[1]/@alttext)
-EOT;
-
-       /**
-        * Searches for $E$
-        */
-       public function testE() {
-               $xQuery = new XQueryGeneratorDB2( $this->q1 );
-               $this->assertEquals( $this->r1, $xQuery->getXQuery() );
-       }
-
-       /*
-        * Searches for $c^2$
-        */
-       public function testc2() {
-               $xQuery = new XQueryGeneratorDB2( $this->q2 );
-               $this->assertEquals( $this->r2, $xQuery->getXQuery() );
-       }
-
-       /*
-        * Searches for $\sin x$
-        */
-       public function testsinx() {
-               $xQuery = new XQueryGeneratorDB2( $this->q3 );
-               $this->assertEquals( $this->r3, $xQuery->getXQuery() );
-       }
-
-       /*
-        * Searches for $?x^2$
-        */
-       public function testx2() {
-               $xQuery = new XQueryGeneratorDB2( $this->qqx2 );
-               $this->assertEquals( $this->rqx2, $xQuery->getXQuery() );
-       }
-
-       /*
-        * Searches for $?x^2+?x$
-        */
-       public function testx2x() {
-               $xQuery = new XQueryGeneratorDB2( $this->qqx2x );
-               $this->assertEquals( $this->rqx2x, $xQuery->getXQuery() );
-       }
-}
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If1677c5ec94cfb0b2e6112c1d088963de8910c0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
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