assertRegExp( "~^$pattern$~", $result['template'], $comment ); } public static function provideTestSectionise() { // Ugly implicit assumption $ph = "\x7fUNIQ[a-z0-9]{8,16}-\d+"; $cases = []; $cases[] = [ 'Hello', "$ph", 'No surrounding whitespace', ]; $cases[] = [ "\nHello", "\n$ph", 'With surrounding whitespace', ]; $cases[] = [ "\nHello world\n\nBunny\n", "\n$ph\n\n$ph\n", 'Splitting at one empty line', ]; $cases[] = [ "First\n\n\n\n\nSecond\n\nThird", "$ph\n\n\n\n\n$ph\n\n$ph", 'Splitting with multiple empty lines', ]; return $cases; } /** * @dataProvider provideTestCleanupTags */ public function testCleanupTags( $input, $expected, $comment ) { $output = TranslatablePage::cleanupTags( $input ); $this->assertEquals( $expected, $output, $comment ); } public static function provideTestCleanupTags() { $cases = []; $cases[] = [ "== Hello ==\n", '== Hello ==', 'Unbalanced tag in a section preview', ]; $cases[] = [ "", '', 'Unbalanced tags, no whitespace', ]; $cases[] = [ "1\n23\n45\n6", "1\n23\n45\n6", 'Unbalanced tags, non-removable whitespace', ]; $cases[] = [ "1\n\n2", '12', 'Unbalanced tags, removable whitespace', ]; $cases[] = [ '[[Special:MyLanguage/Wikimedia Foundation|Wikimedia Foundation]].', '[[Special:MyLanguage/Wikimedia Foundation|Wikimedia Foundation]].', 'TVAR tag is collapsed', ]; $cases[] = [ 'You can use the tag.', 'You can use the tag.', 'Tag inside a nowiki is retained', ]; $cases[] = [ 'What if I .', 'What if I