7a12ada5cd797a2f2eecf5a476bf9936fd36d5fb
4 * @group ContentHandler
6 class JavascriptContentTest
extends WikitextContentTest
{
8 public function newContent( $text ) {
9 return new JavascriptContent( $text );
13 public function dataGetParserOutput() {
15 array("hello <world>\n", "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
20 public function dataGetSection() {
22 array( WikitextContentTest
::$sections,
26 array( WikitextContentTest
::$sections,
30 array( WikitextContentTest
::$sections,
37 public function dataReplaceSection() {
39 array( WikitextContentTest
::$sections,
45 array( WikitextContentTest
::$sections,
51 array( WikitextContentTest
::$sections,
53 "== TEST ==\nmore fun",
57 array( WikitextContentTest
::$sections,
63 array( WikitextContentTest
::$sections,
72 public function testAddSectionHeader( ) {
73 $content = $this->newContent( 'hello world' );
74 $c = $content->addSectionHeader( 'test' );
76 $this->assertTrue( $content->equals( $c ) );
79 public function dataPreSaveTransform() {
81 array( 'hello this is ~~~',
84 array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
85 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
90 public function dataPreloadTransform() {
92 array( 'hello this is ~~~',
95 array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
96 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
101 public function dataGetRedirectTarget() {
103 array( '#REDIRECT [[Test]]',
106 array( '#REDIRECT Test',
109 array( '* #REDIRECT [[Test]]',
116 * @todo: test needs database!
119 public function getRedirectChain() {
120 $text = $this->getNativeData();
121 return Title::newFromRedirectArray( $text );
126 * @todo: test needs database!
129 public function getUltimateRedirectTarget() {
130 $text = $this->getNativeData();
131 return Title::newFromRedirectRecurse( $text );
136 public function dataIsCountable() {
163 array( 'Foo [[bar]]',
173 array( 'Foo [[bar]]',
178 array( '#REDIRECT [[bar]]',
183 array( '#REDIRECT [[bar]]',
188 array( '#REDIRECT [[bar]]',
196 public function dataGetTextForSummary() {
198 array( "hello\nworld.",
202 array( 'hello world.',
206 array( '[[hello world]].',
213 # =================================================================================================================
215 public function testGetModel() {
216 $content = $this->newContent( "hello world." );
218 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getModel() );
221 public function testGetContentHandler() {
222 $content = $this->newContent( "hello world." );
224 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getContentHandler()->getModelID() );
227 public function dataEquals( ) {
229 array( new JavascriptContent( "hallo" ), null, false ),
230 array( new JavascriptContent( "hallo" ), new JavascriptContent( "hallo" ), true ),
231 array( new JavascriptContent( "hallo" ), new CssContent( "hallo" ), false ),
232 array( new JavascriptContent( "hallo" ), new JavascriptContent( "HALLO" ), false ),