insertPage( 'Source' ); $id = $res['id']; $title = $res['title']; $wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title ); $po = new ParserOutput(); $po->addCategory( new TitleValue( NS_CATEGORY, 'Cat' ), 'cat' ); $po->addExternalLink( 'https://en.wikipedia.org/' ); $po->addImage( new TitleValue( NS_FILE, 'Wiki.png' ) ); $po->addLink( new TitleValue( 0, 'foo', '', 'iwprefix' ) ); $po->addLanguageLink( new TitleValue( 0, 'Francais', '', 'fr' ) ); $po->addLink( new TitleValue( 0, 'Target' ) ); $po->setNumericPageProperty( 'int', 1 ); $po->addTemplate( new TitleValue( NS_TEMPLATE, '!' ), 1, 1 ); $linksUpdate = new LinksUpdate( $title, $po, false ); $linksUpdate->setTransactionTicket( $this->getServiceContainer()->getConnectionProvider()->getEmptyTransactionTicket( __METHOD__ ) ); $linksUpdate->doUpdate(); $tables = [ 'categorylinks' => 'cl_from', 'externallinks' => 'el_from', 'imagelinks' => 'il_from', 'iwlinks' => 'iwl_from', 'langlinks' => 'll_from', 'pagelinks' => 'pl_from', 'page_props' => 'pp_page', 'templatelinks' => 'tl_from', ]; foreach ( $tables as $table => $fromField ) { $res = $this->getDb()->newSelectQueryBuilder() ->select( [ 1 ] ) ->from( $table ) ->where( [ $fromField => $id ] ) ->caller( __METHOD__ )->fetchResultSet(); $this->assertSame( 1, $res->numRows(), "Number of rows in table $table" ); } $linksDeletionUpdate = new LinksDeletionUpdate( $wikiPage, $id ); $linksDeletionUpdate->setTransactionTicket( $this->getServiceContainer()->getConnectionProvider()->getEmptyTransactionTicket( __METHOD__ ) ); $linksDeletionUpdate->doUpdate(); foreach ( $tables as $table => $fromField ) { $res = $this->getDb()->newSelectQueryBuilder() ->select( [ 1 ] ) ->from( $table ) ->where( [ $fromField => $id ] ) ->caller( __METHOD__ )->fetchResultSet(); $this->assertSame( 0, $res->numRows(), "Number of rows in table $table" ); } } }