There are several validations now enforced, such as:
- The description should be larger than x length
- The main page should exist
- The main page should be unique per newsletter
- The newsletter name should be unique
How to write the test:
- First, take a look at the behavior while creating a newsletter at Special:CreateNewsletter
- Take a look at the function being called on clicking submit button - and in this case its https://github.com/wikimedia/mediawiki-extensions-Newsletter/blob/master/includes/specials/SpecialNewsletterCreate.php#L74
- Then take a look at https://gerrit.wikimedia.org/r/#/c/399995/3/tests/specials/SpecialNewsletterCreateTest.php and see how exactly we are testing it.
- Understand what validation you are going to test, and write a new function in the file SpecialNewsletterCreateTest.phpwith a new payload ($input) that can mock it. For eg: with a faulty description or bad main page, etc. For debugging, you can always use var_dump( $res ); as in the example gerrit change line 31
- Execute all the tests, make sure things are green, and push.
Bonus: Think about adding an extra test that makes sure that the newsletter was not created (and saved in the database) after each of these conditions fail.