From: jenkins-bot Date: Thu, 28 Dec 2017 16:47:45 +0000 (+0000) Subject: Merge "Add @covers tags to languages tests" X-Git-Tag: 1.31.0-rc.0~1060 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=5f0080715ab1f9e176420c737b4a0511e3cb280b;hp=fc23633035eebb24b7199cb15683e25100184e2b;p=lhc%2Fweb%2Fwiklou.git Merge "Add @covers tags to languages tests" --- diff --git a/includes/Linker.php b/includes/Linker.php index 48be3bfe7a..84e3103c65 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1595,7 +1595,12 @@ class Linker { $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped(); return '
' - . '

' . $title . "

\n" + . Html::openElement( 'div', [ + 'class' => 'toctitle', + 'lang' => $lang->getHtmlCode(), + 'dir' => $lang->getDir(), + ] ) + . '

' . $title . "

\n" . $toc . "\n\n"; } diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index d959dd2adc..296c4b3bb9 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -213,11 +213,11 @@ class HTMLForm extends ContextSource { 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 = []; @@ -1062,7 +1062,7 @@ class HTMLForm extends ContextSource { if ( $this->mId ) { $attribs['id'] = $this->mId; } - if ( $this->mAutocomplete ) { + if ( is_string( $this->mAutocomplete ) ) { $attribs['autocomplete'] = $this->mAutocomplete; } if ( $this->mName ) { @@ -1868,12 +1868,12 @@ class HTMLForm extends ContextSource { } /** - * 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 */ diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 10a338ed01..078de3c601 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3114,10 +3114,29 @@ class Parser { 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']; + } } } @@ -3862,11 +3881,12 @@ class Parser { } 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 ) ) { diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 2588962604..5368125f35 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -559,8 +559,16 @@ class Preprocessor_DOM extends Preprocessor { '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' ) { @@ -610,8 +618,16 @@ class Preprocessor_DOM extends Preprocessor { // 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; @@ -640,8 +656,16 @@ class Preprocessor_DOM extends Preprocessor { $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 ) ); @@ -748,8 +772,16 @@ class Preprocessor_DOM extends Preprocessor { $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; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 735c33a4fe..145fbbc592 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -497,7 +497,16 @@ class Preprocessor_Hash extends Preprocessor { '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' ) { @@ -554,7 +563,16 @@ class Preprocessor_Hash extends Preprocessor { // 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 ); @@ -584,7 +602,16 @@ class Preprocessor_Hash extends Preprocessor { $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 ) ); @@ -695,7 +722,16 @@ class Preprocessor_Hash extends Preprocessor { } } - 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 ); diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php index 20fee2db29..b570a43c06 100644 --- a/includes/parser/Sanitizer.php +++ b/includes/parser/Sanitizer.php @@ -477,7 +477,16 @@ class Sanitizer { 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 ); diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php index 832da4db79..ffb8cb353f 100644 --- a/maintenance/benchmarks/Benchmarker.php +++ b/maintenance/benchmarks/Benchmarker.php @@ -26,7 +26,9 @@ * @ingroup Benchmark */ +// @codeCoverageIgnoreStart require_once __DIR__ . '/../Maintenance.php'; +// @codeCoverageIgnoreEnd /** * Base class for benchmark scripts. diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index 2b79b546d4..0604f4886b 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -25,6 +25,7 @@ */ require_once __DIR__ . '/backup.inc'; +require_once __DIR__ . '/7zip.inc'; require_once __DIR__ . '/../includes/export/WikiExporter.php'; use Wikimedia\Rdbms\IMaintainableDatabase; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 72ee550109..840c74dbb9 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -16578,7 +16578,7 @@ Section headings with TOC Some text ===Another headline=== !! html -

Contents

+

Contents

  • 1 Headline 1
      @@ -16621,7 +16621,7 @@ __FORCETOC__ == Headline 2 == == Headline == !! html/php -

      Contents

      +

      Contents

      • 1 Headline 2
      • 2 Headline
      • @@ -16655,7 +16655,7 @@ parsoid=wt2html ========= Level 9 Heading========= ========== Level 10 Heading========== !! html/php -

        Contents

        +

        Contents

        • 1 Level 1 Heading
            @@ -16719,7 +16719,7 @@ TOC regression (T11764) == title 2 == === title 2.1 === !! html -

            Contents

            +

            Contents

            • 1 title 1
                @@ -16754,7 +16754,7 @@ TOC for heading containing (T96153) __FORCETOC__ ==New title== !! html/php -

                Contents

                +

                Contents

                @@ -16776,7 +16776,7 @@ wgMaxTocLevel=3 == title 2 == === title 2.1 === !! html -

                Contents

                +

                Contents

                • 1 title 1
                    @@ -16812,7 +16812,7 @@ wgMaxTocLevel=3 ====Section 1.1.1.1==== ==Section 2== !! html -

                    Contents

                    +

                    Contents

                    • 1 Section 1
                        @@ -16905,7 +16905,7 @@ __TOC__ === title 1.1 === == title 2 == !! html -

                        Contents

                        +

                        Contents

                        • 1 title 1
                            @@ -16981,7 +16981,7 @@ section 5 !! html/php

                            The tooltips shall not show entities to the user (ie. be double escaped)

                            -

                            Contents

                            +

                            Contents

                            • 1 text > text
                            • 2 text < text
                            • @@ -17057,7 +17057,7 @@ section 6 !! html/php

                              Id should not contain + for spaces

                              -

                              Contents

                              +

                              Contents

                              • 1 Space between Text
                              • 2 Space-Entity between Text
                              • @@ -17133,7 +17133,7 @@ parsoid=wt2html,wt2wt,html2html =''italic'' heading== ==''italic'' heading= !! html/php -

                                Contents

                                +

                                Contents

                                • 1 foo=
                                • 2 =foo
                                • @@ -17168,7 +17168,7 @@ HTML headers vs TOC (T25393) == Header 2.2 == __NOEDITSECTION__ !! html/php -

                                  Contents

                                  +

                                  Contents

                                  • 1 Header 1
                                      @@ -19081,7 +19081,7 @@ Fuzz testing: Parser14 http://__TOC__ !! html/php

                                      onmouseover=[edit]

                                      -http://

                                      Contents

                                      +http://

                                      Contents

                                      @@ -19092,7 +19092,7 @@ http://

                                      Contents

                                      onmouseover=[edit]

                                      http://

                                      -
                                      +

                                      Contents

                                        @@ -21608,7 +21608,7 @@ Out-of-order TOC heading levels =====5===== ==2== !! html -

                                        Contents

                                        +

                                        Contents

                                        • 1 2
                                            @@ -24242,7 +24242,7 @@ title=[[Main Page]] __TOC__ == ''Lost'' episodes == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24263,7 +24263,7 @@ title=[[Main Page]] __TOC__ == '''should be bold''' then normal text == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24284,7 +24284,7 @@ title=[[Main Page]] __TOC__ == Image [[Image:foobar.jpg]] == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24305,7 +24305,7 @@ title=[[Main Page]] __TOC__ ==
                                            Quote
                                            == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24316,7 +24316,7 @@ __TOC__ !! html/php+tidy

                                            -
                                            +

                                            Contents

                                              @@ -24346,7 +24346,7 @@ __TOC__ Hanc marginis exiguitas non caperet. QED !! html/php -

                                              Contents

                                              +

                                              Contents

                                              @@ -24371,7 +24371,7 @@ __TOC__ == Foo
                                              Bar
                                              == !! html/php -

                                              Contents

                                              +

                                              Contents

                                              • 1 Foo Bar
                                              • 2 Foo Bar
                                              • @@ -24384,7 +24384,7 @@ __TOC__ !! html/php+tidy

                                                -
                                                +

                                                Contents

                                                  @@ -24418,7 +24418,7 @@ __TOC__ == Evilbye == !! html/php -

                                                  Contents

                                                  +

                                                  Contents

                                                  • 1 Hello
                                                  • 2 b">Evilbye
                                                  • @@ -24449,7 +24449,7 @@ __TOC__ == Attributes after dir on these span tags must be deleted from the TOC == !! html/php -

                                                    Contents

                                                    +

                                                    Contents

                                                    • 1 C++
                                                    • 2 זבנג!
                                                    • @@ -24480,7 +24480,7 @@ T74884: bdi element in ToC __TOC__ == test == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24499,7 +24499,7 @@ T35715: s/strike element in ToC __TOC__ == test test test == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24521,7 +24521,7 @@ Empty

                                                      tag in TOC, removed by Sanitizer (T92892) __TOC__ == x == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24532,7 +24532,7 @@ __TOC__ !! html/php+tidy

                                                      -
                                                      +

                                                      Contents

                                                        @@ -29955,7 +29955,7 @@ wgFragmentMode=[ 'html5', 'legacy' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                        Contents

                                                        +

                                                        Contents

                                                        • 1 Foo bar
                                                        • 2 foo Bar
                                                        • @@ -30021,7 +30021,7 @@ wgFragmentMode=[ 'legacy', 'html5' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                          Contents

                                                          +

                                                          Contents

                                                          • 1 Foo bar
                                                          • 2 foo Bar
                                                          • @@ -30069,7 +30069,7 @@ wgFragmentMode=[ 'html5' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                            Contents

                                                            +

                                                            Contents

                                                            • 1 Foo bar
                                                            • 2 foo Bar
                                                            • diff --git a/tests/phpunit/includes/AutopromoteTest.php b/tests/phpunit/includes/AutopromoteTest.php index 785aa4e3d4..24f6596ea9 100644 --- a/tests/phpunit/includes/AutopromoteTest.php +++ b/tests/phpunit/includes/AutopromoteTest.php @@ -1,5 +1,8 @@ getUserForBlocking(); @@ -366,6 +367,9 @@ class BlockTest extends MediaWikiLangTestCase { $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'; @@ -418,6 +422,11 @@ class BlockTest extends MediaWikiLangTestCase { ); } + /** + * @covers Block::getSystemBlockType + * @covers Block::insert + * @covers Block::doAutoblock + */ public function testSystemBlocks() { $user = $this->getUserForBlocking(); $this->addBlockForUser( $user ); diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php index 498532f76c..91101bd975 100644 --- a/tests/phpunit/includes/MWNamespaceTest.php +++ b/tests/phpunit/includes/MWNamespaceTest.php @@ -7,7 +7,6 @@ /** * Test class for MWNamespace. - * @todo covers tags * @todo FIXME: this test file is a mess */ class MWNamespaceTest extends MediaWikiTestCase { diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index 7e56ebf20b..ae23a4343e 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -5,11 +5,6 @@ */ class StatusTest extends MediaWikiLangTestCase { - public function testCanConstruct() { - new Status(); - $this->assertTrue( true ); - } - /** * @dataProvider provideValues * @covers Status::newGood diff --git a/tests/phpunit/includes/TemplateParserTest.php b/tests/phpunit/includes/TemplateParserTest.php index c161f85306..4a803e6374 100644 --- a/tests/phpunit/includes/TemplateParserTest.php +++ b/tests/phpunit/includes/TemplateParserTest.php @@ -2,6 +2,7 @@ /** * @group Templates + * @covers TemplateParser */ class TemplateParserTest extends MediaWikiTestCase { @@ -19,9 +20,6 @@ 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 ) { diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index abef1c9206..f1ff94751e 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -218,6 +218,9 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { ); } + /** + * @coversNothing + */ public function testApiTestGroup() { $groups = PHPUnit_Util_Test::getGroups( static::class ); $constraint = PHPUnit_Framework_Assert::logicalOr( diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php index deaa65ad87..f0a3606fc2 100644 --- a/tests/phpunit/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php @@ -285,6 +285,9 @@ class DatabaseSqliteTest extends MediaWikiTestCase { ); } + /** + * @coversNothing + */ public function testEntireSchema() { global $IP; @@ -298,6 +301,7 @@ class DatabaseSqliteTest extends MediaWikiTestCase { /** * 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; @@ -497,6 +501,9 @@ class DatabaseSqliteTest extends MediaWikiTestCase { $this->assertTrue( $db->close(), "closing database" ); } + /** + * @covers \Wikimedia\Rdbms\DatabaseSqlite::__toString + */ public function testToString() { $db = DatabaseSqlite::newStandaloneInstance( ':memory:' ); diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index 1efeeebdaf..75d54146e1 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -1,10 +1,4 @@ closeAll(); } + /** + * @covers \Wikimedia\Rdbms\ChronologyProtector + */ public function testChronologyProtector() { // (a) First HTTP request $mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' ); diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php index a8e7f898a4..5fd33dc1cf 100644 --- a/tests/phpunit/includes/db/LoadBalancerTest.php +++ b/tests/phpunit/includes/db/LoadBalancerTest.php @@ -24,6 +24,8 @@ use Wikimedia\Rdbms\LoadBalancer; * * @group Database * @file + * + * @covers \Wikimedia\Rdbms\LoadBalancer */ class LoadBalancerTest extends MediaWikiTestCase { public function testWithoutReplica() { diff --git a/tests/phpunit/includes/exception/MWExceptionTest.php b/tests/phpunit/includes/exception/MWExceptionTest.php index 614a1c981d..6c5b3b1eae 100644 --- a/tests/phpunit/includes/exception/MWExceptionTest.php +++ b/tests/phpunit/includes/exception/MWExceptionTest.php @@ -10,6 +10,7 @@ class MWExceptionTest extends MediaWikiTestCase { /** * @expectedException MWException + * @covers MWException */ public function testMwexceptionThrowing() { throw new MWException(); diff --git a/tests/phpunit/includes/htmlform/HTMLFormTest.php b/tests/phpunit/includes/htmlform/HTMLFormTest.php index 98511ca79c..f74f60af05 100644 --- a/tests/phpunit/includes/htmlform/HTMLFormTest.php +++ b/tests/phpunit/includes/htmlform/HTMLFormTest.php @@ -2,22 +2,56 @@ /** * @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( '/assertStringStartsWith( '
                                                              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( '' ) ); + } + } diff --git a/tests/phpunit/includes/http/HttpTest.php b/tests/phpunit/includes/http/HttpTest.php index 2d73bac548..8ca9f6a268 100644 --- a/tests/phpunit/includes/http/HttpTest.php +++ b/tests/phpunit/includes/http/HttpTest.php @@ -495,6 +495,7 @@ class HttpTest extends MediaWikiTestCase { * where it did not define a cURL constant. T72570 * * @dataProvider provideCurlConstants + * @coversNothing */ public function testCurlConstants( $value ) { $this->checkPHPExtension( 'curl' ); diff --git a/tests/phpunit/includes/libs/HtmlArmorTest.php b/tests/phpunit/includes/libs/HtmlArmorTest.php index 5f176e0c85..0e9469ad04 100644 --- a/tests/phpunit/includes/libs/HtmlArmorTest.php +++ b/tests/phpunit/includes/libs/HtmlArmorTest.php @@ -5,7 +5,22 @@ */ class HtmlArmorTest extends PHPUnit_Framework_TestCase { - public static function provideHtmlArmor() { + public static function provideConstructor() { + return [ + [ 'test' ], + [ null ], + [ 'some html!' ] + ]; + } + + /** + * @dataProvider provideConstructor + */ + public function testConstructor( $value ) { + $this->assertInstanceOf( HtmlArmor::class, new HtmlArmor( $value ) ); + } + + public static function provideGetHtml() { return [ [ 'foobar', @@ -19,13 +34,17 @@ class HtmlArmorTest extends PHPUnit_Framework_TestCase { new HtmlArmor( '' ), '', ], + [ + new HtmlArmor( null ), + null, + ] ]; } /** - * @dataProvider provideHtmlArmor + * @dataProvider provideGetHtml */ - public function testHtmlArmor( $input, $expected ) { + public function testGetHtml( $input, $expected ) { $this->assertEquals( $expected, HtmlArmor::getHtml( $input ) diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index 5ae1763596..fff101f3a2 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -5,10 +5,13 @@ * @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' ); diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 6a2afad6d7..9f5e38640e 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -9,11 +9,13 @@ * @author Antoine Musso * @copyright Copyright © 2011, Antoine Musso * @file - * @todo covers tags * * @group Database */ +/** + * @covers Parser::getVariableValue + */ class MagicVariableTest extends MediaWikiTestCase { /** * @var Parser diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php index 5ef30e872a..acf4710ffd 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -607,6 +607,11 @@ class ExtensionProcessorTest extends MediaWikiTestCase { $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( diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index f004e7913b..ea7f715b5f 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -236,6 +236,8 @@ class UserTest extends MediaWikiTestCase { * 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 diff --git a/tests/phpunit/maintenance/BenchmarkerTest.php b/tests/phpunit/maintenance/BenchmarkerTest.php new file mode 100644 index 0000000000..69f98bdd00 --- /dev/null +++ b/tests/phpunit/maintenance/BenchmarkerTest.php @@ -0,0 +1,135 @@ +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 () { + } + ] ); + } +} diff --git a/tests/phpunit/skins/SideBarTest.php b/tests/phpunit/skins/SideBarTest.php index af03fe6325..dceaf418f1 100644 --- a/tests/phpunit/skins/SideBarTest.php +++ b/tests/phpunit/skins/SideBarTest.php @@ -188,6 +188,7 @@ class SideBarTest extends MediaWikiLangTestCase { /** * Test $wgNoFollowLinks in sidebar + * @covers Skin::addToSidebarPlain */ public function testRespectWgnofollowlinks() { $this->setMwGlobals( 'wgNoFollowLinks', false ); @@ -201,6 +202,7 @@ class SideBarTest extends MediaWikiLangTestCase { /** * Test $wgExternaLinkTarget in sidebar * @dataProvider dataRespectExternallinktarget + * @covers Skin::addToSidebarPlain */ public function testRespectExternallinktarget( $externalLinkTarget ) { $this->setMwGlobals( 'wgExternalLinkTarget', $externalLinkTarget ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index b20b68f5d6..6a1b83cf12 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -12,7 +12,7 @@ assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' ); tocHtml = '
                                                              ' + - '
                                                              ' + + '
                                                              ' + '

                                                              Contents

                                                              ' + '
                                                              ' + '
                                                              ' +