3 use MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate
;
4 use MediaWiki\Deferred\LinksUpdate\LinksUpdate
;
5 use MediaWiki\Parser\ParserOutput
;
6 use MediaWiki\Title\TitleValue
;
9 * @covers \MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate
10 * @covers \MediaWiki\Deferred\LinksUpdate\LinksUpdate
11 * @covers \MediaWiki\Deferred\LinksUpdate\CategoryLinksTable
12 * @covers \MediaWiki\Deferred\LinksUpdate\ExternalLinksTable
13 * @covers \MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable
14 * @covers \MediaWiki\Deferred\LinksUpdate\ImageLinksTable
15 * @covers \MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable
16 * @covers \MediaWiki\Deferred\LinksUpdate\LangLinksTable
17 * @covers \MediaWiki\Deferred\LinksUpdate\LinksTable
18 * @covers \MediaWiki\Deferred\LinksUpdate\LinksTableGroup
19 * @covers \MediaWiki\Deferred\LinksUpdate\PageLinksTable
20 * @covers \MediaWiki\Deferred\LinksUpdate\PagePropsTable
21 * @covers \MediaWiki\Deferred\LinksUpdate\TemplateLinksTable
22 * @covers \MediaWiki\Deferred\LinksUpdate\TitleLinksTable
26 * ^--- make sure temporary tables are used.
28 class LinksDeletionUpdateTest
extends MediaWikiLangTestCase
{
29 public function testUpdate() {
30 $res = $this->insertPage( 'Source' );
32 $title = $res['title'];
33 $wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
35 $po = new ParserOutput();
36 $po->addCategory( new TitleValue( NS_CATEGORY
, 'Cat' ), 'cat' );
37 $po->addExternalLink( 'https://en.wikipedia.org/' );
38 $po->addImage( new TitleValue( NS_FILE
, 'Wiki.png' ) );
39 $po->addLink( new TitleValue( 0, 'foo', '', 'iwprefix' ) );
40 $po->addLanguageLink( new TitleValue( 0, 'Francais', '', 'fr' ) );
41 $po->addLink( new TitleValue( 0, 'Target' ) );
42 $po->setNumericPageProperty( 'int', 1 );
43 $po->addTemplate( new TitleValue( NS_TEMPLATE
, '!' ), 1, 1 );
45 $linksUpdate = new LinksUpdate( $title, $po, false );
46 $linksUpdate->setTransactionTicket(
47 $this->getServiceContainer()->getConnectionProvider()->getEmptyTransactionTicket( __METHOD__
)
49 $linksUpdate->doUpdate();
52 'categorylinks' => 'cl_from',
53 'externallinks' => 'el_from',
54 'imagelinks' => 'il_from',
55 'iwlinks' => 'iwl_from',
56 'langlinks' => 'll_from',
57 'pagelinks' => 'pl_from',
58 'page_props' => 'pp_page',
59 'templatelinks' => 'tl_from',
61 foreach ( $tables as $table => $fromField ) {
62 $res = $this->getDb()->newSelectQueryBuilder()
65 ->where( [ $fromField => $id ] )
66 ->caller( __METHOD__
)->fetchResultSet();
67 $this->assertSame( 1, $res->numRows(), "Number of rows in table $table" );
70 $linksDeletionUpdate = new LinksDeletionUpdate( $wikiPage, $id );
71 $linksDeletionUpdate->setTransactionTicket(
72 $this->getServiceContainer()->getConnectionProvider()->getEmptyTransactionTicket( __METHOD__
)
74 $linksDeletionUpdate->doUpdate();
76 foreach ( $tables as $table => $fromField ) {
77 $res = $this->getDb()->newSelectQueryBuilder()
80 ->where( [ $fromField => $id ] )
81 ->caller( __METHOD__
)->fetchResultSet();
82 $this->assertSame( 0, $res->numRows(), "Number of rows in table $table" );