mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Merge "Add dedicated unit test for Cite::refArg()"
This commit is contained in:
commit
e9383f3cf4
|
@ -11,10 +11,49 @@ class CiteTest extends MediaWikiTestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgCiteBookReferencing' => true,
|
||||
'wgFragmentMode' => [ 'html5' ],
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::refArg
|
||||
* @dataProvider provideRefAttributes
|
||||
*/
|
||||
public function testRefArg( array $attributes, array $expected ) {
|
||||
/** @var Cite $cite */
|
||||
$cite = TestingAccessWrapper::newFromObject( new Cite() );
|
||||
$this->assertSame( $expected, $cite->refArg( $attributes ) );
|
||||
}
|
||||
|
||||
public function provideRefAttributes() {
|
||||
return [
|
||||
[ [], [ null, null, false, null ] ],
|
||||
|
||||
// One attribute only
|
||||
[ [ 'dir' => 'invalid' ], [ null, null, false, '' ] ],
|
||||
[ [ 'dir' => 'rtl' ], [ null, null, false, ' class="mw-cite-dir-rtl"' ] ],
|
||||
[ [ 'follow' => 'f' ], [ null, null, 'f', null ] ],
|
||||
[ [ 'group' => 'g' ], [ null, 'g', null, null ] ],
|
||||
[ [ 'invalid' => 'i' ], [ false, false, false, false ] ],
|
||||
[ [ 'name' => 'n' ], [ 'n', null, null, null ] ],
|
||||
[ [ 'name' => null ], [ false, false, false, false ] ],
|
||||
[ [ 'refines' => 'r' ], [ null, null, null, null ] ],
|
||||
|
||||
// Pairs
|
||||
[ [ 'follow' => 'f', 'name' => 'n' ], [ false, false, false, false ] ],
|
||||
[ [ 'follow' => null, 'name' => null ], [ false, false, false, false ] ],
|
||||
[ [ 'follow' => 'f', 'refines' => 'r' ], [ null, null, 'f', null ] ],
|
||||
[ [ 'group' => 'r', 'name' => 'n' ], [ 'n', 'r', null, null ] ],
|
||||
|
||||
// Combinations of 3 or more attributes
|
||||
[
|
||||
[ 'group' => 'r', 'name' => 'n', 'refines' => 'f', 'dir' => 'rtl' ],
|
||||
[ 'n', 'r', null, ' class="mw-cite-dir-rtl"' ]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::normalizeKey
|
||||
* @dataProvider provideKeyNormalizations
|
||||
|
|
Loading…
Reference in a new issue