Page MenuHomePhabricator

[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.

Related Objects

StatusSubtypeAssignedTask
OpenNone
Resolvednikitavbv
ResolvedAlbert221
ResolvedRyan10145
Resolvednikitavbv
Resolveddivadsn
ResolvedAlbert221
Resolveddivadsn
Resolvednikitavbv
Resolvednikitavbv
OpenNone
Resolvednikitavbv
OpenNone
ResolvedRyan10145
ResolvedRyan10145
OpenNone
OpenNone

Event Timeline

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 subscribed.

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

Ryan10145 subscribed.

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

Pppery renamed this task from [GCI][Unit testing] Unit test db operations on Newsletter extension to [Unit testing] Unit test db operations on Newsletter extension.Oct 21 2023, 5:48 PM