Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / tests / phpunit / includes / changes / EnhancedChangesListTest.php
index a14a50d..b8be8d4 100644 (file)
@@ -14,7 +14,7 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
         */
        private $testRecentChangesHelper;
 
-       public function __construct( $name = null, array $data = array(), $dataName = '' ) {
+       public function __construct( $name = null, array $data = [], $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
 
                $this->testRecentChangesHelper = new TestRecentChangesHelper();
@@ -74,6 +74,20 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
                $this->assertEquals( '', $html );
        }
 
+       public function testCategorizationLineFormatting() {
+               $html = $this->createCategorizationLine(
+                       $this->getCategorizationChange( '20150629191735', 0, 0 )
+               );
+               $this->assertNotContains( '(diff | hist)', strip_tags( $html ) );
+       }
+
+       public function testCategorizationLineFormattingWithRevision() {
+               $html = $this->createCategorizationLine(
+                       $this->getCategorizationChange( '20150629191735', 1025, 1024 )
+               );
+               $this->assertContains( '(diff | hist)', strip_tags( $html ) );
+       }
+
        /**
         * @todo more tests for actual formatting, this is more of a smoke test
         */
@@ -115,6 +129,24 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
                return $recentChange;
        }
 
+       /**
+        * @return RecentChange
+        */
+       private function getCategorizationChange( $timestamp, $thisId, $lastId ) {
+               $wikiPage = new WikiPage( Title::newFromText( 'Testpage' ) );
+               $wikiPage->doEditContent( new WikitextContent( 'Some random text' ), 'page created' );
+
+               $wikiPage = new WikiPage( Title::newFromText( 'Category:Foo' ) );
+               $wikiPage->doEditContent( new WikitextContent( 'Some random text' ), 'category page created' );
+
+               $user = $this->getTestUser();
+               $recentChange = $this->testRecentChangesHelper->makeCategorizationRecentChange(
+                       $user, 'Category:Foo', $wikiPage->getId(), $thisId, $lastId, $timestamp
+               );
+
+               return $recentChange;
+       }
+
        /**
         * @return User
         */
@@ -128,4 +160,15 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
                return $user;
        }
 
+       private function createCategorizationLine( $recentChange ) {
+               $enhancedChangesList = $this->newEnhancedChangesList();
+               $cacheEntry = $this->testRecentChangesHelper->getCacheEntry( $recentChange );
+
+               $reflection = new \ReflectionClass( get_class( $enhancedChangesList ) );
+               $method = $reflection->getMethod( 'recentChangesBlockLine' );
+               $method->setAccessible( true );
+
+               return $method->invokeArgs( $enhancedChangesList, [ $cacheEntry ] );
+       }
+
 }