Commit Graph

5 Commits

Author SHA1 Message Date
Marcus Bointon dfa731a087
Check broken links, update for HTTPS everywhere 2024-04-01 20:48:10 +02:00
jrfnl d5a5ad19cd CS: minor cleanup
PHPCS 3.6.2 added a sniff for a PSR-12 rule which was previously not strictly checked: "No blank line after the opening brace of a class".

This fixes the newly flagged issues.
2021-12-18 04:08:22 +01:00
jrfnl f9ce138ff7 PreSendTestCase: reduce amount of properties being preset
After some investigation, it turns out that barely any of these properties are actually needed for the `PHPMailer::preSend()` method to succeed.

This commit removes all presetting of properties for the PHPMailer instance created by the `PreSendTestCase`, save for the bare minimum.

Overloading and/or adding to the `$propertyChanges` array from concrete test cases is, of course, supported, so if individual tests need additional presetting of properties, the same logic as mentioned in the previous commit can be used.
2021-07-06 20:05:35 +02:00
jrfnl f4bb4d7b63 PreSendTestCase: implement use of the `$propertyChanges` property 2021-07-06 20:05:35 +02:00
jrfnl d7b048cf64 TestCase: split into three different `TestCase`s
The `TestCase::set_up()` was setting quite a number of properties in the `PHPMailer` class.

This makes testing more difficult for the following reasons:
1. The tests can no longer presume the properties in the `PHPMailer` class will have their default values
    This means that tests are not "transparent" (clearly show what is being tested), nor isolated (only target what is specifically being tested).
2. Any changes to the values set in the `set_up()` method may have a ripple effect and create a need for individual test expectations to be adjusted.
3. As the `set_up()` is changing a number of the properties using methods in the `PHPMailer()` class and methods called during the `set_up()` are included in code coverage visualizations, code coverage cannot fully be trusted and it is more difficult to verify that each piece of code has tests covering that code path.

With this in mind, I'm proposing splitting the `TestCase` into three distinct abstract `TestCase`s:
* A basic `TestCase` containing the utility methods and a minimal `set_up()` and `tear_down()`.
* A `PreSendTestCase` for use with tests using the `preSend()` method which requires a few properties to be set.
* A `SendTestCase` for use with tests actually testing the sending of mail using the `send()` method, which needs yet more properties and uses the `testbootstrap.php` file to retrieve the values of those variables.

This commit executes the initial split. Follow-on commits will streamline this further.

Includes adjusting the `TestCase` being extended for select existing unit test classes.
2021-07-06 20:05:35 +02:00