X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fphpunit%2Fincludes%2FLinksUpdateTest.php;h=b37ff2e3b76692ef49a5134da5944b788cedea5c;hb=c739d8c4fccc9686ee2b196bbeeeec7542dbaf03;hp=c83f7dac45b815c1ecefa21807ea03fed2b6fefe;hpb=4cac99baae22b4459327ef9982d98f89b19fea4a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/LinksUpdateTest.php b/tests/phpunit/includes/LinksUpdateTest.php index c83f7dac45..b37ff2e3b7 100644 --- a/tests/phpunit/includes/LinksUpdateTest.php +++ b/tests/phpunit/includes/LinksUpdateTest.php @@ -52,6 +52,9 @@ class LinksUpdateTest extends MediaWikiTestCase { return array( $t, $po ); } + /** + * @covers LinksUpdate::addLink + */ public function testUpdate_pagelinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -60,20 +63,35 @@ 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 LinksUpdate::addExternalLink + */ public function testUpdate_externallinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -84,6 +102,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addCategory + */ public function testUpdate_categorylinks() { $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' ); @@ -96,6 +117,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addInterwikiLink + */ public function testUpdate_iwlinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -107,6 +131,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addTemplate + */ public function testUpdate_templatelinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -117,28 +144,35 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addImage + */ public function testUpdate_imagelinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); $po->addImage( "Foo.png" ); - $this->assertLinksUpdate( $t, $po, 'imagelinks', 'il_to', 'il_from = 111', array( array( 'Foo.png' ), ) ); } + /** + * @covers LinksUpdate::addLanguageLink + */ public function testUpdate_langlinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); $po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() ); - $this->assertLinksUpdate( $t, $po, 'langlinks', 'll_lang, ll_title', 'll_from = 111', array( array( 'En', 'Foo' ), ) ); } + /** + * @covers LinksUpdate::setProperty + */ public function testUpdate_page_props() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -149,7 +183,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 ); @@ -160,5 +194,6 @@ class LinksUpdateTest extends MediaWikiTestCase { $update->commitTransaction(); $this->assertSelect( $table, $fields, $condition, $expectedRows ); + return $update; } }