Use interwiki cache directly to resolve transwiki import sources
[lhc/web/wiklou.git] / tests / phpunit / includes / changes / RecentChangeTest.php
index 0dba183..ab35453 100644 (file)
@@ -76,6 +76,19 @@ class RecentChangeTest extends MediaWikiTestCase {
                        ),
                        $this->user_comment
                );
+               # block/block - legacy
+               $this->assertIRCComment(
+                       $this->context->msg( 'blocklogentry', 'SomeTitle', 'duration', '(flags)' )->plain()
+                               . $sep . $this->user_comment,
+                       'block', 'block',
+                       array(
+                               'duration',
+                               'flags',
+                       ),
+                       $this->user_comment,
+                       '',
+                       true
+               );
                # block/unblock
                $this->assertIRCComment(
                        $this->context->msg( 'unblocklogentry', 'SomeTitle' )->plain() . $sep . $this->user_comment,
@@ -284,16 +297,22 @@ class RecentChangeTest extends MediaWikiTestCase {
                $sep = $this->context->msg( 'colon-separator' )->text();
 
                # import/upload
+               $msg = $this->context->msg( 'import-logentry-upload', 'SomeTitle' )->plain() .
+                       $sep .
+                       $this->user_comment;
                $this->assertIRCComment(
-                       $this->context->msg( 'import-logentry-upload', 'SomeTitle' )->plain() . $sep . $this->user_comment,
+                       $msg,
                        'import', 'upload',
                        array(),
                        $this->user_comment
                );
 
                # import/interwiki
+               $msg = $this->context->msg( 'import-logentry-interwiki', 'SomeTitle' )->plain() .
+                       $sep .
+                       $this->user_comment;
                $this->assertIRCComment(
-                       $this->context->msg( 'import-logentry-interwiki', 'SomeTitle' )->plain() . $sep . $this->user_comment,
+                       $msg,
                        'import', 'interwiki',
                        array(),
                        $this->user_comment
@@ -323,6 +342,51 @@ class RecentChangeTest extends MediaWikiTestCase {
        }
        */
 
+       /**
+        * @covers RecentChange::parseParams
+        */
+       public function testParseParams() {
+               $params = array(
+                       'root' => array(
+                               'A' => 1,
+                               'B' => 'two'
+                       )
+               );
+
+               $this->assertParseParams(
+                       $params,
+                       'a:1:{s:4:"root";a:2:{s:1:"A";i:1;s:1:"B";s:3:"two";}}'
+               );
+
+               $this->assertParseParams(
+                       null,
+                       null
+               );
+
+               $this->assertParseParams(
+                       null,
+                       serialize( false )
+               );
+
+               $this->assertParseParams(
+                       null,
+                       'not-an-array'
+               );
+       }
+
+       /**
+        * @param array $expectedParseParams
+        * @param string|null $rawRcParams
+        */
+       protected function assertParseParams( $expectedParseParams, $rawRcParams ) {
+               $rc = new RecentChange;
+               $rc->setAttribs( array( 'rc_params' => $rawRcParams ) );
+
+               $actualParseParams = $rc->parseParams();
+
+               $this->assertEquals( $expectedParseParams, $actualParseParams );
+       }
+
        /**
         * @param string $expected Expected IRC text without colors codes
         * @param string $type Log type (move, delete, suppress, patrol ...)
@@ -332,7 +396,7 @@ class RecentChangeTest extends MediaWikiTestCase {
         * @param string $msg (optional) A message for PHPUnit :-)
         */
        protected function assertIRCComment( $expected, $type, $action, $params,
-               $comment = null, $msg = ''
+               $comment = null, $msg = '', $legacy = false
        ) {
                $logEntry = new ManualLogEntry( $type, $action );
                $logEntry->setPerformer( $this->user );
@@ -341,6 +405,7 @@ class RecentChangeTest extends MediaWikiTestCase {
                        $logEntry->setComment( $comment );
                }
                $logEntry->setParameters( $params );
+               $logEntry->setLegacy( $legacy );
 
                $formatter = LogFormatter::newFromEntry( $logEntry );
                $formatter->setContext( $this->context );