diff --git a/tests/phpunit/CiteTest.php b/tests/phpunit/CiteTest.php new file mode 100644 index 000000000..87a1e3278 --- /dev/null +++ b/tests/phpunit/CiteTest.php @@ -0,0 +1,41 @@ +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' ], + ]; + } + +}