[go: up one dir, main page]

Skip to content

Commit

Permalink
Fix bad file tests in parserTests
Browse files Browse the repository at this point in the history
Change-Id: I2ba4f41283c20d9d200ffbd62eb7c507c698ab5a
Enthusiastically-Suggested-By: Kunal Mehta <legoktm@debian.org>
Bug: T75581
  • Loading branch information
arlolra committed Apr 8, 2022
1 parent dd04fcf commit 8d48b61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 10 additions & 0 deletions tests/parser/ParserTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ public function setupDatabase( $nextTeardown = null ) {
* @return ScopedCallback The teardown object
*/
public function setupUploads( $nextTeardown = null ) {
$setup = [];
$teardown = [];

$this->checkSetupDone( 'setupDatabase' );
Expand Down Expand Up @@ -1701,6 +1702,15 @@ public function setupUploads( $nextTeardown = null ) {
$this->db->timestamp( '20010115123600' )
);

// The above calls to recordUpload3 call the bad file service which
// caches the wfMessage. Reset the service so that any
// "MediaWiki:bad image list" articles added get fetched
$setup[] = static function () {
MediaWikiServices::getInstance()->resetServiceForTesting( 'BadFileLookup' );
};

$teardown[] = $this->executeSetupSnippets( $setup );

return $this->createTeardownObject( $teardown, $nextTeardown );
}

Expand Down
13 changes: 6 additions & 7 deletions tests/parser/parserTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22864,15 +22864,13 @@ comment

# Parsoid doesn't support this yet: see T75581
# but it *should* omit the 'src' attribute if the image is bad.
# PHP side of tests was disabled in
# mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
# because of issues in the PHP parserTests infrastructure
# (but the output below is indeed what the PHP side emits)
!! test
Bad images - basic functionality
!! wikitext
[[File:Bad.jpg]]
!! html/php+disabled
!! html/php
<p><a href="/wiki/File:Bad.jpg" title="File:Bad.jpg">File:Bad.jpg</a>
</p>
!! html/parsoid
<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./Special:FilePath/Bad.jpg"><span class="mw-broken-media" resource="./File:Bad.jpg">File:Bad.jpg</span></a></span></p>
!! end
Expand All @@ -22883,9 +22881,10 @@ Bad images - T18039: text after bad image disappears
Foo bar
[[File:Bad.jpg]]
Bar foo
!! html/php+disabled
!! html/php
<p>Foo bar
</p><p>Bar foo
<a href="/wiki/File:Bad.jpg" title="File:Bad.jpg">File:Bad.jpg</a>
Bar foo
</p>
!! html/parsoid
<p>Foo bar
Expand Down

0 comments on commit 8d48b61

Please sign in to comment.