Add parser tests for refined references as rendered right now

These tests document the current status quo, and are meant to change
with every patch that makes the code for refined references more
feature complete.

Bug: T236256
Change-Id: I8c11b1decc36b86e7f7d1919cc39d0c16a200055
This commit is contained in:
Andrew Kostka 2019-11-01 15:49:34 +00:00 committed by Adam Wight
parent 64c94662f0
commit 1dcb096776

View file

@ -1744,3 +1744,388 @@ wgCiteBookReferencing=true
</li>
</ol></div>
!! end
!! test
T236256 - Refining the same base multiple times is fine
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref refines="a">page 2</ref>
<ref refines="a">page 3</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup>
<sup id="cite_ref-3" class="reference"><a href="#cite_note-3">&#91;3&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 2</span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">page 3</span>
</li>
</ol></div>
!! end
!! test
T236256 - Naming refinements is fine
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref refines="a" name="b">page 2</ref>
<ref refines="a" name="c">page 3</ref>
<ref name="b" />
<ref name="c" />
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
<sup id="cite_ref-c_3-0" class="reference"><a href="#cite_note-c-3">&#91;3&#93;</a></sup>
<sup id="cite_ref-b_2-1" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
<sup id="cite_ref-c_3-1" class="reference"><a href="#cite_note-c-3">&#91;3&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">2.0</a></sup> <sup><a href="#cite_ref-b_2-1">2.1</a></sup></span> <span class="reference-text">page 2</span>
</li>
<li id="cite_note-c-3"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-c_3-0">3.0</a></sup> <sup><a href="#cite_ref-c_3-1">3.1</a></sup></span> <span class="reference-text">page 3</span>
</li>
</ol></div>
!! end
!! test
T236256 - Cant reuse a name for 2 refinements
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref refines="a" name="b">page 2</ref>
<ref refines="a" name="b">page 3</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
<sup id="cite_ref-b_2-1" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">2.0</a></sup> <sup><a href="#cite_ref-b_2-1">2.1</a></sup></span> <span class="reference-text">page 2 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "b" defined multiple times with different content</span></span>
</li>
</ol></div>
!! end
!! test
T236256 - Cant refine a refined ref (no nesting)
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref refines="a" name="b">page 2</ref>
<ref refines="b">section 3</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
<sup id="cite_ref-3" class="reference"><a href="#cite_note-3">&#91;3&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">page 2</span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">section 3</span>
</li>
</ol></div>
!! end
!! test
T236256 - Refining a multi-part ref should be fine
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">part 1</ref>
<ref follow="a">part 2</ref>
<ref refines="a">ok</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
</p><p><sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">part 1 part 2</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">ok</span>
</li>
</ol></div>
!! end
!! test
T236256 - Dont allow splitting a refinement for now
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref refines="a" name="b">page 2</ref>
<ref follow="b">and page 3 the same time?</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">page 2 and page 3 the same time?</span>
</li>
</ol></div>
!! end
!! test
T236256 - Cant be a follow up and a refinement the same time
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book 1</ref>
<ref follow="a" refines="a">huh?</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1 huh?</span>
</li>
</ol></div>
!! end
!! test
T236256 - Cant be a follow up and a refinement the same time, even when referencing 2 different bases
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book 1</ref>
<ref name="b">book 2</ref>
<ref follow="a" refines="b">huh?</ref>
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1 huh?</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">book 2</span>
</li>
</ol></div>
!! end
!! test
T236256 - Everything in the same group
!! config
wgCiteBookReferencing=true
!! wikitext
<ref group="g1" name="a">book</ref>
<ref group="g1" refines="a" name="b">page</ref>
<ref group="g1" name="b" />
<references group="g1"/>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;g1 1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;g1 2&#93;</a></sup>
<sup id="cite_ref-b_2-1" class="reference"><a href="#cite_note-b-2">&#91;g1 2&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">2.0</a></sup> <sup><a href="#cite_ref-b_2-1">2.1</a></sup></span> <span class="reference-text">page</span>
</li>
</ol></div>
!! end
!! test
T236256 - Base and refinement in different groups
!! config
wgCiteBookReferencing=true
!! wikitext
<ref group="g1" name="a">book</ref>
<ref group="g2" refines="a">page</ref>
<references group="g1"/>
<references group="g2"/>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;g1 1&#93;</a></sup>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;g2 1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
</ol></div>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
</li>
</ol></div>
!! end
!! test
T236256 - Refinement in the unnamed default group
!! config
wgCiteBookReferencing=true
!! wikitext
<ref group="g1" name="a">book</ref>
<ref refines="a">page</ref>
<references group="g1"/>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;g1 1&#93;</a></sup>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
</ol></div><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
</li>
</ol></div>
!! end
!! test
T236256 - Base in the unnamed default group
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref group="g1" refines="a">page</ref>
<references group="g1"/>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;g1 1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
</li>
</ol></div><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
</ol></div>
!! end
!! test
T236256 - Refining a reference that doesn't exist #1
!! config
wgCiteBookReferencing=true
!! wikitext
<ref refines="a">page 1</ref>
!! html/php
<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">&#91;1&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></div>
!! end
!! test
T236256 - Refining a reference that doesn't exist #2
!! config
wgCiteBookReferencing=true
!! wikitext
<ref>book</ref>
<ref refines="a">page 1</ref>
!! html/php
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">&#91;1&#93;</a></sup>
</p>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></div>
!! end
!! test
T236256 - Named reference without text
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a" />
<ref refines="a">page 1</ref>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
</p>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>a</code></span></li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></div>
!! end
!! test
T236256 - Reference with the same name defined twice
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="a">book</ref>
<ref name="a">magazine</ref>
<ref refines="a">page 1</ref>
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-1" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
</p>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a_1-0">1.0</a></sup> <sup><a href="#cite_ref-a_1-1">1.1</a></sup></span> <span class="reference-text">book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "a" defined multiple times with different content</span></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></div>
!! end
!! test
T236256 - No text for a refinement
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="foo">book</ref>
<ref refines="foo" />
!! html/php
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">&#91;1&#93;</a></sup>
</p>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: The opening <code>&lt;ref&gt;</code> tag is malformed or has a bad name</span><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
</ol></div>
!! end
!! test
T236256 - Empty text for a refinement
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="foo">book</ref>
<ref refines="foo"></ref>
!! html/php
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">&#91;1&#93;</a></sup>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
</p>
refs with no name must have content</span><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
</ol></div>
!! end
!! test
T236256 - De-facto empty text for a refinement
!! config
wgCiteBookReferencing=true
!! wikitext
<ref name="foo">book</ref>
<ref refines="foo"> </ref>
!! html/php
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">&#91;1&#93;</a></sup>
</p>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text"> </span>
</li>
</ol></div>
!! end