+ public function testOnAddingAndRemovingCategory_recentChangesRowIsAdded() {
+ $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+
+ $title = Title::newFromText( 'Testing' );
+ $wikiPage = new WikiPage( $title );
+ $wikiPage->doEditContent( new WikitextContent( '[[Category:Foo]]' ), 'added category' );
+
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Foo' ),
+ array( array( 'Foo', '[[:Testing]] added to category' ) )
+ );
+
+ $wikiPage->doEditContent( new WikitextContent( '[[Category:Bar]]' ), 'added category' );
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Foo' ),
+ array(
+ array( 'Foo', '[[:Testing]] added to category' ),
+ array( 'Foo', '[[:Testing]] removed from category' ),
+ )
+ );
+
+ $this->assertRecentChangeByCategorization(
+ $title,
+ $wikiPage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Category:Bar' ),
+ array(
+ array( 'Bar', '[[:Testing]] added to category' ),
+ )
+ );
+ }
+
+ public function testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored() {
+ $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
+
+ $templateTitle = Title::newFromText( 'Template:TestingTemplate' );
+ $templatePage = new WikiPage( $templateTitle );
+
+ $wikiPage = new WikiPage( Title::newFromText( 'Testing' ) );
+ $wikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
+ $otherWikiPage = new WikiPage( Title::newFromText( 'Some_other_page' ) );
+ $otherWikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
+ $templatePage->doEditContent( new WikitextContent( '[[Category:Foo]]' ), 'added category' );
+
+ $this->assertRecentChangeByCategorization(
+ $templateTitle,
+ $templatePage->getParserOutput( new ParserOptions() ),
+ Title::newFromText( 'Foo' ),
+ array( array( 'Foo', '[[:Template:TestingTemplate]] and 2 pages added to category' ) )
+ );
+ }
+