mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-12 01:01:29 +00:00
Add the first small PHPUnit test for Cite::normalizeKey()
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
This commit is contained in:
parent
16b757b88d
commit
64c94662f0
41
tests/phpunit/CiteTest.php
Normal file
41
tests/phpunit/CiteTest.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?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' ],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue