Simplenews needs a simplenews.test file so that patches can be automatically tested.

If the maintainers will give some input as to what functions ought to be tested, I will endeavor to write the necessary tests.

Comments

simon georges’s picture

Thanks a lot for your proposition (and the work you've already done porting patches, I'll review them when I find some time).

The two immediate things I see are:
- subscription process;
- sending process (server side, I think the client form is clearly less important), especially cron processing.

I'll try to find some time (again) to dig deeper into the code to point out the most important parts. Thanks again.

pillarsdotnet’s picture

Title: Needs tests. » Add simpletest support to simplenews.
miro_dietiker’s picture

Priority: Normal » Critical

At least major to me. We need some measurement of quality...

Let's set this for some time to critical. If we decide to release without tests, then back to major.

Pinged pillarsdotnet..

pillarsdotnet’s picture

Got the ping -- I'm still learning how to write tests; it's not nearly as easy as I first supposed. I don't know how soon I'll be able to work on this -- it occurs to me that my own modules are universally missing tests, as well.

berdir’s picture

Title: Add simpletest support to simplenews. » Port and extend tests
Assigned: pillarsdotnet » berdir
Category: feature » task

I am working on some tests.

There were some existing, old tests, which I successfully ported and I'm working on some additional ones currently.

simon georges’s picture

That's awesome news !

berdir’s picture

Status: Active » Needs review
StatusFileSize
new35.17 KB

Ok, here is a first patch.

Included:

- Ported the existing tests
- Removed the simplenews_test.module, the only purpose of it was to display all sent messages on the site to be able to read them in the tests. However, Simpletest has built in support for that and allows to access mails through $this->drupalGetMails().
- Removed the empty SimplenewsBlockTestCase. Can still be re-added later on and the blocks are already largely covered by the other tests
- Added new tests to test newsletter categories including all combiniations of their settings (new account, opt_inout, block).
- Added tests for the subscriptions admin UI (mass subscribe/unsubscribe, export, filters)
- Worked around a bug when deleting categories after a term was deleted. This didn't worked at all, because loading of the term failed as the term was already deleted in the database.

Once this is commited, it should be possible to enable automated testing for this project I think.

I also have a number of other patches lined up, mostly clean ups and i18n integration, will post separate issues for them.

simon georges’s picture

Tagging.

simon georges’s picture

Patch applies cleanly.
Tests can be launched (550 passes, 0 fails, 153 exceptions, and 138 debug messages).

Patch needs further review, but it seems great at first sight. @pillarsdotnet, are you willing to do it ?

pillarsdotnet’s picture

Will do shortly.

berdir’s picture

Hm, what are those exceptions? The tests work fine for me...

simon georges’s picture

Ooops, nevermind, they seem to come from my configuration:file_put_contents(sites/default/files/simpletest/verbose/SimpleNewsAdministrationTestCase-49.html) [function.file-put-contents]: failed to open stream: Permission denied

And 3 notices, several times:
Undefined index: email_plain Notice field.info.inc 797 field_info_max_weight() Exception
Undefined index: email_html Notice field.info.inc 797 field_info_max_weight() Exception
Undefined index: email_textalt Notice field.info.inc 797 field_info_max_weight() Exception

berdir’s picture

Yes the first is a permission issue, make sure Drupal has write permissions for that folder (everything in files, actually).

The second I'm not sure, can anyone else confirm that? I can't...

miro_dietiker’s picture

StatusFileSize
new15.09 KB

ohhhh... wrong post, wrong patch!

berdir’s picture

Status: Needs review » Fixed

We (MD Systems) are going to work a few days on Simplenews this month, I'll go ahead and commit the tests so that we can proceed here.

Automatically closed -- issue fixed for 2 weeks with no activity.