Skip to content

Commit

Permalink
Add lint test for multiple media formats defined
Browse files Browse the repository at this point in the history
Bug: T305641
Change-Id: I99c916d187baecd8e681ddb0f08bba323210c948
  • Loading branch information
arlolra committed Apr 12, 2022
1 parent 68556f6 commit 9023f63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Mocks/MockSiteConfig.php
Expand Up @@ -294,10 +294,13 @@ protected function updateFunctionSynonym( string $func, string $magicword, bool
/** @inheritDoc */
protected function getMagicWords(): array {
return [
'toc' => [ 0, '__TOC__' ],
'img_thumbnail' => [ 1, 'thumb' ],
'img_none' => [ 1, 'none' ],
'notoc' => [ 0, '__NOTOC__' ]
'toc' => [ 0, '__TOC__' ],
'img_thumbnail' => [ 1, 'thumb' ],
'img_framed' => [ 1, 'frame', 'framed' ],
'img_frameless' => [ 1, 'frameless' ],
'img_manualthumb' => [ 1, 'thumbnail=$1', 'thumb=$1' ],
'img_none' => [ 1, 'none' ],
'notoc' => [ 0, '__NOTOC__' ],
];
}

Expand Down
20 changes: 20 additions & 0 deletions tests/phpunit/Parsoid/Wt2Html/PP/Processors/LinterTest.php
Expand Up @@ -365,6 +365,26 @@ public function testBogusImageOptions(): void {
$this->assertEquals( [ 136, 180, 2, 2 ], $result[3]['dsr'], $desc );
$this->assertTrue( isset( $result[3]['params'] ), $desc );
$this->assertEquals( 'upright=-1', $result[3]['params']['items'][0], $desc );

$desc = "should lint multiple media formats, first one wins";
$result = $this->parseWT(
'[[File:Foobar.jpg|frame|frameless]]' .
'[[File:Foobar.jpg|frameless|frame]]' .
'[[File:Foobar.jpg|thumbnail=Thumb.png|thumb]]'
);
$this->assertCount( 3, $result, $desc );
$this->assertEquals( 'bogus-image-options', $result[0]['type'], $desc );
$this->assertEquals( [ 0, 35, 2, 2 ], $result[0]['dsr'], $desc );
$this->assertTrue( isset( $result[0]['params'] ), $desc );
$this->assertEquals( 'frameless', $result[0]['params']['items'][0], $desc );
$this->assertEquals( 'bogus-image-options', $result[1]['type'], $desc );
$this->assertEquals( [ 35, 70, null, null ], $result[1]['dsr'], $desc );
$this->assertTrue( isset( $result[1]['params'] ), $desc );
$this->assertEquals( 'frame', $result[1]['params']['items'][0], $desc );
$this->assertEquals( 'bogus-image-options', $result[2]['type'], $desc );
$this->assertEquals( [ 70, 115, 2, 2 ], $result[2]['dsr'], $desc );
$this->assertTrue( isset( $result[2]['params'] ), $desc );
$this->assertEquals( 'thumb', $result[2]['params']['items'][0], $desc );
}

// /**
Expand Down

0 comments on commit 9023f63

Please sign in to comment.