Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78626
Change subject: Add unit tests for MassMessage::followRedirect
......................................................................
Add unit tests for MassMessage::followRedirect
Change-Id: I785fc7eca4b9f4460fc87edc3ce264fdb293b774
---
M tests/MassMessageTest.php
1 file changed, 20 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage
refs/changes/26/78626/1
diff --git a/tests/MassMessageTest.php b/tests/MassMessageTest.php
index 27246be..5539589 100644
--- a/tests/MassMessageTest.php
+++ b/tests/MassMessageTest.php
@@ -3,8 +3,6 @@
class MassMessageTest extends MediaWikiTestCase {
protected function setUp() {
parent::setUp();
- $this->title = Title::newfromText( 'Input list' );
- $this->page = WikiPage::factory( $this->title );
}
protected function tearDown() {
@@ -12,12 +10,13 @@
}
/**
- * Updates $this->title with the provided text
- * @param WikiPage $page
+ * Updates $title with the provided $text
+ * @param Title title
* @param string $text
*/
- public static function updatePage( $page, $text ) {
+ public static function updatePage( $title, $text ) {
$user = new User();
+ $page = WikiPage::factory( $title );
$content = ContentHandler::makeContent( $text,
$page->getTitle() );
$page->doEditContent( $content, "summary", 0, false, $user );
}
@@ -43,8 +42,9 @@
* @param array $check Stuff to check against
*/
public function testGetParserFunctionTargets( $text, $check ) {
- self::updatePage( $this->page, $text );
- $data = MassMessage::getParserFunctionTargets( $this->title,
RequestContext::getMain() );
+ $title = Title::newFromText( 'Input list ');
+ self::updatePage( $title, $text );
+ $data = MassMessage::getParserFunctionTargets( $title,
RequestContext::getMain() );
if ( empty( $check ) ) {
// Check that the spamlist is empty
$this->assertTrue( empty( $data ) );
@@ -78,4 +78,17 @@
$output = MassMessage::getBaseUrl( $url );
$this->assertEquals( $output, $expected );
}
+
+ /**
+ * Tests MassMessage::followRedirect
+ */
+ public function testFollowRedirect() {
+ $title = Title::newfromtext( 'R1' );
+ self::updatePage( $title, '#REDIRECT [[R2]]' );
+ $title2 = Title::newfromtext( 'R2' );
+ self::updatePage( $title2, 'foo' );
+
+ $this->assertEquals( $title2->getFullText(),
MassMessage::followRedirect( $title )->getFullText() );
+ $this->assertEquals( $title2->getFullText(),
MassMessage::followRedirect( $title2)->getFullText() );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/78626
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I785fc7eca4b9f4460fc87edc3ce264fdb293b774
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits