Cenarium has uploaded a new change for review. https://gerrit.wikimedia.org/r/257845
Change subject: PHPUnit testing ...................................................................... PHPUnit testing Change-Id: I8a9ea095952b9de7208e6fb8ce69dd94ec17450a --- A tests/phpunit/includes/changetags/ChangeTagsCoreTest.php 1 file changed, 65 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/45/257845/1 diff --git a/tests/phpunit/includes/changetags/ChangeTagsCoreTest.php b/tests/phpunit/includes/changetags/ChangeTagsCoreTest.php new file mode 100644 index 0000000..d8be7f7 --- /dev/null +++ b/tests/phpunit/includes/changetags/ChangeTagsCoreTest.php @@ -0,0 +1,65 @@ +<?php + +class ChangeTagsCoreTest extends MediaWikiTestCase { + + protected function setUp() { + parent::setUp(); + $this->setMwGlobals( array( + 'wgUseAutoTagging' => true, + ) ); + } + + /** + * @dataProvider provideGetAutotagsForEditUpdate + * @covers ChangeTagsCore::getAutotagsForEditUpdate + */ + public function testGetAutotagsForEditUpdate( $oldText, $newText, $pageTitle, $expected ) { + $title = Title::makeTitle( NS_MAIN, $pageTitle ); + $oldContent = ContentHandler::makeContent( $oldText, null, CONTENT_MODEL_WIKITEXT ); + $newContent = ContentHandler::makeContent( $newText, null, CONTENT_MODEL_WIKITEXT ); + $actual = ChangeTagsCore::getAutotagsForEditUpdate( $oldContent, $newContent, $title ); + + sort( $expected ); + sort( $actual ); + $this->assertEquals( $expected, $actual ); + } + + public function provideGetAutotagsForEditUpdate() { + return array( + array( 'Hi', '#REDIRECT [[Main Page]]', 'Main Page', + array( 'core-redirect-self', 'core-redirect-new' ) ), + array( '#REDIRECT [[Main Page]]', 'nothing', 'Some Page', + array( 'core-redirect-removed' ) ), + array( 'Lorem ipsum', '', 'Some Page', + array( 'core-edit-blank' ) ), + array( 'Lorem ipsum', 'Lorem ipsum dolor sit amet', 'Some Page', + array() ), + ); + } + + /** + * @dataProvider provideGetAutotagsForMove + * @covers ChangeTagsCore::getAutotagsForMove + */ + public function testGetAutotagsForMove( + $oldNs, $oldPage, $newNs, $newPage, $userName, $expected + ) { + $oldTitle = Title::makeTitle( $oldNs, $oldPage ); + $newTitle = Title::makeTitle( $newNs, $newPage ); + $user = User::newFromName( $userName ); + $actual = ChangeTagsCore::getAutotagsForMove( $oldTitle, $newTitle, $user ); + + sort( $expected ); + sort( $actual ); + $this->assertEquals( $expected, $actual ); + } + + public function provideGetAutotagsForMove() { + return array( + array( NS_USER, 'John', NS_USER, 'James', 'John', + array( 'core-move-rename' ) ), + array( NS_MAIN, 'Foo', NS_PROJECT, 'Foo', 'Caesar', + array( 'core-move-crossnamespace' ) ), + ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/257845 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8a9ea095952b9de7208e6fb8ce69dd94ec17450a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits