mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-14 10:34:53 +00:00
22627f074d
There was a call in the API that was *not* using normalizeKey(). Now that the API is gone, we can inline this. This patch also contains a bunch of cleanups that might already been resolved in the previous patches. Change-Id: Id3767b5830268c8cfe9c10efabfa4a31e9dafeb8
47 lines
1 KiB
PHP
47 lines
1 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\CiteKeyFormatter;
|
|
use MediaWikiUnitTestCase;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @coversDefaultClass \Cite\CiteKeyFormatter
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CiteKeyFormatterTest extends MediaWikiUnitTestCase {
|
|
|
|
public function setUp() : void {
|
|
parent::setUp();
|
|
|
|
global $wgFragmentMode;
|
|
$wgFragmentMode = [ 'html5' ];
|
|
}
|
|
|
|
/**
|
|
* @covers ::normalizeKey
|
|
* @dataProvider provideKeyNormalizations
|
|
*/
|
|
public function testNormalizeKey( $key, $expected ) {
|
|
/** @var CiteKeyFormatter $formatter */
|
|
$formatter = TestingAccessWrapper::newFromObject( new CiteKeyFormatter() );
|
|
$this->assertSame( $expected, $formatter->normalizeKey( $key ) );
|
|
}
|
|
|
|
public function provideKeyNormalizations() {
|
|
return [
|
|
[ 'a b', 'a_b' ],
|
|
[ 'a __ b', 'a_b' ],
|
|
[ ':', ':' ],
|
|
[ "\t\n", '	 ' ],
|
|
[ "'", ''' ],
|
|
[ "''", '''' ],
|
|
[ '"%&/<>?[]{|}', '"%&/<>?[]{|}' ],
|
|
[ 'ISBN', 'ISBN' ],
|
|
];
|
|
}
|
|
|
|
}
|