Karima Rafes has submitted this change and it was merged. Change subject: Update for MediaWiki 1.22 and add basic test ......................................................................
Update for MediaWiki 1.22 and add basic test Change-Id: I0c05be587e9c458118eba9779e6573514a44e547 --- M LinkedWiki.php M specialpages/SpecialSparqlQuery.php A test/sparqlbasic.feature A test/step_definitions/sparql_steps.rb 4 files changed, 138 insertions(+), 10 deletions(-) Approvals: Karima Rafes: Verified; Looks good to me, approved diff --git a/LinkedWiki.php b/LinkedWiki.php index c6f955a..b2725d6 100644 --- a/LinkedWiki.php +++ b/LinkedWiki.php @@ -440,8 +440,8 @@ } function efSparqlParserFunction_footer($duration){ - $today = date(wfMsg('date')); - return $today ." -- [{{fullurl:{{FULLPAGENAME}}|action=purge}} ".wfMsg('refresh')."] -- ".wfMsg('durate')." :". round($duration, 3) ."s"; + $today = date(wfMessage( 'date' )->text()); + return $today ." -- [{{fullurl:{{FULLPAGENAME}}|action=purge}} ".wfMessage( 'refresh' )->text()."] -- ".wfMessage( 'durate' )->text()." :". round($duration, 3) ."s"; } function efSparqlParserFunction_uri2Link($uri,$nowiki = false){ diff --git a/specialpages/SpecialSparqlQuery.php b/specialpages/SpecialSparqlQuery.php index 108b52b..d9e4c1d 100644 --- a/specialpages/SpecialSparqlQuery.php +++ b/specialpages/SpecialSparqlQuery.php @@ -28,7 +28,8 @@ public function __construct() { parent::__construct( 'specialsparqlquery' ); - wfLoadExtensionMessages('specialsparqlquery'); + /** @noinspection PhpUndefinedFunctionInspection */ + //wfLoadExtensionMessages('specialsparqlquery'); } public function execute($par = null) { @@ -49,22 +50,22 @@ if ( $query != "" && $output == "save" && $titleRequest != "" ) { if($this->pageExists($titleRequest)){ - $wgOut->addHTML("<h2>".wfMsg('specialsparqlquery_error_title_exists_yet')."</h2> \n"); + $wgOut->addHTML("<h2>".wfMessage('specialsparqlquery_error_title_exists_yet')->text()."</h2> \n"); $wgOut->addHTML(); }else{ $this->savePage($titleRequest, $this->template($query,$description)); - $wgOut->addWikiText(wfMsg('specialsparqlquery_your_query_saved_here')."[[$titleRequest]]"); + $wgOut->addWikiText(wfMessage('specialsparqlquery_your_query_saved_here')->text()."[[$titleRequest]]"); } } if ( $query == "" || $output == "save" || $output == "wiki" ) { - $wgOut->addWikiText(wfMsg('specialsparqlquery_mainpage')); + $wgOut->addWikiText(wfMessage('specialsparqlquery_mainpage')->text()); $wgOut->addHTML("<pre>".htmlentities($this->prefix(), ENT_QUOTES, 'UTF-8')."</pre>"); $wgOut->addHTML("<form method='post' name='formQuery'>"); $wgOut->addHTML("<input type='hidden' name='output' value='wiki'>"); $wgOut->addHTML("<input type='hidden' name='prefix' value='".htmlentities($this->prefix(), ENT_QUOTES, 'UTF-8')." '>"); $wgOut->addHTML("<input type='hidden' name='query' >"); - $wgOut->addHTML(wfMsg('specialsparqlquery_endpointsparql')." : <input type='text' name='endpoint' size='50' value='".$endpoint." '>"); + $wgOut->addHTML(wfMessage('specialsparqlquery_endpointsparql')->text()." : <input type='text' name='endpoint' size='50' value='".$endpoint." '>"); $wgOut->addHTML("<textarea name='queryWithoutPrefix' cols='25' rows='15'>"); $strQuery = $queryWithoutPrefix != "" ? $queryWithoutPrefix : $this->exampleSparql(0) ; $wgOut->addHTML($strQuery); @@ -89,7 +90,7 @@ } //--> </SCRIPT>"); - $wgOut->addHTML("<input type='button' value='".wfMsg('specialsparqlquery_sendquery')."' onClick='validAndSendQuery();' />"); + $wgOut->addHTML("<input type='button' value='".wfMessage('specialsparqlquery_sendquery')->text()."' onClick='validAndSendQuery();' />"); $wgOut->addHTML("<input type='button' value='(R&D) Validation (js)' onClick='validWithJS();' />"); $wgOut->addHTML(" Xml : <input type='checkbox' name='toXML' />"); $wgOut->addHTML(" </form>"); @@ -123,8 +124,8 @@ $arr = efSparqlParserFunction_simple( $query, $endpoint, '', '', null ); $wgOut->addWikiText($arr[0]); - $wgOut->addWikiText("==".wfMsg('specialsparqlquery_usethisquery')."=="); - $wgOut->addWikiText(wfMsg('specialsparqlquery_usethisquery_tutorial')); + $wgOut->addWikiText("==".wfMessage('specialsparqlquery_usethisquery')->text()."=="); + $wgOut->addWikiText(wfMessage('specialsparqlquery_usethisquery_tutorial')->text()); $wgOut->addHTML("<pre>{{#sparql:".htmlentities($query, ENT_QUOTES, 'UTF-8')."\n|endpoint=".htmlentities($endpoint, ENT_QUOTES, 'UTF-8')."}}</pre>"); } diff --git a/test/sparqlbasic.feature b/test/sparqlbasic.feature new file mode 100644 index 0000000..76b6bdf --- /dev/null +++ b/test/sparqlbasic.feature @@ -0,0 +1,92 @@ +@login +Feature: client_sparql + + Background: + Given I am logged in + +#Check if the process work + Scenario:Go to page that does not exist + Given I am at page that does not exist + Then link Create should be there + +#Check if I can write in the wiki + Scenario: Start a new page using the URL + Given I am at page that does not exist + When I click link Create + And I enter article text + And I click Save page button + Then newly created page should open + And page title should be there + And page text should be there + +Scenario: Create a table + Given I am at page that does not exist + When I click link Create + And I enter the wikitext: + """ +{| class="wikitable sortable" +|- +!x!!y!!z +|- +|1||2||3 +|} + """ + And I click Save page button + Then newly created page should open + And table should be there: + | x | y | z | + | 1 | 2 | 3 | + +Scenario: Print a empty table with a query SPARQL + Given I am at page that does not exist + And I has a empty graph http://example.com/data in the triplestore http://192.168.1.100:8181 + When I click link Create + And I enter the wikitext: + """ +{{#sparql: +SELECT * WHERE { +GRAPH <http://example.com/data> +{ ?x ?y ?z . } +} +|endpoint=http://192.168.1.100:8181/sparql/ +}} + """ + And I click Save page button + Then newly created page should open + And LinkedWiki's table should be there: + | x | y | z | + +Scenario: Print a table with a query SPARQL + Given I am at page that does not exist + And I has a empty graph http://example.com/data in the triplestore http://192.168.1.100:8181 + And I do this SPARQL query in the triplestore http://192.168.1.100:8181: + """ +PREFIX dc: <http://purl.org/dc/elements/1.1/> +INSERT DATA +{ GRAPH <http://example.com/data> { + <http://example/book1> dc:title "Book 1" ; + dc:creator "A.N.Other1" . + <http://example/book2> dc:title "Book 2" ; + dc:creator "A.N.Other2" . +}} + """ + When I click link Create + And I enter the wikitext: + """ +{{#sparql: +PREFIX dc: <http://purl.org/dc/elements/1.1/> +SELECT ?title ?creator WHERE { +GRAPH <http://example.com/data> +{ ?x dc:title ?title ; + dc:creator ?creator . +} +} ORDER BY ?title ?creator +|endpoint=http://192.168.1.100:8181/sparql/ +}} + """ + And I click Save page button + Then newly created page should open + And LinkedWiki's table should be there: + | title | creator | + | Book 1 | A.N.Other1 | + | Book 2 | A.N.Other2 | diff --git a/test/step_definitions/sparql_steps.rb b/test/step_definitions/sparql_steps.rb new file mode 100644 index 0000000..64f17ad --- /dev/null +++ b/test/step_definitions/sparql_steps.rb @@ -0,0 +1,35 @@ +When(/^I enter the wikitext:$/) do |wikiText| + on(EditPage).article_text = wikiText +end + +Then(/^table should be there:$/) do |table| + nodesTR = Nokogiri::HTML(@browser.html).css(".wikitable tr") + tableResult = nodesTR.map {|tr| tr.css("th,td").map {|cell| cell.text.strip}} +# p tableResult +# p table.raw() + table.diff!(tableResult) +end + +Given /^I has a empty graph ([^ ]*) in the triplestore ([^ ]*)$/ do |graph,endpoint| + c = Curl::Easy.http_delete("#{endpoint}/data/?graph=#{graph}") + c.status.should match(/^.*200.*$/i) +end + +Then(/^LinkedWiki's table should be there:$/) do |table| + nodesTR = Nokogiri::HTML(@browser.html).css(".wikitable tr") + tableResult = nodesTR.map {|tr| tr.css("th,td").map {|cell| cell.text.strip}} + tableResult.delete(tableResult.last) +# p tableResult +# p table.raw() + table.diff!(tableResult) +end + +When(/^I do this SPARQL query in the triplestore ([^ ]*):$/) do |endpoint,query| + c = Curl::Easy.http_post("#{endpoint}/update/", + Curl::PostField.content('update', query)) + c.status.should match(/^.*200.*$/i) +end + + + + -- To view, visit https://gerrit.wikimedia.org/r/71180 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0c05be587e9c458118eba9779e6573514a44e547 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LinkedWiki Gerrit-Branch: master Gerrit-Owner: Karima Rafes <karima.ra...@gmail.com> Gerrit-Reviewer: Karima Rafes <karima.ra...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits