0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-19 17:42:14 +02:00
Commit Graph

17 Commits

Author SHA1 Message Date
Juliette
6372ff87c1
Tests: introduce base testcase and move test classes to subdirectories (#2376)
* Tests/reorganize: add an abstract base testcase

As a first step towards reorganizing the tests, this commit:
* Creates an abstract base `TestCase` class which can be extended by concrete child test classes and holds the generic properties and helper methods for use throughout the tests.
    Based on their use, the visibility of properties and methods have been adjusted for the new setup.
* Removes the generic property and helper method declarations from the concrete test class.
* Moves the `require` statement for the `validators.php` file to a `set_up_before_class()` method in the base `TestCase`.

* Tests/reorganize: define base directory in set_up_before_class

The `$this->INCLUDE_DIR` property which points to the project root directory does not change at any time during the test run, but was being redefined for every test in the `set_up()` method.

As this is in effect a _constant_ value, let's define it as a constant in the TestCase `set_up_before_class()` method instead.

Notes:
Both actions executed in the `set_up_before_class()` method are typically things for a test bootstrap file.
However, to allow for PHPUnit to be able to run from both a Composer install as well as a Phar file, without having to create custom autoloaders, it is simpler to have the `vendor/autoload.php` file as the bootstrap file as, in that case, PHPUnit will handle the loading order and prevent loading conflicting PHPUnit files from a Composer install when running via the Phar.
With this in mind, putting these actions in a `set_up_before_class()` method is a valid compromise.

* Tests/reorganize: move actual test files to subdirectories

... leaving the test root directory to only contain test utility files.

Note: I've added a second entry for the test generated files to the `.gitignore`. Adding this entry instead of replacing the entry allows for any existing generated files in contributor clones to continue to be ignored.
At a later point in time, it could be elected to remove the original entry, once all active contributors have updated their installs and removed any stray generated files from their `test` root directories.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2021-06-23 22:43:46 +02: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
22e81749ae
Switch from PHP CS fixer to phpcs and apply PSR12 reformatting 2020-10-13 15:08:42 +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
b67f5491f4 Ignore all .pem files 2016-08-31 09:48:30 +02:00
Adeniyi Ibraheem
5faa708103 Update docblock 2016-08-30 00:21:08 +01:00
Marcus Bointon
78ef24e9f6 Merge branch 'master' into 6.0
# Conflicts:
#	.gitignore
#	VERSION
#	src/PHPMailer.php
#	src/POP3.php
#	src/SMTP.php
2016-06-06 14:23:33 +02:00
Marcus Bointon
60a645358f Platform/IDE-specific entries should not be in project .gitignore 2016-06-06 10:35:40 +02:00
Marcus Bointon
10d1a2ea3f Don't ignore docs folder, just its contents 2016-05-01 18:01:10 +02:00
Marcus Bointon
9b784d23b0 Simplify phpdocs generation 2016-05-01 17:30:19 +02:00
Marcus Bointon
558bcdc269 DKIM cleanup, examples 2016-05-01 13:09:24 +02:00
Synchro
e874b2a14b Code cleanups 2015-05-19 17:36:29 +02:00
Synchro
c506185d50 Add support for additional CA certificate when S/MIME signing, fixes #376 2015-03-06 16:35:29 +01:00
Synchro
379b700e77 Add config for scrutinizer 2013-12-17 08:43:48 +01:00
Marcus Bointon
019499efc3 Convert line breaks to CRLF in MsgHTML, closes #52
Fix double suffix on image cids, see #50
Remove unneeded test files, re-use example content for tests
Remove reference to phpmailer-lite
Ignore .idea folder
2013-05-01 10:20:10 +02:00
Synchro
6f919df65e Import 5.2.2rc2 from Google Code
Major cleanup of PHPDocs
Test suite works again
2012-11-21 16:12:07 +01:00