Page MenuHomePhabricator

[GCI][Unit testing] Unit test db operations on Newsletter extension
Open, Needs TriagePublic

Description

This would be a parent task for writing unit tests to check DB operations executed by extension:Newsleter. It would be very similar to testAddSubscriber in https://github.com/wikimedia/mediawiki-extensions-Newsletter/blob/master/tests/NewsletterDbTest.php and mostly go into the same file as well.

The operations are mainly functions in https://github.com/wikimedia/mediawiki-extensions-Newsletter/blob/master/includes/NewsletterDb.php which needs to be tested.

To write the *unit* test:

  1. Add your function with correct name (as to what task you are solving) to NewsletterDbTest.php
  2. Write what the Expected Db operations are - follow something like the $mockWriteDb operations in testAddSubscriber at https://github.com/wikimedia/mediawiki-extensions-Newsletter/blob/master/tests/NewsletterDbTest.php
  3. Install phpmyadmin(https://help.ubuntu.com/lts/serverguide/phpmyadmin.html) to even see what all tables newsletter extension use. These are prefixed with nl_tablename
  4. Assert if things are correct - look at last line of testAddSubscriber
  5. Run all the tests once by executing tests/phpunit/phpunit.php extensions/Newsletter from core/

*Expected know-how*: A bit of PHP, some idea about unit testing - and that would be it.
*Difficulty*: moderate, but you can always see what was done before and copy.

Details

Related Gerrit Patches:
mediawiki/extensions/Newsletter : masterAdd @covers annotation to each NewsletterDb test case

Related Objects

StatusAssignedTask
OpenNone
Resolvednikitavbv
ResolvedAlbert221
ResolvedRyan10145
Resolvednikitavbv
Resolveddivadsn
ResolvedAlbert221
Resolveddivadsn
Resolvednikitavbv
Resolvednikitavbv
OpenNone
Resolvednikitavbv
OpenNone
ResolvedRyan10145
ResolvedRyan10145
OpenNone
OpenNone

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 23 2017, 12:05 PM

Change 400224 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/Newsletter@master] Add @covers annotation to each NewsletterDb test case

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

Change 400224 merged by jenkins-bot:
[mediawiki/extensions/Newsletter@master] Add @covers annotation to each NewsletterDb test case

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

Change 400232 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/Newsletter@master] Unit test NewsletterDb::restoreNewsletter

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

Pppery added a subscriber: Pppery.

Removing patch-for-review; all patches linked are merged

Pppery removed a subscriber: Pppery.Jan 2 2018, 10:15 PM
Ryan10145 updated the task description. (Show Details)Jan 11 2018, 2:50 AM
Ryan10145 added a subscriber: Ryan10145.

Changed some of the description, since the merged changes made the line numbers incorrect