Fix getAutosummary for create blank page
authorflorianschmidtwelzow <florian.schmidt.welzow@t-online.de>
Sun, 27 Jul 2014 12:18:26 +0000 (14:18 +0200)
committerFlorianschmidtwelzow <florian.schmidt.welzow@t-online.de>
Sun, 27 Jul 2014 12:22:07 +0000 (12:22 +0000)
Fixes for change to enable the creation of blank pages. Added test
for this case.

Follow up: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386

Bug: 57238
Change-Id: Id52be6cbe22c6098d1c0824d7a7848579aa05a84

includes/content/ContentHandler.php
tests/phpunit/includes/content/ContentHandlerTest.php

index 1d7a7a7..c8a9f1e 100644 (file)
@@ -822,8 +822,8 @@ abstract class ContentHandler {
                }
 
                // New blank article auto-summary
-               if ( $flags && EDIT_NEW && $newContent->getSize() == 0 ) {
-                       return wfMessage( 'autosumm-newblank' ) ->inContentLanguage()->text();
+               if ( $flags & EDIT_NEW && $newContent->isEmpty() ) {
+                       return wfMessage( 'autosumm-newblank' )->inContentLanguage()->text();
                }
 
                // If we reach this point, there's no applicable auto-summary for our
index 2add9f2..b564a29 100644 (file)
@@ -312,6 +312,23 @@ class ContentHandlerTest extends MediaWikiTestCase {
                }
        }
 
+       /*
+        * Test if we become a "Created blank page" summary from getAutoSummary if no Content added to
+        * page.
+        */
+       public function testGetAutosummary() {
+               $content = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
+               $title = Title::newFromText( 'Help:Test' );
+               // Create a new content object with no content
+               $newContent = ContentHandler::makeContent( '', $title, null, null, CONTENT_MODEL_WIKITEXT );
+               // first check, if we become a blank page created summary with the right bitmask
+               $autoSummary = $content->getAutosummary( null, $newContent, 97 );
+               $this->assertEquals( $autoSummary, 'Created blank page' );
+               // now check, what we become with another bitmask
+               $autoSummary = $content->getAutosummary( null, $newContent, 92 );
+               $this->assertEquals( $autoSummary, '' );
+       }
+
        /*
        public function testSupportsSections() {
                $this->markTestIncomplete( "not yet implemented" );