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 // XXX: currently, preSaveTransform is applied to scripts. this may change or become optional.
81 public function dataPreSaveTransform() {
83 array( 'hello this is ~~~',
86 array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
87 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
93 public function dataPreloadTransform() {
95 array( 'hello this is ~~~',
98 array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
99 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
104 public function dataGetRedirectTarget() {
106 array( '#REDIRECT [[Test]]',
109 array( '#REDIRECT Test',
112 array( '* #REDIRECT [[Test]]',
119 * @todo: test needs database!
122 public function getRedirectChain() {
123 $text = $this->getNativeData();
124 return Title::newFromRedirectArray( $text );
129 * @todo: test needs database!
132 public function getUltimateRedirectTarget() {
133 $text = $this->getNativeData();
134 return Title::newFromRedirectRecurse( $text );
139 public function dataIsCountable() {
166 array( 'Foo [[bar]]',
176 array( 'Foo [[bar]]',
181 array( '#REDIRECT [[bar]]',
186 array( '#REDIRECT [[bar]]',
191 array( '#REDIRECT [[bar]]',
199 public function dataGetTextForSummary() {
201 array( "hello\nworld.",
205 array( 'hello world.',
209 array( '[[hello world]].',
216 # =================================================================================================================
218 public function testGetModel() {
219 $content = $this->newContent( "hello world." );
221 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getModel() );
224 public function testGetContentHandler() {
225 $content = $this->newContent( "hello world." );
227 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getContentHandler()->getModelID() );
230 public function dataEquals( ) {
232 array( new JavascriptContent( "hallo" ), null, false ),
233 array( new JavascriptContent( "hallo" ), new JavascriptContent( "hallo" ), true ),
234 array( new JavascriptContent( "hallo" ), new CssContent( "hallo" ), false ),
235 array( new JavascriptContent( "hallo" ), new JavascriptContent( "HALLO" ), false ),