Closed jrfnl closed 2 years ago
Thank you :blue_heart:
Your commits are as a guide "How to replace Nette Tester with PHPUnit"
😄 Nice! Oh and if it weren't for the fact that PHP 5.3 is still supported in this package, I would have added the PHPUnit Polyfills as well instead of having our "own" polyfilled functions in the TestCase
class.
We could maybe consider dropping support for PHP 5.3 in the 2.0 version ?
Note: This PR will be easiest to review by looking at each commit individually.
Fixes #90
Tests: switch to PHPUnit - set up the basics
Tests: add test bootstrap and basic UnitTestCase
bootstrap.php
file has been crafted to allow for running the tests both via a Composer installed PHPUnit version, as well as running the tests via a PHPUnit PHAR file. The reason for this is, that as this application supports a wide range of PHP versions, a wide range of PHPUnit versions is needed to test against all the relevant PHP versions. When running the tests locally, this would mean runningcomposer update
between every test run, which gets tedious fast and slows development down. By explicitly supporting running the tests via a PHPUnit PHAR file, this extra step of runningcomposer update
between every test run on a different PHP version is eliminated.UnitTestCase.php
file is a bare bones PHPUnit TestCase file. This TestCase only contains a couple of methods to provide polyfills for PHPUnit assertions which have changed names across PHPUnit versions. An alternative would be to use something like the PHPUnit Polyfills package, however as that requires a minimum PHP version of PHP 5.4, that is not an option at this time. The polyfilled functions I added to theUnitTestCase
are 100% based on the polyfills from the PHPUnit Polyfills and are tried and tested in that package (which I wrote, so I'm not violating copyright here ;-) ).Note: the name
UnitTestCase
file has been chosen deliberately as this package is typically a package which could benefit from having both unit as well as integration tests and naming the file/classUnitTestCase
allows for adding anIntegrationTestCase
base class later on.Tests: switch to using the PHPUnit test runner
Includes:
@testCase
annotations.require
statements at the top of each test file. Instead the file loading will be handled via thebootstrap.php
file for PHPUnit.TestCase
and replacing it with thePHP_Parallel_Lint\PhpParallelLint\Tests\UnitTestCase
.->run()
commands at the end of the test files in favour of letting the PHPUnit test runner handle this.Tests: switch to using the PHPUnit assertions and expectations
Includes:
assertSame()
instead ofequal
).UnitTestCase
class to ensure the tests can run without problems on the needed range of PHPUnit versions.ManagerRunTest
as the tests for Nette were run from thetests
directory, while PHPUnit is run from the project root directory.Tests: use the PL_TESTROOT constant
... as declared in the test bootstrap file to allow for more stability when test files get moved around.
Tests: re-organize test directory structure
Unit
subdirectory as these are unit tests. This allows for more easily adding a second set of (integration) tests at a later point in time.tests\Unit
directory reflect the structure of thesrc
directory.