0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-20 01:52:15 +02:00
PHPMailer/test
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
..
Language Tests: introduce base testcase and move test classes to subdirectories (#2376) 2021-06-23 22:43:46 +02:00
PHPMailer Tests: introduce base testcase and move test classes to subdirectories (#2376) 2021-06-23 22:43:46 +02:00
DebugLogTestListener.php Make the tests PHPUnit cross version compatible + test on PHP 8 (#2202) 2020-11-25 15:35:50 +01:00
fakefunctions.php Decode encoded names in the address parser, see #2266 2021-02-18 11:46:07 +01:00
fakepopserver.sh Update copyright year 2020-09-02 08:41:14 +02:00
fakesendmail.sh Minor fixes, code style 2016-08-31 10:26:06 +02:00
runfakepopserver.sh See what's happening in the shell 2015-11-24 19:04:12 +01:00
testbootstrap-dist.php Big cleanup for Symfony coding style and php-cs-fixer, see #1148 2017-09-07 18:21:09 +02:00
TestCase.php Tests: introduce base testcase and move test classes to subdirectories (#2376) 2021-06-23 22:43:46 +02:00
validators.php Add tests for injected validators 2021-06-15 14:54:40 +02:00