mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-14 10:34:53 +00:00
64c94662f0
Note this is intentionally testing a private method. As of now, the code is so heavily entangled, it's not yet possible to test individual aspects without calling private methods. The plan is to slowly increase the overall test coverage, and the start restructuring the code as necessary. Change-Id: Ib3b01bddaffd0469fb66979c67c8114a5807df6d
42 lines
857 B
PHP
42 lines
857 B
PHP
<?php
|
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @coversDefaultClass \Cite
|
|
*/
|
|
class CiteTest extends MediaWikiTestCase {
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
|
|
$this->setMwGlobals( [
|
|
'wgFragmentMode' => [ 'html5' ],
|
|
] );
|
|
}
|
|
|
|
/**
|
|
* @covers ::normalizeKey
|
|
* @dataProvider provideKeyNormalizations
|
|
*/
|
|
public function testNormalizeKey( $key, $expected ) {
|
|
/** @var Cite $cite */
|
|
$cite = TestingAccessWrapper::newFromObject( new Cite() );
|
|
$this->assertSame( $expected, $cite->normalizeKey( $key ) );
|
|
}
|
|
|
|
public function provideKeyNormalizations() {
|
|
return [
|
|
[ 'a b', 'a_b' ],
|
|
[ 'a __ b', 'a_b' ],
|
|
[ ':', ':' ],
|
|
[ "\t\n", '	 ' ],
|
|
[ "'", ''' ],
|
|
[ "''", '''' ],
|
|
[ '"%&/<>?[]{|}', '"%&/<>?[]{|}' ],
|
|
[ 'ISBN', 'ISBN' ],
|
|
];
|
|
}
|
|
|
|
}
|