Commit Graph

62 Commits

Author SHA1 Message Date
jrfnl c16da1afa8 GH Actions: set up code coverage monitoring via codecov
The Codecov service is a way to monitor test vs code coverage of a project over time and allows for the code coverage % + delta to be reported in each PR.

This commits:
* Adds a Codecov configuration.
* Adds a convenience script to the `composer.json` file to run the tests with or without code coverage.
* Adds a new matrix variable to the GH Actions `test` workflow to run the tests with code coverage and send the results to the Codecov service.
    Notes:
    - This disables the code coverage reporting in the "normal" test runs, including disabling `xdebug` for those runs which should make them slightly faster.
    - This splits the test runs into two sets:
        * High/low PHP are being run with code coverage (and have been removed from the "normal" test run matrix).
        * For all other PHP versions, the tests are being run without code coverage.
* Adds a badge to the README to show the current code coverage %.
2021-07-04 15:03:01 +02:00
jrfnl f0cfd3f49d GH Actions: add PHP linting job
This commit:
* Add a new dependency on the PHP Parallel Lint package for fast PHP linting.
    The PHP Parallel Lint package, in combination with the PHP Console Highlighter provides the following advantages in comparison with "plain" PHP linting:
    - Higher speed due to the parallel processes.
    - Improved usability by providing color coded syntax highlighting of found errors on the command-line.
    - Integration with the `cs2pr` tool, allowing for the results of the lint command to be shown in-line in PRs.
* Adds a Composer `lint` script for easy access to the tool for devs, while making sure the correct command line parameters will be used.
    The linting command as currently set up, will also check the example files for linting errors.
* Adds a GH Actions job for linting the code on the high/low supported PHP versions, one arbitrary interim version + an experimental build against PHP 8.1.
    The `cs2pr` tool has been enabled and will show the results of the non-experimental lint runs in-line in PRs.
    **Note**: For PHP 8.1, the `cs2pr` tool is not used as there is a known issue in the Parallel Lint tool with PHP 8.1 which breaks on the checkstyle reporting. There is already a [PR open](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/64) to fix this upstream. Once this PR has been merged and a new version of Parallel Lint has been released, the separate step for PHP 8.1 linting can be removed.
 * Makes the `test` job in the GHA workflow dependent on the `lint` job having passed...
     ... as the tests would fail anyway if there are linting errors.
    Also adjusts the name of the `test` jobs to include the word "Test" so they can be easily distinguished from the Lint jobs.

Refs:
* https://github.com/php-parallel-lint/PHP-Parallel-Lint
2021-07-03 12:55:00 +02:00
Juliette 9093c84614
Composer: update version constraints for PHPUnit Polyfills (#2366)
PHPUnit Polyfills 1.0.0 has been released.

Ref: https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/1.0.0

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
Co-authored-by: Marcus Bointon <marcus@synchromedia.co.uk>
2021-06-22 18:59:27 +02:00
Juliette b2df807028
Composer: use a version of PHPCS compatible with PHP 8 (#2364)
While working on 2363, I noticed that the code sniffer run was using PHP 8.0, but Composer still allowed for a PHP_CodeSniffer version to be installed which is not fully compatible with PHP 8.0.

Note: there are still two known incompatibilities with PHP 8.0 in PHPCS 3.6.0, but everything else has been fixed.

Ref: https://github.com/squizlabs/php_codesniffer/releases

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2021-06-22 18:52:00 +02:00
Marcus Bointon b1038ee356
Add composer scripts for syntax check and tests 2021-04-29 10:49:27 +02:00
Marcus Bointon 6b6badad3f
Check for mbstring before trying to use it in parseAddresses 2021-03-19 22:17:22 +01:00
Juliette 78bda9997d
Make the tests PHPUnit cross version compatible + test on PHP 8 (#2202)
* .gitignore: ignore files created during a test run

* Tests: make config cross-version compatible

PHPUnit config file:

* Add `backupGlobals="true"`.
    The default value for this setting changed in PHPUnit 6 from `true` to `false`. By explicitly setting it to `true`, the existing behaviour is maintained.
* Remove the `logIncompleteSkipped` directive which is no longer supported.
* Remove a number of directives which use the default values and for which the defaults have not changed across PHPUnit versions.
* Remove the space in the testsuite name to make it more easily usable on the command line.
* Make sure that all src files are taken into consideration when calculating code coverage.
* Add XSD schema reference.
    Note: the config as-is will now validate for PHPUnit 4.4-9.2. For PHPUnit 9.3, the code coverage terminology has changed, though the "old" configuration is still supported.
    If needs be (PHPUnit 10), the config can be updated on the fly by using `--migrate-configuration`.

Other:
* Ignore a locally overloaded PHPUnit config file using the standard `phpunit.xml` file name.

Question: why does the config file not use the standard `phpunit.xml.dist` file name ? That would allow for running the tests without command line arguments.
That file can still be overloaded locally by a `phpunit.xml` file.

* Composer: add dependency on the PHPUnit Polyfills package

* Adds a dev dependency to the `yoast/phpunit-polyfills` package.
* As that package already requires and manages the installable versions for PHPUnit, remove this as an explicit requirement from `require-dev` in favour of letting the PHPUnit Polyfills package manage the versions.
    This will update the supported PHPUnit versions from `^4.8 || ^5.7` to `^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0`.
    Note: the supported versions for PHPUnit 4.x and 5.x are very specific and restrictive as it specifically targets the versions in which the "forward compatible" alias files for the namespaced classes are available.

This new package adds the following features:
* Polyfills for various PHPUnit cross-version changes.
* Basic test case and test listener.

Refs:
* https://github.com/Yoast/PHPUnit-Polyfills/

Includes adding the PHPUnit cache file, which is automatically created in PHPUnit 8 and 9, to the `.gitignore` file.

* Tests: switch over to use the Yoast\PHPUnitPolyfills\TestCases\TestCase

This switches the parent class of the test classes over `TestCase` from the PHPUnit native TestCase to the `Yoast\PHPUnitPolyfills\TestCases\TestCase`.

The Yoast `TestCase`:
* Provides cross-version compatibility using snake case fixture method names instead of the PHPUnit native camelCase names.

This switch over includes:
* Renaming the `setUp()` and `tearDown()` methods to, respectively, `set_up()` and `tear_down()` in various test classes for PHPUnit cross-version compatibility.

* Tests: switch over to use the Yoast Polyfill TestListenerDefaultImplementation

This switches `DebugLogTestListener` class over to using the PHPUnit 9 default implementation pattern in combination with using the `TestListenerDefaultImplementation` from the PHPUnit Polyfill library for the cross-version compatibility layer for the TestListener.

The Yoast `TestListenerDefaultImplementation`:
* Provides cross-version compatibility using snake case method names instead of the PHPUnit native camelCase names.

This switch over includes:
* Renaming the template methods used in the `DebugLogTestListener` to use their snake_case variant and removes the type declarations.

* Tests: switch out `assertInternalType()`

... in favour of the more specific assertion(s) as introduced in PHPUnit 7.5.0.

The new assertions are automatically polyfilled via the PHPUnit Polyfill repo as this test class extends the `Yoast\PHPUnitPolyfills\TestCases\TestCase` test case.

* Tests: switch out `assert[Not]Contains()` with string haystacks

... in favour of the string specific `assertString[Not]ContainsString() assertion(s) as introduced in PHPUnit 7.5.0.

The new assertions are automatically polyfilled via the PHPUnit Polyfill repo as this test class extends the `Yoast\PHPUnitPolyfills\TestCases\TestCase` test case.

* Tests: switch out `@expectException` annotations

... in favour of method calls to the `TestCase::expectException()` method as introduced in PHPUnit 5.2.0.

The new method and its variants are automatically polyfilled via the PHPUnit Polyfill repo as this test class extends the `Yoast\PHPUnitPolyfills\TestCases\TestCase` test case.

* Tests: switch out `assertRegExp()`

... in favour of the renamed `Assert::assertMatchesRegularExpression() as introduced in PHPUnit 9.1.0.

The new assertion is automatically polyfilled via the PHPUnit Polyfill repo as this test class extends the `Yoast\PHPUnitPolyfills\TestCases\TestCase` test case.

* Tests: mark a test as incomplete

As per the comment in the docblock:
> Needs a connection to a server that supports this auth mechanism, so commented out by default.

As the test cannot currently be executed succesfully, we may as well skip it with a meaningful message.

* Tests: mark a test as not performing assertions

... to prevent it from being marked as risky.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2020-11-25 15:35:50 +01:00
Juliette 3cb2162859
Improve PHPCS config (#2182)
* PHPCS: rename config file

... to `phpcs.xml.dist` to allow devs to locally overload the file by using a `.phpcs.xml` or `phpcs.xml` file, to, for instance, test out some new rules.

Includes:
* Adding the local overload files to `.gitignore`.
* Adding the standard config file to `.gitattributes`.

* PHPCS: scan missing file

The `get_oauth_token.php` file in the project root seems to have been overlooked when configuring the PHPCS ruleset.

Fixed now by adding it to the file to be scanned.

Includes minor fixes to make the file comply with the configured standard.

* CS: fix two files

Two minor CS fixes.

* PHPCS: miscellaneous changes

* Don't fix the PHPCS/external standards version restraints.
* Add the PHPCS cache file to `.gitignore`.
* Removing the no longer existent `.php_cs` file from `.gitattributes`.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2020-10-26 17:25:46 +01:00
Marcus Bointon 482bdd697a
Cleanup 2020-10-18 20:03:58 +02:00
Marcus Bointon 22e81749ae
Switch from PHP CS fixer to phpcs and apply PSR12 reformatting 2020-10-13 15:08:42 +02:00
Marcus Bointon 4af0120eda
Note that the hash extension is required (and always has been!) or file attachments won't work 2020-08-04 09:03:04 +02:00
Marcus Bointon a7f1b23aae
Add funding info 2020-05-06 16:42:46 +02:00
Marcus Bointon dd6cf2eb51
Remove some unneeded dev dependencies, resolves conflict in #1898
Phpdocs now build using a github action
2019-11-19 16:07:01 +01:00
Damien Regad 75e0a5ce3f Update composer license to `LGPL-2.1-only` (#1719)
As per SPDX License List, previously used `LGPL-2.1` is deprecated[1].

[1]: https://spdx.org/licenses/LGPL-2.1.html
2019-05-05 20:14:21 +02:00
Michael Orlitzky c8613a447b composer.json: add dependency on the PHP "filter" extension. (#1301)
Many of the PHP extensions used by PHPMailer are optional, in one of
two senses. Either there is a fallback if the extension is not
present, or the use of the extension is avoidable entirely. For
example, there is a fallback parser if "imap_rfc822_parse_adrlist" is
not available, and OpenSSL is not needed unless encryption is used;
therefore neither are hard dependencies.

The filter extension, on the other hand, is unavoidable. It is used
unconditionally, with no fallbacks, in (for example) the "isValidHost"
function. This commit adds "ext-filter" to composer.json, to document
the dependency and to help out composer users.

Closes: https://github.com/PHPMailer/PHPMailer/issues/1298
2017-12-22 11:40:15 +01:00
Filippo Tessarotto 992392437c Tests improvements (#1162)
* Move tests to proper namespace; enforce signatures

* Travis stages, check coding-standard before tests

* Test against PHP 7.2

* CS Fix

* Remove php-cs-fixer on test builds

* Travis: remove phpdocumentor/phpdocumentor from builds

* Allow PHPUnit 5
2017-09-14 18:47:12 +02:00
Filippo Tessarotto dc54e2b93c Show debug log only when tests fail (#1161) 2017-09-14 15:56:04 +02:00
Filippo Tessarotto 8550acd0e4 Add PHP-CS-Fixer integration (#1148)
* Add PHP-CS-Fixer checks

* Remove composer.lock to early catch FC break on CI

* Travis: cache dependencies

* Enable code-coverage only for latest build

* Remove Symfony-specific PHP-Doc rules

* Apply coding-standards fix
2017-09-14 12:29:03 +02:00
Marcus Bointon efd7561b56
Revert composer changes to avoid PR clash 2017-09-08 16:18:50 +02:00
Marcus Bointon 31493b6732
Big cleanup for Symfony coding style and php-cs-fixer, see #1148 2017-09-07 18:21:09 +02:00
Marcus Bointon 9e4f68b6b0 Restrict zend_i18n to PHP 5.5 compat version 2017-06-29 21:55:28 +02:00
Marcus Bointon 5807c1fcbe
Merge remote-tracking branch 'remotes/origin/master' into 6.0
# Conflicts:
#	composer.json
#	src/PHPMailer.php
2017-05-11 16:09:52 +02:00
Elan Ruusamäe afb1302611 composer: indicate ctype ext being used (#937) 2017-05-11 00:25:01 +01:00
Marcus Bointon 936eaa7770
Downgrade packages for BC with PHP 5.5 tests 2017-03-15 19:49:11 +01:00
Marcus Bointon bf03eda8f6
Package downgrades to run tests on PHP 5.3 2017-03-15 15:13:09 +01:00
Marcus Bointon c385749c11
Downgrade packages for BC with PHP 5.3 tests 2017-03-15 14:55:19 +01:00
Marcus Bointon 2ceafa2e84
Downgrade packages for BC with PHP 5.3 tests 2017-03-15 14:05:43 +01:00
Marcus Bointon 042ea958cb
Downgrade Zend packages for BC with PHP 5.3 tests 2017-03-15 12:56:46 +01:00
Ramon van Belzen 70da1b419d composer: phpunit 4.8 (#940)
switch from 4.7 to 4.8 (latest stable) of phpunit
2017-03-06 23:05:44 +01:00
aduh95 6f90caae19 Add mbstring suggestions to the composer file (#795) 2016-10-26 21:57:53 +02:00
Marcus Bointon 5e7ea2a6d1
Add PSR-3 compatible debug logging 2016-09-30 17:46:39 +02:00
Marcus 3abcab1936 Clean up TODOs
Switch SingleToArray to protected
Update Readme
Update composer deps
2016-04-19 18:26:33 +02:00
Marcus a8b44e9a8e Merge remote-tracking branch 'remotes/upstream/master' into xoauth
# Conflicts:
#	src/PHPMailer.php
2016-04-19 17:30:13 +02:00
Marcus 05e43f3666 Don't use dynamic classnames in aliased namespaces, see #675
Increase PHP version req to 5.5 in composer.json
2016-04-06 20:18:34 +02:00
Synchro 7bb65f288b Merge branch 'master' into xoauth 2016-01-07 20:38:58 +01:00
Synchro df2a2dfc79 Point at Google-specific OAuth2 lib since that's the only provider supported in 5.2.x 2016-01-07 18:35:00 +01:00
Synchro de1015e6ed Fix composer files 2015-12-07 23:29:15 +01:00
Synchro dffac3a0f5 Merge remote-tracking branch 'remotes/upstream/5.4' into xoauth
# Conflicts:
#	composer.json
#	composer.lock
#	get_oauth_token.php
2015-12-07 22:37:30 +01:00
Synchro 40bdd9c488 Merge branch 'master' into 5.4
# Conflicts:
#	changelog.md
#	composer.json
#	get_oauth_token.php
2015-12-07 22:19:48 +01:00
sherryl4george 2116208ab0 Resolve Scope issues which results in auth failure 2015-12-08 02:08:46 +05:30
Synchro 2101e1654b PHPUnit tweaks 2015-11-11 18:04:02 +01:00
Synchro 0dae3451c6 Downgrade to PHPUnit 4.7 to avoid 4.8 bug 2015-11-11 17:08:35 +01:00
Synchro 016e6330d4 xoauth stuff 2015-11-10 13:09:29 +01:00
Synchro 466264810a Merge remote-tracking branch 'remotes/upstream/5.4' into xoauth
# Conflicts:
#	composer.json
#	composer.lock
#	examples/gmail_xoauth.phps
#	get_oauth_token.php
#	src/OAuthProvider/Google.php
#	src/PHPMailerOAuth.php
2015-11-10 10:25:37 +01:00
Synchro 9b3e13dc14 First draft of 5.4 2015-11-09 19:09:13 +01:00
Marcus Bointon c24f242d9b Fix xoauth package suggestions 2015-10-23 14:59:55 +02:00
Synchro 19fcea0556 Cleanup 2015-10-20 13:52:29 +02:00
Ravishanker Kusuma c71721636e XOAuth Providers support Google,Yahoo,Microsoft
Added token expiry check
2015-09-24 15:22:48 +08:00
Marcus Bointon de8e32f842 Rename oauth class 2015-09-14 10:58:04 +02:00
Marcus Bointon 14ace3da7b Merge branch 'master' of ssh://github.com/PHPMailer/PHPMailer 2015-09-04 10:45:19 +02:00