<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://wiki.serverdev-mediawiki-v1/" />
<title>lua_instance</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">lua_instance</td></tr>
</thead><tbody>
<tr>
	<td>store</td>
	<td>javascript{&quot;TestPage&quot;+Math.random()}</td>
	<td>Title</td>
</tr>
<tr>
	<td>open</td>
	<td>/index.php?title=Module:LinkedWikiTest${Title}&amp;action=edit</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>id=wpTextbox1</td>
	<td>-- @copyright (c) 2016 Bourdercloud.com<br />-- @author Karima Rafes &lt;karima.rafes@bordercloud.com&gt;<br />-- @link http://www.mediawiki.org/wiki/Extension:LinkedWiki<br />-- @license CC-by-nc-sa V3.0<br />--<br />--&nbsp;&nbsp;Last version : http://github.com/BorderCloud/LinkedWiki<br />--<br />--<br />-- This work is licensed under the Creative Commons<br />-- Attribution-NonCommercial-ShareAlike 3.0<br />-- Unported License. To view a copy of this license,<br />-- visit http://creativecommons.org/licenses/by-nc-sa/3.0/<br />-- or send a letter to Creative Commons,<br />-- 171 Second Street, Suite 300, San Francisco,<br />-- California, 94105, USA.<br /><br />--[[<br />-- Debug console<br /><br />mw.log(p.tests() )<br />]]<br /><br />local p = {}<br /><br />function p.checkLitteral(query, litteral)<br />&nbsp;&nbsp;&nbsp;&nbsp;local result = ''<br />&nbsp;&nbsp;&nbsp;&nbsp;if string.match(query, litteral) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;OK&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;return result<br />end<br /><br /><br />function p.checkString(val1, val2)<br />&nbsp;&nbsp;&nbsp;&nbsp;local result = ''<br />&nbsp;&nbsp;&nbsp;&nbsp;if (val1 ==&nbsp;&nbsp;nil or val2 ==&nbsp;&nbsp;nil) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if val1 ==&nbsp;&nbsp;val2 then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;OK&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;return result<br />end<br />function p.checkNumber(val1, val2)<br />&nbsp;&nbsp;&nbsp;&nbsp;local result = ''<br />&nbsp;&nbsp;&nbsp;&nbsp;if (val1 ==&nbsp;&nbsp;nil or val2 ==&nbsp;&nbsp;nil) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if tonumber(val1) ==&nbsp;&nbsp;tonumber(val2) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;OK&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;return result<br />end<br />function p.checkBool(val1, val2)<br />&nbsp;&nbsp;&nbsp;&nbsp;local result = ''<br />&nbsp;&nbsp;&nbsp;&nbsp;if (val1 ==&nbsp;&nbsp;nil or val2 ==&nbsp;&nbsp;nil) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if val1 ==&nbsp;&nbsp;val2 then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;OK&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = &quot;KO&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;return result<br />end<br /><br /><br />function p.tests(f)<br />&nbsp;&nbsp;&nbsp;&nbsp;local html = &quot;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;local result = &quot;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;local linkedwiki = require 'linkedwiki'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;local wd = &quot;http://www.wikidata.org/entity/&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;local subject1 = wd..&quot;Q1&quot;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;local wd = &quot;http://www.wikidata.org/entity/&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;local subject2 = wd..&quot;Q2&quot;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;local configTest = 'http://database-test'<br />&nbsp;&nbsp;&nbsp;&nbsp;local configWikidata = &quot;http://www.wikidata.org&quot;<br /><br />--&nbsp;&nbsp;&nbsp;&nbsp;for i,v in pairs(linkedwiki) do<br />--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mw.log(i)<br />--&nbsp;&nbsp;&nbsp;&nbsp;end<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;-- Config by default : Wikidata and taglang : en<br />&nbsp;&nbsp;&nbsp;&nbsp;local ObjWikidata =&nbsp;&nbsp;linkedwiki.new(subject1)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;-- Config by default : Wikidata but taglang : fr<br />&nbsp;&nbsp;&nbsp;&nbsp;local ObjWikidataFr =&nbsp;&nbsp;linkedwiki.new(subject1,nil,&quot;fr&quot;)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;--Lang by default : en<br />&nbsp;&nbsp;&nbsp;&nbsp;local objTest = linkedwiki.new(subject2,configTest)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;-- config with another taglang<br />&nbsp;&nbsp;&nbsp;&nbsp;local objTestFr = linkedwiki.new(subject2,configTest,&quot;fr&quot;)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;----------------------------------------------------------------------------&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;TEST : Subject &quot; ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTest:getSubject()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,subject2) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidata:getSubject()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,subject1) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;----------------------------------------------------------------------------&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;TEST : Config &quot; ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTest:getConfig()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,configTest) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidata:getConfig()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,configWikidata) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTestFr:getConfig()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,configTest) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidataFr:getConfig()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,configWikidata) ..'\n'<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;----------------------------------------------------------------------------&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;TEST : lang &quot; ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTest:getLang()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,&quot;en&quot;) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidata:getLang()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,&quot;en&quot;) ..'\n'<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTestFr:getLang()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,&quot;fr&quot;) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidataFr:getLang()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..result ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkString(result,&quot;fr&quot;) ..'\n'<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;----------------------------------------------------------------------------&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;TEST : debug &quot; ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTest:isDebug()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..tostring(result) ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkBool(result,false) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidata:isDebug()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..tostring(result) ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkBool(result,false) ..'\n'<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTestFr:setDebug(true)<br />&nbsp;&nbsp;&nbsp;&nbsp;result = objTest:isDebug()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..tostring(result) ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkBool(result,false) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;result = ObjWikidata:isDebug()<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT BEGIN : &quot;..'\n' ..tostring(result) ..'\n'..&quot;END&quot; ..'\n'<br />&nbsp;&nbsp;&nbsp;&nbsp;html = html ..&quot;RESULT : &quot; .. p.checkBool(result,false) ..'\n'<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;return &quot;&lt;nowiki&gt;&lt;pre&gt;&quot;..mw.text.encode( html)..&quot;&lt;/pre&gt;&lt;/nowiki&gt;&quot;<br />end<br /><br />return p<br /></td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>id=wpSave</td>
	<td></td>
</tr>
<tr>
	<td>open</td>
	<td>/index.php/LinkedWikiTestLua${Title}?action=edit</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>id=wpTextbox1</td>
	<td>{{#invoke: LinkedWikiTest${Title} | tests}}</td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>id=wpSave</td>
	<td></td>
</tr>
<tr>
	<td>open</td>
	<td>/index.php/LinkedWikiTestLua${Title}?action=purge</td>
	<td></td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>css=input.mw-htmlform-submit</td>
	<td></td>
</tr>
<tr>
	<td>verifyText</td>
	<td>//div[@id='mw-content-text']/pre</td>
	<td>*TEST :*</td>
</tr>
<tr>
	<td>verifyNotText</td>
	<td>//div[@id='mw-content-text']/pre</td>
	<td>*KO*</td>
</tr>
</tbody></table>
</body>
</html>
