Page MenuHomePhabricator

[GCI][Unit testing] Unit test condition "The newsletter name should be unique" in NewsletterCreate
Closed, ResolvedPublic

Description

Validation to test: A newsletter with the name "Test" already exists. Please try again with another name is shown up when you try to create two newsletter with same main page.

You can find instructions on how to test in the parent task description, or https://phabricator.wikimedia.org/T183632

Mentors: @01tonythomas and others.

Details

Related Gerrit Patches:

Event Timeline

I'm having difficulties with being able to create 2 different newsletters with the same name. Whenever I try to input a new newsletter, it gives me an error saying that the mainpage is either in use or nonexistent. What can I put in Title::newFromText( ' ' )->getBaseText() in order to successfully submit 2 different newsletters?

@Ryan10145 I see the point. Can you try creating the first one like - https://github.com/wikimedia/mediawiki-extensions-Newsletter/blob/master/tests/specials/SpecialNewsletterCreateTest.php#L44 (that is a direct creation to the db, but not a problem).

For the second one, I guess you need to manually create a new Wikipage. One way I achieved it last time was:

$title = Title::newFromText( 'TestPage' );
$wikiPage = WikiPage::factory( $title );
$content = new WikitextContent( $text='this is a test' );
$wikiPage->doEditContent( $content, $summary='Test commit' );

That would create a page for that title, and you can possibly use that. Also, from this thread - https://lists.wikimedia.org/pipermail/wikitech-l/2017-December/089342.html -- you can find how to inject a logged in user case so that you can possibly complete the newsletter creation.

Change 400242 had a related patch set uploaded (by Ryan10145; owner: Ryan10145):
[mediawiki/extensions/Newsletter@master] Added a unit test to check that the name must be unique per newsletter

https://gerrit.wikimedia.org/r/400242

Change 400242 merged by jenkins-bot:
[mediawiki/extensions/Newsletter@master] Added a unit test to check that the name must be unique per newsletter

https://gerrit.wikimedia.org/r/400242

01tonythomas closed this task as Resolved.Dec 28 2017, 9:41 AM
01tonythomas assigned this task to Ryan10145.

Great work. Thanks !