$title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
return '<div id="toc" class="toc">'
- . '<div class="toctitle"><h2>' . $title . "</h2></div>\n"
+ . Html::openElement( 'div', [
+ 'class' => 'toctitle',
+ 'lang' => $lang->getHtmlCode(),
+ 'dir' => $lang->getDir(),
+ ] )
+ . '<h2>' . $title . "</h2></div>\n"
. $toc
. "</ul>\n</div>\n";
}
protected $mAction = false;
/**
- * Form attribute autocomplete. false does not set the attribute
+ * Form attribute autocomplete. A typical value is "off". null does not set the attribute
* @since 1.27
- * @var bool|string
+ * @var string|null
*/
- protected $mAutocomplete = false;
+ protected $mAutocomplete = null;
protected $mUseMultipart = false;
protected $mHiddenFields = [];
if ( $this->mId ) {
$attribs['id'] = $this->mId;
}
- if ( $this->mAutocomplete ) {
+ if ( is_string( $this->mAutocomplete ) ) {
$attribs['autocomplete'] = $this->mAutocomplete;
}
if ( $this->mName ) {
}
/**
- * Set the value for the autocomplete attribute of the form.
- * When set to false (which is the default state), the attribute get not set.
+ * Set the value for the autocomplete attribute of the form. A typical value is "off".
+ * When set to null (which is the default state), the attribute get not set.
*
* @since 1.27
*
- * @param string|bool $autocomplete
+ * @param string|null $autocomplete
*
* @return HTMLForm $this for chaining calls
*/
throw $ex;
}
- # The interface for parser functions allows for extracting
- # flags into the local scope. Extract any forwarded flags
- # here.
- extract( $result );
+ // Extract any forwarded flags
+ if ( isset( $result['found'] ) ) {
+ $found = $result['found'];
+ }
+ if ( array_key_exists( 'text', $result ) ) {
+ // a string or null
+ $text = $result['text'];
+ }
+ if ( isset( $result['nowiki'] ) ) {
+ $nowiki = $result['nowiki'];
+ }
+ if ( isset( $result['isHTML'] ) ) {
+ $isHTML = $result['isHTML'];
+ }
+ if ( isset( $result['forceRawInterwiki'] ) ) {
+ $forceRawInterwiki = $result['forceRawInterwiki'];
+ }
+ if ( isset( $result['isChildObj'] ) ) {
+ $isChildObj = $result['isChildObj'];
+ }
+ if ( isset( $result['isLocalObj'] ) ) {
+ $isLocalObj = $result['isLocalObj'];
+ }
}
}
}
if ( is_array( $output ) ) {
- # Extract flags to local scope (to override $markerType)
+ // Extract flags
$flags = $output;
$output = $flags[0];
- unset( $flags[0] );
- extract( $flags );
+ if ( isset( $flags['markerType'] ) ) {
+ $markerType = $flags['markerType'];
+ }
}
} else {
if ( is_null( $attrText ) ) {
'count' => $count ];
$stack->push( $piece );
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
$i += $count;
}
} elseif ( $found == 'line-end' ) {
// Unwind the stack
$stack->pop();
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
// Append the result to the enclosing accumulator
$accum .= $element;
$stack->push( $piece );
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
} else {
# Add literal brace(s)
$accum .= htmlspecialchars( str_repeat( $curChar, $count ) );
$accum .= $s;
}
}
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
# Add XML element to the enclosing accumulator
$accum .= $element;
'count' => $count ];
$stack->push( $piece );
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
$i += $count;
}
} elseif ( $found == 'line-end' ) {
// Unwind the stack
$stack->pop();
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
// Append the result to the enclosing accumulator
array_splice( $accum, count( $accum ), 0, $element );
$stack->push( $piece );
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
} else {
# Add literal brace(s)
self::addLiteral( $accum, str_repeat( $curChar, $count ) );
}
}
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
# Add XML element to the enclosing accumulator
array_splice( $accum, count( $accum ), 0, $element );
public static function removeHTMLtags( $text, $processCallback = null,
$args = [], $extratags = [], $removetags = [], $warnCallback = null
) {
- extract( self::getRecognizedTagData( $extratags, $removetags ) );
+ $tagData = self::getRecognizedTagData( $extratags, $removetags );
+ $htmlpairs = $tagData['htmlpairs'];
+ $htmlsingle = $tagData['htmlsingle'];
+ $htmlsingleonly = $tagData['htmlsingleonly'];
+ $htmlnest = $tagData['htmlnest'];
+ $tabletags = $tagData['tabletags'];
+ $htmllist = $tagData['htmllist'];
+ $listtags = $tagData['listtags'];
+ $htmlsingleallowed = $tagData['htmlsingleallowed'];
+ $htmlelements = $tagData['htmlelements'];
# Remove HTML comments
$text = self::removeHTMLcomments( $text );
* @ingroup Benchmark
*/
+// @codeCoverageIgnoreStart
require_once __DIR__ . '/../Maintenance.php';
+// @codeCoverageIgnoreEnd
/**
* Base class for benchmark scripts.
*/
require_once __DIR__ . '/backup.inc';
+require_once __DIR__ . '/7zip.inc';
require_once __DIR__ . '/../includes/export/WikiExporter.php';
use Wikimedia\Rdbms\IMaintainableDatabase;
Some text
===Another headline===
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
<ul>
== Headline 2 ==
== Headline ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
========= Level 9 Heading=========
========== Level 10 Heading==========
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
<ul>
== title 2 ==
=== title 2.1 ===
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
<ul>
__FORCETOC__
==<span id="old-anchor"></span>New title==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
</ul>
== title 2 ==
=== title 2.1 ===
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
<ul>
====Section 1.1.1.1====
==Section 2==
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
<ul>
=== title 1.1 ===
== title 2 ==
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
<ul>
!! html/php
<p>The tooltips shall not show entities to the user (ie. be double escaped)
</p>
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text > text</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text < text</span></a></li>
!! html/php
<p>Id should not contain + for spaces
</p>
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Space_between_Text"><span class="tocnumber">1</span> <span class="toctext">Space between Text</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Space-Entity_between_Text"><span class="tocnumber">2</span> <span class="toctext">Space-Entity between Text</span></a></li>
=''italic'' heading==
==''italic'' heading=
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
== Header 2.2 ==
__NOEDITSECTION__
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
<ul>
http://__TOC__
!! html/php
<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
</ul>
<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>http://</p>
<div id="toc" class="toc">
-<div class="toctitle">
+<div class="toctitle" lang="en" dir="ltr" xml:lang="en">
<h2>Contents</h2>
</div>
<ul>
=====5=====
==2==
!! html
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
<ul>
__TOC__
== ''Lost'' episodes ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li>
</ul>
__TOC__
== '''should be bold''' then normal text ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li>
</ul>
__TOC__
== Image [[Image:foobar.jpg]] ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
</ul>
__TOC__
== <blockquote>Quote</blockquote> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
</ul>
!! html/php+tidy
<p></p>
<div id="toc" class="toc">
-<div class="toctitle">
+<div class="toctitle" lang="en" dir="ltr" xml:lang="en">
<h2>Contents</h2>
</div>
<ul>
<small>Hanc marginis exiguitas non caperet.</small>
QED
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Proof:_2_<_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 < 3</span></a></li>
</ul>
== <i>Foo</i> <blockquote>Bar</blockquote> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
!! html/php+tidy
<p></p>
<div id="toc" class="toc">
-<div class="toctitle">
+<div class="toctitle" lang="en" dir="ltr" xml:lang="en">
<h2>Contents</h2>
</div>
<ul>
== <sup class="a > b">Evilbye</sup> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b">Evilbye</sup></span></a></li>
== <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li>
__TOC__
== <bdi>test</bdi> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
</ul>
__TOC__
== <s>test</s> test <strike>test</strike> ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li>
</ul>
__TOC__
== x ==
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
</ul>
!! html/php+tidy
<p></p>
<div id="toc" class="toc">
-<div class="toctitle">
+<div class="toctitle" lang="en" dir="ltr" xml:lang="en">
<h2>Contents</h2>
</div>
<ul>
[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
!! html/php
-<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
<?php
+/**
+ * @covers Autopromote
+ */
class AutopromoteTest extends MediaWikiTestCase {
/**
* T157718: Verify Autopromote does not perform edit count lookup if requirement is 0 or invalid
/**
* per T28425
+ * @covers Block::__construct
*/
public function testBug26425BlockTimestampDefaultsToTime() {
$user = $this->getUserForBlocking();
$this->assertEquals( $exResult, $block->mReason, 'Correct block type for XFF header ' . $xff );
}
+ /**
+ * @covers Block::__construct
+ */
public function testDeprecatedConstructor() {
$this->hideDeprecated( 'Block::__construct with multiple arguments' );
$username = 'UnthinkablySecretRandomUsername';
);
}
+ /**
+ * @covers Block::getSystemBlockType
+ * @covers Block::insert
+ * @covers Block::doAutoblock
+ */
public function testSystemBlocks() {
$user = $this->getUserForBlocking();
$this->addBlockForUser( $user );
/**
* Test class for MWNamespace.
- * @todo covers tags
* @todo FIXME: this test file is a mess
*/
class MWNamespaceTest extends MediaWikiTestCase {
*/
class StatusTest extends MediaWikiLangTestCase {
- public function testCanConstruct() {
- new Status();
- $this->assertTrue( true );
- }
-
/**
* @dataProvider provideValues
* @covers Status::newGood
/**
* @group Templates
+ * @covers TemplateParser
*/
class TemplateParserTest extends MediaWikiTestCase {
/**
* @dataProvider provideProcessTemplate
- * @covers TemplateParser::processTemplate
- * @covers TemplateParser::getTemplate
- * @covers TemplateParser::getTemplateFilename
*/
public function testProcessTemplate( $name, $args, $result, $exception = false ) {
if ( $exception ) {
);
}
+ /**
+ * @coversNothing
+ */
public function testApiTestGroup() {
$groups = PHPUnit_Util_Test::getGroups( static::class );
$constraint = PHPUnit_Framework_Assert::logicalOr(
);
}
+ /**
+ * @coversNothing
+ */
public function testEntireSchema() {
global $IP;
/**
* Runs upgrades of older databases and compares results with current schema
* @todo Currently only checks list of tables
+ * @coversNothing
*/
public function testUpgrades() {
global $IP, $wgVersion, $wgProfiler;
$this->assertTrue( $db->close(), "closing database" );
}
+ /**
+ * @covers \Wikimedia\Rdbms\DatabaseSqlite::__toString
+ */
public function testToString() {
$db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
<?php
-
-use Wikimedia\Rdbms\LBFactorySimple;
-use Wikimedia\Rdbms\LBFactoryMulti;
-use Wikimedia\Rdbms\ChronologyProtector;
-use Wikimedia\Rdbms\MySQLMasterPos;
-
/**
* Holds tests for LBFactory abstract MediaWiki class.
*
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @group Database
* @file
* @author Antoine Musso
* @copyright © 2013 Antoine Musso
* @copyright © 2013 Wikimedia Foundation Inc.
*/
+
+use Wikimedia\Rdbms\LBFactorySimple;
+use Wikimedia\Rdbms\LBFactoryMulti;
+use Wikimedia\Rdbms\ChronologyProtector;
+use Wikimedia\Rdbms\MySQLMasterPos;
+
+/**
+ * @group Database
+ * @covers \Wikimedia\Rdbms\LBFactorySimple
+ * @covers \Wikimedia\Rdbms\LBFactoryMulti
+ */
class LBFactoryTest extends MediaWikiTestCase {
/**
+ * @covers MWLBFactory::getLBFactoryClass
* @dataProvider getLBFactoryClassProvider
*/
public function testGetLBFactoryClass( $expected, $deprecated ) {
$lb->closeAll();
}
+ /**
+ * @covers \Wikimedia\Rdbms\ChronologyProtector
+ */
public function testChronologyProtector() {
// (a) First HTTP request
$mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' );
*
* @group Database
* @file
+ *
+ * @covers \Wikimedia\Rdbms\LoadBalancer
*/
class LoadBalancerTest extends MediaWikiTestCase {
public function testWithoutReplica() {
/**
* @expectedException MWException
+ * @covers MWException
*/
public function testMwexceptionThrowing() {
throw new MWException();
/**
* @covers HTMLForm
+ *
+ * @licence GNU GPL v2+
+ * @author Gergő Tisza
+ * @author Thiemo Mättig
*/
class HTMLFormTest extends MediaWikiTestCase {
- public function testGetHTML_empty() {
+
+ private function newInstance() {
$form = new HTMLForm( [] );
$form->setTitle( Title::newFromText( 'Foo' ) );
+ return $form;
+ }
+
+ public function testGetHTML_empty() {
+ $form = $this->newInstance();
$form->prepareForm();
$html = $form->getHTML( false );
- $this->assertRegExp( '/<form\b/', $html );
+ $this->assertStringStartsWith( '<form ', $html );
}
/**
* @expectedException LogicException
*/
public function testGetHTML_noPrepare() {
- $form = new HTMLForm( [] );
- $form->setTitle( Title::newFromText( 'Foo' ) );
+ $form = $this->newInstance();
$form->getHTML( false );
}
+
+ public function testAutocompleteDefaultsToNull() {
+ $form = $this->newInstance();
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToNull() {
+ $form = $this->newInstance();
+ $form->setAutocomplete( null );
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToFalse() {
+ $form = $this->newInstance();
+ // Previously false was used instead of null to indicate the attribute should not be set
+ $form->setAutocomplete( false );
+ $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
+ }
+
+ public function testAutocompleteWhenSetToOff() {
+ $form = $this->newInstance();
+ $form->setAutocomplete( 'off' );
+ $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
+ }
+
}
* where it did not define a cURL constant. T72570
*
* @dataProvider provideCurlConstants
+ * @coversNothing
*/
public function testCurlConstants( $value ) {
$this->checkPHPExtension( 'curl' );
*/
class HtmlArmorTest extends PHPUnit_Framework_TestCase {
- public static function provideHtmlArmor() {
+ public static function provideConstructor() {
+ return [
+ [ 'test' ],
+ [ null ],
+ [ '<em>some html!</em>' ]
+ ];
+ }
+
+ /**
+ * @dataProvider provideConstructor
+ */
+ public function testConstructor( $value ) {
+ $this->assertInstanceOf( HtmlArmor::class, new HtmlArmor( $value ) );
+ }
+
+ public static function provideGetHtml() {
return [
[
'foobar',
new HtmlArmor( '<script>alert("evil!");</script>' ),
'<script>alert("evil!");</script>',
],
+ [
+ new HtmlArmor( null ),
+ null,
+ ]
];
}
/**
- * @dataProvider provideHtmlArmor
+ * @dataProvider provideGetHtml
*/
- public function testHtmlArmor( $input, $expected ) {
+ public function testGetHtml( $input, $expected ) {
$this->assertEquals(
$expected,
HtmlArmor::getHtml( $input )
* @group Media
* @group medium
*
- * @todo covers tags
+ * @covers BitmapHandler
*/
class ExifRotationTest extends MediaWikiMediaTestCase {
+ /** @var BitmapHandler */
+ private $handler;
+
protected function setUp() {
parent::setUp();
$this->checkPHPExtension( 'exif' );
* @author Antoine Musso
* @copyright Copyright © 2011, Antoine Musso
* @file
- * @todo covers tags
*
* @group Database
*/
+/**
+ * @covers Parser::getVariableValue
+ */
class MagicVariableTest extends MediaWikiTestCase {
/**
* @var Parser
$this->assertSame( [ 'ext.baz.fizzbuzz' ], $info['attributes']['FizzBuzzMorePlugins'] );
}
+ /**
+ * Verify that extension.schema.json is in sync with ExtensionProcessor
+ *
+ * @coversNothing
+ */
public function testGlobalSettingsDocumentedInSchema() {
global $IP;
$globalSettings = TestingAccessWrapper::newFromClass(
* Test, if for all rights a right- message exist,
* which is used on Special:ListGroupRights as help text
* Extensions and core
+ *
+ * @coversNothing
*/
public function testAllRightsWithMessage() {
// Getting all user rights, for core: User::$mCoreRights, for extensions: $wgAvailableRights
--- /dev/null
+<?php
+
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * @covers Benchmarker
+ */
+class BenchmarkerTest extends PHPUnit_Framework_TestCase {
+ public function testBenchSimple() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 3;
+
+ $count = 0;
+ $bench->bench( [
+ 'test' => function () use ( &$count ) {
+ $count++;
+ }
+ ] );
+
+ $this->assertSame( 3, $count );
+ }
+
+ public function testBenchSetup() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 2;
+
+ $buffer = [];
+ $bench->bench( [
+ 'test' => [
+ 'setup' => function () use ( &$buffer ) {
+ $buffer[] = 'setup';
+ },
+ 'function' => function () use ( &$buffer ) {
+ $buffer[] = 'run';
+ }
+ ]
+ ] );
+
+ $this->assertSame( [ 'setup', 'run', 'run' ], $buffer );
+ }
+
+ public function testBenchVerbose() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output', 'hasOption', 'verboseRun' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 1;
+
+ $bench->expects( $this->exactly( 2 ) )->method( 'hasOption' )
+ ->will( $this->returnValueMap( [
+ [ 'verbose', true ],
+ [ 'count', false ],
+ ] ) );
+
+ $bench->expects( $this->once() )->method( 'verboseRun' )
+ ->with( 0 )
+ ->willReturn( null );
+
+ $bench->bench( [
+ 'test' => function () {
+ }
+ ] );
+ }
+
+ public function noop() {
+ }
+
+ public function testBenchName_method() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output', 'addResult' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 1;
+
+ $bench->expects( $this->once() )->method( 'addResult' )
+ ->with( $this->callback( function ( $res ) {
+ return isset( $res['name'] ) && $res['name'] === __CLASS__ . '::noop()';
+ } ) );
+
+ $bench->bench( [
+ [ 'function' => [ $this, 'noop' ] ]
+ ] );
+ }
+
+ public function testBenchName_string() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output', 'addResult' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 1;
+
+ $bench->expects( $this->once() )->method( 'addResult' )
+ ->with( $this->callback( function ( $res ) {
+ return 'strtolower(A)';
+ } ) );
+
+ $bench->bench( [ [
+ 'function' => 'strtolower',
+ 'args' => [ 'A' ],
+ ] ] );
+ }
+
+ /**
+ * @covers Benchmarker::verboseRun
+ */
+ public function testVerboseRun() {
+ $bench = $this->getMockBuilder( Benchmarker::class )
+ ->setMethods( [ 'execute', 'output', 'hasOption', 'startBench', 'addResult' ] )
+ ->getMock();
+ $benchProxy = TestingAccessWrapper::newFromObject( $bench );
+ $benchProxy->defaultCount = 1;
+
+ $bench->expects( $this->exactly( 2 ) )->method( 'hasOption' )
+ ->will( $this->returnValueMap( [
+ [ 'verbose', true ],
+ [ 'count', false ],
+ ] ) );
+
+ $bench->expects( $this->once() )->method( 'output' )
+ ->with( $this->callback( function ( $out ) {
+ return preg_match( '/memory.+ peak/', $out ) === 1;
+ } ) );
+
+ $bench->bench( [
+ 'test' => function () {
+ }
+ ] );
+ }
+}
/**
* Test $wgNoFollowLinks in sidebar
+ * @covers Skin::addToSidebarPlain
*/
public function testRespectWgnofollowlinks() {
$this->setMwGlobals( 'wgNoFollowLinks', false );
/**
* Test $wgExternaLinkTarget in sidebar
* @dataProvider dataRespectExternallinktarget
+ * @covers Skin::addToSidebarPlain
*/
public function testRespectExternallinktarget( $externalLinkTarget ) {
$this->setMwGlobals( 'wgExternalLinkTarget', $externalLinkTarget );
assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' );
tocHtml = '<div id="toc" class="toc">' +
- '<div class="toctitle">' +
+ '<div class="toctitle" lang="en" dir="ltr">' +
'<h2>Contents</h2>' +
'</div>' +
'<ul><li></li></ul>' +