0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-20 01:52:15 +02:00
Commit Graph

1912 Commits

Author SHA1 Message Date
jrfnl
a550adc872 Localization: allow for more text strings to be translated
In a number of places in the code base I came across hard-code error messages, which were not set up to be translatable.

For those I found, I've now fixed this.

Note: I've not added the labels used for logging errors via the `PHPMailer:edebug()` method. If so desired, that could be added in a future iteration.

Existing translation files have not been updated. Translators may need to be pinged before the next release to update the translation(s) they maintain.

Includes a minor tweak to the PHPCS configuration to allow lines in language files to exceed the "120 chars line max" as using concatenation for text strings in translation files will not work with the current way of loading these files and the new "buggy PHP" message is a long text which would result in nearly all translation files throwing the warning.
2021-07-09 15:01:11 +02:00
Marcus Bointon
1a2e462b9d
Merge pull request #2431 from jrfnl/feature/tests-add-tests-fileisaccessible
Tests: introduce dedicated tests for the `PHPMailer::fileIsAccessible()` method
2021-07-09 11:39:25 +02:00
Marcus Bointon
fbf2eea0e9
Merge pull request #2430 from jrfnl/feature/tests-add-tests-ispermittedpath
Tests: introduce dedicated tests for the `PHPMailer::isPermittedPath()` method
2021-07-09 11:38:37 +02:00
Marcus Bointon
971af16ccf
Merge pull request #2427 from jrfnl/feature/tests-reorganize-26
Tests: move addStringAttachment tests to own file
2021-07-09 11:37:27 +02:00
jrfnl
49bcd4a035 Tests: introduce dedicated tests for the PHPMailer::fileIsAccessible() method
So far, this method did not have dedicated tests.

The test file this commit introduces, tests nearly all aspects of the method as well as documents the current behaviour of the method.

There is one particular test case missing. This is annotated in the class docblock.

While this method is quite simple, testing it separately means that the tests for methods _using_ this method don't have to _also_ test the functioning of this method, which means they can be more focussed on their own logic.
2021-07-09 09:36:36 +02:00
jrfnl
f5b54c2bb5 Tests: introduce dedicated tests for the PHPMailer::isPermittedPath() method
So far, this method did not have dedicated tests.

The test file this commit introduces, tests all aspects of the method as well as documents the current behaviour of the method.

While this method is quite simple, testing it separately means that the tests for methods _using_ this method don't have to _also_ test the functioning of this method, which means they can be more focussed on their own logic.
2021-07-09 09:30:39 +02:00
jrfnl
59f82c7db5 AddStringAttachmentTest: add @covers tags 2021-07-08 11:37:17 +02:00
jrfnl
404ba09b64 AddStringAttachmentTest: add additional "fail to attach" test method
This commit:
* Adds a new `testFailToAttach()` test method to test the behaviour of the `PHPMailer::addStringAttachment()` method when the `PHPMailer` class has been instantiated with `$exceptions` disabled.
* This new test method uses the same data provider - introduced in the previous commit - as the `testFailToAttachException()` method.
2021-07-08 11:37:15 +02:00
jrfnl
384e291092 AddStringAttachmentTest: refactor the "fail to attach" test case
This commit:
* Renames the `testStringAttachmentEncodingException()` test to `testFailToAttachException()`.
* Reworks the test to use a data provider.
* Adds testing of the exception message to the `testFailToAttachException()` method.
2021-07-08 11:37:13 +02:00
jrfnl
40a4fa39b7 AddStringAttachmentTest: improve original test
This expands the assertions executed in this test to cover the code under test more comprehensively.
2021-07-08 11:37:12 +02:00
jrfnl
41af61ab2f AddStringAttachmentTest: switch to preSend()
The actual "attaching" of the string attachment happens within `createBody()` which is called from `preSend()`, so this test doesn't actually need to call `send()`.
2021-07-08 11:37:10 +02:00
jrfnl
0bc3dfb96b Tests/reorganize: move addStringAttachment tests to own file 2021-07-08 11:37:08 +02:00
Marcus Bointon
e93f027b1f
Merge pull request #2425 from jrfnl/feature/tests-reorganize-25
Tests: move addEmbeddedImage tests to own file
2021-07-08 10:56:11 +02:00
jrfnl
73b4ec5bea AddEmbeddedImageTest: add @covers tags 2021-07-07 19:27:02 +02:00
jrfnl
90c98c3c1c AddEmbeddedImageTest: fully test exceptions for "fail to attach" test cases
This commit:
* Adds an `exceptionMessage` index to the `dataFailToAttach()` data provider.
* Renames the `testEmbeddedImageEncodingException()` method to `testFailToAttachException()`.
* Sets the `testFailToAttachException()` method up to use the `dataFailToAttach()` data provider.
* Adds testing of the exception message to the `testFailToAttachException()` method.

With this change, the "fail to attach" test cases are now fully tested for both a `PHPMailer` instance without exceptions enabled, as well as for an instance _with_ exceptions enabled.
2021-07-07 19:27:01 +02:00
jrfnl
eb666a7e5d AddEmbeddedImageTest: add extra test case for testFailToAttach() method
... mirroring the same test in the `testEmbeddedImageEncodingException()` method.
2021-07-07 19:26:59 +02:00
jrfnl
028b503624 AddEmbeddedImageTest: improve original test [2]
This expands the assertions executed in this test to cover the code under test more comprehensively.
2021-07-07 19:26:58 +02:00
jrfnl
cbecbc956b AddEmbeddedImageTest: improve original test [1]
The test code remaining in the `testEmbeddedImage()` constitutes one test.

This commit:
* Renames the test method and improves the description in the docblock.
* Removes the redundant call to `PHPMailer::clearAttachments()`.
    This call was previously needed as multiple situations were being tested in one test method.
    Now each test case has its own test method, the call to `PHPMailer::clearAttachments()` is no longer needed as each test method will receive a fresh, clean instance of the `PHPMailer` class.
* Replace a redundant condition and "forced" failure assertion with an assertion actually testing the result of the method call.
* Removes the redundant `return` - if an assertion fails, the rest of the code within the test method will not be executed anyway.
2021-07-07 19:26:56 +02:00
jrfnl
d034bef136 AddEmbeddedImageTest: split off "missing name" test
The test case when a file was attached without explicitly adding a filename wasn't actually being tested at all as no assertion was used.

This commit:
* Moves that particular test case to a separate test method.
* Adds relevant assertions to actually test the test case.
2021-07-07 19:26:54 +02:00
jrfnl
e5b07ba3c3 AddEmbeddedImageTest: split off failure test
The "failure" case when a non-existent file was being passed, wasn't actually being tested at all as no assertion was used.

This commit:
* Moves the particular failure test case to a separate test method with a data provider (to allow for more failure test cases to be added).
* Uses an assertion on the call to `addEmbeddedImage()` to actually test that the method return a failure state.
* Verifies that no attachment for an inline image was added by adding a second assertion with a call to `PHPMailer::inlineImageExists()`.
2021-07-07 19:26:53 +02:00
jrfnl
a866bc9eda AddEmbeddedImageTest: switch to preSend()
The actual "attaching" of the images happens within `createBody()` which is called from `preSend()`, so this test doesn't actually need to call `send()`.
2021-07-07 19:26:51 +02:00
jrfnl
8e76e48afb Tests/reorganize: move addEmbeddedImage tests to own file
Note: this doesn't move the complete test from the original test file, just select parts of the test method.
2021-07-07 19:26:49 +02:00
Marcus Bointon
58b875bfed
Merge pull request #2424 from jrfnl/feature/tests-reorganize-24
Tests: move custom header tests to own file
2021-07-07 18:51:08 +02:00
jrfnl
da01dc50e0 CustomHeaderTest: add @covers tags 2021-07-07 17:42:47 +02:00
jrfnl
611c58c134 CustomHeaderTest: add extra test cases for testAddCustomHeaderInvalid() method 2021-07-07 17:42:45 +02:00
jrfnl
07be3bc7ff CustomHeaderTest: add extra test cases for testAddAndGetCustomHeader() method 2021-07-07 17:42:43 +02:00
jrfnl
d2a1a20097 CustomHeaderTest: reorganize rest to use data provider
* Maintains (largely) the same test cases.
* Prevent one failing assertion hiding a potential second failure.
* Makes it easier to add additional test cases in the future.

Note:
This removes the intermittent calls to `clearCustomHeaders()` from this test. This is now tested via a separate method and as each test case will receive a fresh instance of the `PHPMailer` class, there is no need to clear the set custom headers between tests.
2021-07-07 17:42:41 +02:00
jrfnl
fb81ccc224 CustomHeaderTest: add dedicated test for clearCustomHeaders() method
Includes adding an assertion to ensure that the `PHPMailer::CustomHeader` property is still in array format after clearing it out.
2021-07-07 17:42:40 +02:00
jrfnl
a7d9416e24 CustomHeaderTest: move "failure" tests to own method with data provider 2021-07-07 17:42:38 +02:00
jrfnl
22ba72fd99 CustomHeaderTest: rename exception test and improve
... by also testing that the exception message matches the expected message.
2021-07-07 17:42:36 +02:00
jrfnl
ce0c31cea7 Tests/reorganize: move custom header tests to own file 2021-07-07 17:42:34 +02:00
Marcus Bointon
2aa2614e5d
Merge pull request #2423 from jrfnl/feature/tests-haslinelongerthan-switch-to-presend
HasLineLongerThanMaxTest: switch to preSend()
2021-07-07 17:26:23 +02:00
Marcus Bointon
7475270380
Merge pull request #2422 from jrfnl/feature/tests-reorganize-23
Tests: move setWordWrap tests to own file
2021-07-07 17:25:54 +02:00
jrfnl
6e0193958d HasLineLongerThanMaxTest: switch to preSend()
The line length adjustments are executed within `createBody()` which is called from `preSend()`, so this test doesn't actually need to call `send()`.

I also wonder if this test can be further improved by having more targeted tests for `PHPMailer::hasLineLongerThanMax()` and whether these more extensive tests can be included in a test class which is more targeted at the `createBody()` and/or `preSend()` methods, but that is for later.
2021-07-07 17:12:16 +02:00
jrfnl
54c0bb9fb5 SetWordWrapTest: add @covers tags 2021-07-07 17:11:43 +02:00
jrfnl
bb8b66d0c9 SetWordWrapTest: add "no-wrapping" test
... to increase code coverage.
2021-07-07 17:11:41 +02:00
jrfnl
2c7a354857 SetWordWrapTest: actually test the wordwrapping has been applied
Previously, the test didn't actually test whether the wordwrapping had been applied, just that the message was (pre)send successfully.

Changing the assertions to actually test that the wordwrapping has been correctly applied.
2021-07-07 17:11:39 +02:00
jrfnl
42ddb107f2 SetWordWrapTest: make $WordWrap variable
Make the `WordWrap` setting variable and provide it via the data provider.
2021-07-07 17:11:37 +02:00
jrfnl
807a80b4a6 SetWordWrapTest: reorganize to use data providers
* Maintains the same test code and test cases.
* Removes code duplication.
* Makes it easier to add additional test cases in the future.
2021-07-07 17:11:35 +02:00
jrfnl
c6ed8ad0eb SetWordWrapTest: use preSend() not send()
For this test, there is no need to actually try to _send_ the message, we just need to make sure that `setWordWrap()` is triggered, which can be done by calling `preSend()` instead of `send()`.
2021-07-07 17:11:33 +02:00
jrfnl
b4ab241395 Tests/reorganize: move setWordWrap tests to own file 2021-07-07 17:11:31 +02:00
Marcus Bointon
55ad6349c9
Merge pull request #2421 from jrfnl/feature/tests-reorganize-22
Tests: move puny encoding test to own file
2021-07-07 15:35:24 +02:00
Marcus Bointon
a44e3db8d9
Merge pull request #2420 from jrfnl/feature/gitattributes-ignore-codecov-config
.gitattributes: export-ignore code coverage config file
2021-07-07 15:33:33 +02:00
Marcus Bointon
fbc5834fc5
Merge pull request #2417 from jrfnl/feature/utf8boundary-test-minor-improvement
Utf8CharBoundaryTest: switch base test case
2021-07-07 15:33:20 +02:00
Marcus Bointon
86aae5c547
Merge pull request #2416 from jrfnl/feature/tests-setup-vs-test-bootstrap
SendTestCase: error out when the testbootstrap file cannot be found
2021-07-07 15:32:53 +02:00
Marcus Bointon
a6aa3c8e12
Merge pull request #2415 from jrfnl/feature/tests-add-tests-generateID
Tests: introduce dedicated test for the `PHPMailer::generateID()` method
2021-07-07 15:32:07 +02:00
jrfnl
89af7c5074 PunyencodeAddressTest: add @covers tag 2021-07-07 05:15:27 +02:00
jrfnl
09ba11ae08 PunyencodeAddressTest: add additional test method
This new test method covers a range of cases where the `PHPMailer::punyencodeAddress()` method should (and does) return the original input value unchanged.

This test does not require the `mbstring` extension or `idn_to_ascii()` function to be available, which is why it has been set up as a separate test with a separate data provider.
2021-07-07 05:15:24 +02:00
jrfnl
7f6c882395 PunyencodeAddressTest: add additional test case
... to ensure that the `PHPMailer::punyencodeAddress()` only acts on the domain.
2021-07-07 05:15:23 +02:00
jrfnl
acb038dac3 PunyencodeAddressTest: reorganize to use data provider
* Maintains the same test code and test cases.
* Makes it easier to add additional test cases in the future.
2021-07-07 05:15:21 +02:00