Index: trunk/phase3/tests/phpunit/includes/parser/TagHooks.php |
— | — | @@ -1,77 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * @group Parser |
6 | | - */ |
7 | | -class TagHookTest extends MediaWikiTestCase { |
8 | | - |
9 | | - public static function provideValidNames() { |
10 | | - return array( array( 'foo' ), array( 'foo-bar' ), array( 'foo_bar' ), array( 'FOO-BAR' ), array( 'foo bar' ) ); |
11 | | - } |
12 | | - |
13 | | - public static function provideBadNames() { |
14 | | - return array( array( "foo<bar" ), array( "foo>bar" ), array( "foo\nbar" ), array( "foo\rbar" ) ); |
15 | | - } |
16 | | - |
17 | | - /** |
18 | | - * @dataProvider provideValidNames |
19 | | - */ |
20 | | - function testTagHooks( $tag ) { |
21 | | - global $wgParserConf; |
22 | | - $parser = new Parser( $wgParserConf ); |
23 | | - |
24 | | - $parser->setHook( $tag, array( $this, 'tagCallback' ) ); |
25 | | - $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
26 | | - $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() ); |
27 | | - |
28 | | - $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle |
29 | | - } |
30 | | - |
31 | | - /** |
32 | | - * @dataProvider provideBadNames |
33 | | - * @expectedException MWException |
34 | | - */ |
35 | | - function testBadTagHooks( $tag ) { |
36 | | - global $wgParserConf; |
37 | | - $parser = new Parser( $wgParserConf ); |
38 | | - |
39 | | - $parser->setHook( $tag, array( $this, 'tagCallback' ) ); |
40 | | - $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
41 | | - $this->fail('Exception not thrown.'); |
42 | | - } |
43 | | - |
44 | | - /** |
45 | | - * @dataProvider provideValidNames |
46 | | - */ |
47 | | - function testFunctionTagHooks( $tag ) { |
48 | | - global $wgParserConf; |
49 | | - $parser = new Parser( $wgParserConf ); |
50 | | - |
51 | | - $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 ); |
52 | | - $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
53 | | - $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() ); |
54 | | - |
55 | | - $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle |
56 | | - } |
57 | | - |
58 | | - /** |
59 | | - * @dataProvider provideBadNames |
60 | | - * @expectedException MWException |
61 | | - */ |
62 | | - function testBadFunctionTagHooks( $tag ) { |
63 | | - global $wgParserConf; |
64 | | - $parser = new Parser( $wgParserConf ); |
65 | | - |
66 | | - $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS ); |
67 | | - $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
68 | | - $this->fail('Exception not thrown.'); |
69 | | - } |
70 | | - |
71 | | - function tagCallback( $text, $params, $parser ) { |
72 | | - return str_rot13( $text ); |
73 | | - } |
74 | | - |
75 | | - function functionTagCallback( &$parser, $frame, $code, $attribs ) { |
76 | | - return str_rot13( $code ); |
77 | | - } |
78 | | -} |
Index: trunk/phase3/tests/phpunit/includes/parser/TagHooksTest.php |
— | — | @@ -0,0 +1,77 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * @group Parser |
| 6 | + */ |
| 7 | +class TagHookTest extends MediaWikiTestCase { |
| 8 | + |
| 9 | + public static function provideValidNames() { |
| 10 | + return array( array( 'foo' ), array( 'foo-bar' ), array( 'foo_bar' ), array( 'FOO-BAR' ), array( 'foo bar' ) ); |
| 11 | + } |
| 12 | + |
| 13 | + public static function provideBadNames() { |
| 14 | + return array( array( "foo<bar" ), array( "foo>bar" ), array( "foo\nbar" ), array( "foo\rbar" ) ); |
| 15 | + } |
| 16 | + |
| 17 | + /** |
| 18 | + * @dataProvider provideValidNames |
| 19 | + */ |
| 20 | + function testTagHooks( $tag ) { |
| 21 | + global $wgParserConf; |
| 22 | + $parser = new Parser( $wgParserConf ); |
| 23 | + |
| 24 | + $parser->setHook( $tag, array( $this, 'tagCallback' ) ); |
| 25 | + $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
| 26 | + $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() ); |
| 27 | + |
| 28 | + $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * @dataProvider provideBadNames |
| 33 | + * @expectedException MWException |
| 34 | + */ |
| 35 | + function testBadTagHooks( $tag ) { |
| 36 | + global $wgParserConf; |
| 37 | + $parser = new Parser( $wgParserConf ); |
| 38 | + |
| 39 | + $parser->setHook( $tag, array( $this, 'tagCallback' ) ); |
| 40 | + $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
| 41 | + $this->fail('Exception not thrown.'); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @dataProvider provideValidNames |
| 46 | + */ |
| 47 | + function testFunctionTagHooks( $tag ) { |
| 48 | + global $wgParserConf; |
| 49 | + $parser = new Parser( $wgParserConf ); |
| 50 | + |
| 51 | + $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 ); |
| 52 | + $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
| 53 | + $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() ); |
| 54 | + |
| 55 | + $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @dataProvider provideBadNames |
| 60 | + * @expectedException MWException |
| 61 | + */ |
| 62 | + function testBadFunctionTagHooks( $tag ) { |
| 63 | + global $wgParserConf; |
| 64 | + $parser = new Parser( $wgParserConf ); |
| 65 | + |
| 66 | + $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS ); |
| 67 | + $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions ); |
| 68 | + $this->fail('Exception not thrown.'); |
| 69 | + } |
| 70 | + |
| 71 | + function tagCallback( $text, $params, $parser ) { |
| 72 | + return str_rot13( $text ); |
| 73 | + } |
| 74 | + |
| 75 | + function functionTagCallback( &$parser, $frame, $code, $attribs ) { |
| 76 | + return str_rot13( $code ); |
| 77 | + } |
| 78 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/parser/TagHooksTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 79 | + native |
Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfShorthandToInteger.php |
— | — | @@ -1,28 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class wfShorthandToIntegerTest extends MediaWikiTestCase { |
5 | | - /** |
6 | | - * @dataProvider provideABunchOfShorthands |
7 | | - */ |
8 | | - function testWfShorthandToInteger( $input, $output, $description ) { |
9 | | - $this->assertEquals( |
10 | | - wfShorthandToInteger( $input ), |
11 | | - $output, |
12 | | - $description |
13 | | - ); |
14 | | - } |
15 | | - |
16 | | - function provideABunchOfShorthands() { |
17 | | - return array( |
18 | | - array( '', -1, 'Empty string' ), |
19 | | - array( ' ', -1, 'String of spaces' ), |
20 | | - array( '1G', 1024 * 1024 * 1024, 'One gig uppercased' ), |
21 | | - array( '1g', 1024 * 1024 * 1024, 'One gig lowercased' ), |
22 | | - array( '1M', 1024 * 1024, 'One meg uppercased' ), |
23 | | - array( '1m', 1024 * 1024, 'One meg lowercased' ), |
24 | | - array( '1K', 1024, 'One kb uppercased' ), |
25 | | - array( '1k', 1024, 'One kb lowercased' ), |
26 | | - ); |
27 | | - } |
28 | | - |
29 | | -} |
Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class wfShorthandToIntegerTest extends MediaWikiTestCase { |
| 5 | + /** |
| 6 | + * @dataProvider provideABunchOfShorthands |
| 7 | + */ |
| 8 | + function testWfShorthandToInteger( $input, $output, $description ) { |
| 9 | + $this->assertEquals( |
| 10 | + wfShorthandToInteger( $input ), |
| 11 | + $output, |
| 12 | + $description |
| 13 | + ); |
| 14 | + } |
| 15 | + |
| 16 | + function provideABunchOfShorthands() { |
| 17 | + return array( |
| 18 | + array( '', -1, 'Empty string' ), |
| 19 | + array( ' ', -1, 'String of spaces' ), |
| 20 | + array( '1G', 1024 * 1024 * 1024, 'One gig uppercased' ), |
| 21 | + array( '1g', 1024 * 1024 * 1024, 'One gig lowercased' ), |
| 22 | + array( '1M', 1024 * 1024, 'One meg uppercased' ), |
| 23 | + array( '1m', 1024 * 1024, 'One meg lowercased' ), |
| 24 | + array( '1K', 1024, 'One kb uppercased' ), |
| 25 | + array( '1k', 1024, 'One kb lowercased' ), |
| 26 | + ); |
| 27 | + } |
| 28 | + |
| 29 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |