jenkins-bot has submitted this change and it was merged. Change subject: Test and bugfix of qvar (?x) support ......................................................................
Test and bugfix of qvar (?x) support * fix missing registration of phpunit tests Change-Id: I8d9a0a63418ef86ee6c7bbacbab157322d8bc731 --- M MathSearch.hooks.php M MathSearch.php M XQueryGenerator.php M tests/MathDB2ConnectionTest.php M tests/MathXQueryTest.php 5 files changed, 33 insertions(+), 16 deletions(-) Approvals: Physikerwelt: Looks good to me, approved jenkins-bot: Verified diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php index fb3b6c2..a59a40a 100644 --- a/MathSearch.hooks.php +++ b/MathSearch.hooks.php @@ -100,5 +100,15 @@ 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; + } } \ No newline at end of file diff --git a/MathSearch.php b/MathSearch.php index e2ea9e5..ede0ab2 100644 --- a/MathSearch.php +++ b/MathSearch.php @@ -63,6 +63,7 @@ $wgHooks['LoadExtensionSchemaUpdates'][] = 'MathSearchHooks::onLoadExtensionSchemaUpdates'; $wgHooks['MathFormulaRendered'][] = 'MathSearchHooks::onMathFormulaRendered'; +$wgHooks['UnitTestsList'][] = 'MathSearchHooks::onRegisterUnitTests'; $wgGroupPermissions['user']['MathDebug'] = true; diff --git a/XQueryGenerator.php b/XQueryGenerator.php index 47e21df..d829e9c 100644 --- a/XQueryGenerator.php +++ b/XQueryGenerator.php @@ -64,6 +64,7 @@ $fixedConstraints . PHP_EOL . ' where' . PHP_EOL . $this->lengthConstraint . + ((( $qvarConstraintString && $this->lengthConstraint) ? ' and ' : '')) . $qvarConstraintString . PHP_EOL . ' return' . PHP_EOL; return $this->getHeader() . $query . $this->getFooter(); diff --git a/tests/MathDB2ConnectionTest.php b/tests/MathDB2ConnectionTest.php index 5b93f05..4008ea9 100644 --- a/tests/MathDB2ConnectionTest.php +++ b/tests/MathDB2ConnectionTest.php @@ -29,4 +29,19 @@ echo $message; } } + public function testBasicXQuery(){ + global $wgMathSearchDB2ConnStr; + if ( ! MathSearchHooks::isDB2Supported() || true ) { + $this->markTestSkipped( 'DB2 php client is not installed.' ); + } + $conn = db2_connect($wgMathSearchDB2ConnStr, '', ''); + $stmt = db2_exec($conn,'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\'] return +data($m/*[1]/@alttext)'); + while($row = db2_fetch_row($stmt)){ + echo db2_result($stmt,0); + + } + } } \ No newline at end of file diff --git a/tests/MathXQueryTest.php b/tests/MathXQueryTest.php index 2ad0a0b..9609217 100644 --- a/tests/MathXQueryTest.php +++ b/tests/MathXQueryTest.php @@ -126,12 +126,13 @@ 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']] +[*[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/*[1]/*) = 0 - and fn:count($x/*[3]/*) = 0 +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; @@ -181,18 +182,7 @@ printf("$row->math_tex\n"); } } - public function testBasicXQuery(){ - global $wgMathSearchDB2ConnStr; - $conn = db2_connect($wgMathSearchDB2ConnStr, '', ''); - $stmt = db2_exec($conn,'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\'] return -data($m/*[1]/@alttext)'); - while($row = db2_fetch_row($stmt)){ - echo db2_result($stmt,0); - } - } -- To view, visit https://gerrit.wikimedia.org/r/115334 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8d9a0a63418ef86ee6c7bbacbab157322d8bc731 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits