4 * @group ContentHandler
6 class JavascriptContentTest
extends WikitextContentTest
{
8 public function newContent( $text ) {
9 return new JavascriptContent( $text );
13 public function dataGetParserOutput() {
15 array("MediaWiki:Test.js", "hello <world>\n",
16 "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
21 public function dataGetSection() {
23 array( WikitextContentTest
::$sections,
27 array( WikitextContentTest
::$sections,
31 array( WikitextContentTest
::$sections,
38 public function dataReplaceSection() {
40 array( WikitextContentTest
::$sections,
46 array( WikitextContentTest
::$sections,
52 array( WikitextContentTest
::$sections,
54 "== TEST ==\nmore fun",
58 array( WikitextContentTest
::$sections,
64 array( WikitextContentTest
::$sections,
73 public function testAddSectionHeader( ) {
74 $content = $this->newContent( 'hello world' );
75 $c = $content->addSectionHeader( 'test' );
77 $this->assertTrue( $content->equals( $c ) );
80 // XXX: currently, preSaveTransform is applied to scripts. this may change or become optional.
82 public function dataPreSaveTransform() {
84 array( 'hello this is ~~~',
87 array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
88 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
94 public function dataPreloadTransform() {
96 array( 'hello this is ~~~',
99 array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
100 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
105 public function dataGetRedirectTarget() {
107 array( '#REDIRECT [[Test]]',
110 array( '#REDIRECT Test',
113 array( '* #REDIRECT [[Test]]',
120 * @todo: test needs database!
123 public function getRedirectChain() {
124 $text = $this->getNativeData();
125 return Title::newFromRedirectArray( $text );
130 * @todo: test needs database!
133 public function getUltimateRedirectTarget() {
134 $text = $this->getNativeData();
135 return Title::newFromRedirectRecurse( $text );
140 public function dataIsCountable() {
167 array( 'Foo [[bar]]',
177 array( 'Foo [[bar]]',
182 array( '#REDIRECT [[bar]]',
187 array( '#REDIRECT [[bar]]',
192 array( '#REDIRECT [[bar]]',
200 public function dataGetTextForSummary() {
202 array( "hello\nworld.",
206 array( 'hello world.',
210 array( '[[hello world]].',
217 # =================================================================================================================
219 public function testGetModel() {
220 $content = $this->newContent( "hello world." );
222 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getModel() );
225 public function testGetContentHandler() {
226 $content = $this->newContent( "hello world." );
228 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getContentHandler()->getModelID() );
231 public function dataEquals( ) {
233 array( new JavascriptContent( "hallo" ), null, false ),
234 array( new JavascriptContent( "hallo" ), new JavascriptContent( "hallo" ), true ),
235 array( new JavascriptContent( "hallo" ), new CssContent( "hallo" ), false ),
236 array( new JavascriptContent( "hallo" ), new JavascriptContent( "HALLO" ), false ),