Ryan10145 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/400242 )
Change subject: Added a unit test to check that the name must be unique per
newsletter
......................................................................
Added a unit test to check that the name must be unique per newsletter
Bug: T183632
Bug: T183637
Change-Id: I0bcdb1d3b8778b5fc01b23f62a83cbfb407f7a09
---
M tests/specials/SpecialNewsletterCreateTest.php
1 file changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Newsletter
refs/changes/42/400242/1
diff --git a/tests/specials/SpecialNewsletterCreateTest.php
b/tests/specials/SpecialNewsletterCreateTest.php
index d69a5ce..f7a5264 100644
--- a/tests/specials/SpecialNewsletterCreateTest.php
+++ b/tests/specials/SpecialNewsletterCreateTest.php
@@ -68,4 +68,41 @@
$store->getNewsletterFromName( 'Second Newsletter' )
);
}
+
+ public function testCreateNewsletterNameUnique() {
+ // Create 1st newsletter that will have a conflicting name
+ $newsletterTitle = Title::makeTitleSafe( NS_NEWSLETTER,
'Duplicated Newsletter' );
+ $firstMainPage = Title::newFromText( 'FirstPage' );
+ $store = NewsletterStore::getDefaultInstance();
+ $firstNewsletter = new Newsletter( 0,
+ $newsletterTitle->getText(),
+ 'This is a test newsletter that will have its name
duplicated',
+ $firstMainPage->getArticleID()
+ );
+ $newsletterCreated = $store->addNewsletter( $firstNewsletter );
+ $this->assertTrue( $newsletterCreated );
+
+ // Create a new Wikipage that will be used as the mainpage of a
second newsletter
+ $mainpageTitle = Title::newFromText( 'SecondPage' );
+ $wikiPage = WikiPage::factory( $mainpageTitle );
+ $content = new WikitextContent( $text = 'Test mainpage for
newsletter' );
+ $wikiPage->doEditContent( $content, $summary = 'Test commit' );
+
+ // Create 2nd newsletter with a duplicated name
+ $input = [
+ 'name' => $newsletterTitle->getText(),
+ 'description' => 'This is a test newsletter that should
return an error for a duplicated name',
+ 'mainpage' => $wikiPage->getTitle()->getBaseText()
+ ];
+ $res = $this->newSpecialPage()->onSubmit( $input );
+ $this->assertEquals( $res->getMessage()->getKey(),
'newsletter-exist-error' );
+
+ // Remove the original newsletter in order to check if the
duplicate was added
+ $store->deleteNewsletter( $firstNewsletter, 'Make sure a
duplicate was not added' );
+
+ // Make sure that there are no duplicates remaining
+ $this->assertNull(
+ $store->getNewsletterFromName(
$newsletterTitle->getText() )
+ );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/400242
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bcdb1d3b8778b5fc01b23f62a83cbfb407f7a09
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Newsletter
Gerrit-Branch: master
Gerrit-Owner: Ryan10145 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits