Merge "Provide direction hinting in the personal toolbar"
[lhc/web/wiklou.git] / tests / phpunit / includes / LinksUpdateTest.php
index ae551c0..33643ac 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 /**
- *
  * @group Database
  * ^--- make sure temporary tables are used.
  */
@@ -52,7 +51,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                return array( $t, $po );
        }
 
+       /**
+        * @covers ParserOutput::addLink
+        */
        public function testUpdate_pagelinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->addLink( Title::newFromText( "Foo" ) );
@@ -60,21 +63,37 @@ class LinksUpdateTest extends MediaWikiTestCase {
                $po->addLink( Title::newFromText( "linksupdatetest:Foo" ) ); // interwiki link should be ignored
                $po->addLink( Title::newFromText( "#Foo" ) ); // hash link should be ignored
 
-               $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
+               $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
                        array( NS_MAIN, 'Foo' ),
                ) );
+               $this->assertArrayEquals( array(
+                       Title::makeTitle( NS_MAIN, 'Foo' ),  // newFromText doesn't yield the same internal state....
+               ), $update->getAddedLinks() );
 
                $po = new ParserOutput();
                $po->setTitleText( $t->getPrefixedText() );
 
                $po->addLink( Title::newFromText( "Bar" ) );
+               $po->addLink( Title::newFromText( "Talk:Bar" ) );
 
-               $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
+               $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
                        array( NS_MAIN, 'Bar' ),
+                       array( NS_TALK, 'Bar' ),
                ) );
+               $this->assertArrayEquals( array(
+                       Title::makeTitle( NS_MAIN, 'Bar' ),
+                       Title::makeTitle( NS_TALK, 'Bar' ),
+               ), $update->getAddedLinks() );
+               $this->assertArrayEquals( array(
+                       Title::makeTitle( NS_MAIN, 'Foo' ),
+               ), $update->getRemovedLinks() );
        }
 
+       /**
+        * @covers ParserOutput::addExternalLink
+        */
        public function testUpdate_externallinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->addExternalLink( "http://testing.com/wiki/Foo" );
@@ -84,7 +103,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::addCategory
+        */
        public function testUpdate_categorylinks() {
+               /** @var ParserOutput $po */
                $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
 
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
@@ -96,7 +119,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::addInterwikiLink
+        */
        public function testUpdate_iwlinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $target = Title::makeTitleSafe( NS_MAIN, "Foo", '', 'linksupdatetest' );
@@ -107,7 +134,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::addTemplate
+        */
        public function testUpdate_templatelinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
@@ -117,7 +148,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::addImage
+        */
        public function testUpdate_imagelinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->addImage( "Foo.png" );
@@ -127,7 +162,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::addLanguageLink
+        */
        public function testUpdate_langlinks() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() );
@@ -137,7 +176,11 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
+       /**
+        * @covers ParserOutput::setProperty
+        */
        public function testUpdate_page_props() {
+               /** @var ParserOutput $po */
                list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 );
 
                $po->setProperty( "foo", "bar" );
@@ -147,7 +190,7 @@ class LinksUpdateTest extends MediaWikiTestCase {
                ) );
        }
 
-       #@todo: test recursive, too!
+       // @todo test recursive, too!
 
        protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
                $update = new LinksUpdate( $title, $parserOutput );
@@ -158,5 +201,6 @@ class LinksUpdateTest extends MediaWikiTestCase {
                $update->commitTransaction();
 
                $this->assertSelect( $table, $fields, $condition, $expectedRows );
+               return $update;
        }
 }