3 class JavascriptContentTest
extends WikitextContentTest
{
5 public function newContent( $text ) {
6 return new JavascriptContent( $text );
10 public function dataGetParserOutput() {
12 array("hello <world>\n", "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
17 public function dataGetSection() {
19 array( WikitextContentTest
::$sections,
23 array( WikitextContentTest
::$sections,
27 array( WikitextContentTest
::$sections,
34 public function dataReplaceSection() {
36 array( WikitextContentTest
::$sections,
42 array( WikitextContentTest
::$sections,
48 array( WikitextContentTest
::$sections,
50 "== TEST ==\nmore fun",
54 array( WikitextContentTest
::$sections,
60 array( WikitextContentTest
::$sections,
69 public function testAddSectionHeader( ) {
70 $content = $this->newContent( 'hello world' );
71 $c = $content->addSectionHeader( 'test' );
73 $this->assertTrue( $content->equals( $c ) );
76 public function dataPreSaveTransform() {
78 array( 'hello this is ~~~',
81 array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
82 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
87 public function dataPreloadTransform() {
89 array( 'hello this is ~~~',
92 array( 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
93 'hello \'\'this\'\' is <noinclude>foo</noinclude><includeonly>bar</includeonly>',
98 public function dataGetRedirectTarget() {
100 array( '#REDIRECT [[Test]]',
103 array( '#REDIRECT Test',
106 array( '* #REDIRECT [[Test]]',
113 * @todo: test needs database!
116 public function getRedirectChain() {
117 $text = $this->getNativeData();
118 return Title::newFromRedirectArray( $text );
123 * @todo: test needs database!
126 public function getUltimateRedirectTarget() {
127 $text = $this->getNativeData();
128 return Title::newFromRedirectRecurse( $text );
133 public function dataIsCountable() {
160 array( 'Foo [[bar]]',
170 array( 'Foo [[bar]]',
175 array( '#REDIRECT [[bar]]',
180 array( '#REDIRECT [[bar]]',
185 array( '#REDIRECT [[bar]]',
193 public function dataGetTextForSummary() {
195 array( "hello\nworld.",
199 array( 'hello world.',
203 array( '[[hello world]].',
210 # =================================================================================================================
212 public function getModelName() {
213 $content = $this->newContent( "hello world." );
215 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getModelName() );
218 public function getContentHandler() {
219 $content = $this->newContent( "hello world." );
221 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $content->getContentHandler()->getModelName() );
224 public function dataEquals( ) {
226 array( new JavascriptContent( "hallo" ), null, false ),
227 array( new JavascriptContent( "hallo" ), new JavascriptContent( "hallo" ), true ),
228 array( new JavascriptContent( "hallo" ), new CssContent( "hallo" ), false ),
229 array( new JavascriptContent( "hallo" ), new JavascriptContent( "HALLO" ), false ),