Replace the SimpleTest framework with PHPUnit.
The SimpleTest framework no longer has the same level of maintenance than the PHP Unit framework. PHPUnit has become the standard; most frameworks use it (ZF1 & 2, Cake, Symfony2, ...) and is actively maintained, sable and works great for every codebase, scenario.
Replacing the testing framework with PHPUnit will allow better consistency in the drupal 8 codebase, by aligning ourselves with Symfony2 testing tools. Moreover, it integrates better with IDE (NetBeans, Eclipse, IntelliJ IDEA), Continuous Integration servers such as Jenkins/Hudson, and with Sonar for static code analysis as well. It has also code coverage which is a huge +.
Convert existings tests from SimpleTest to PHPUnit, in three "simple" steps:
- Unit tests can be converted quasi-verbatim, requiring some minor adjustement due to the difference of APIs. They will extend the
Drupal\Core\Testing\UnitTestBaseclass. <- DONE !
- Database tests, such as UserSaveTest, which only asserts Database interaction, will extend the
Drupal\Core\Testing\DatabaseTestBase. These tests will require some refactoring as we need to mock the needed subsystems such as config, cache, etc. <- Work is in progress in that area, see the commits.
- Functional tests a.k.a our WebTestCase. These tests will requires a minimal bootstrapped environment to be run, and an internal browser, such as Guzzle. Because recreating a mocked environment like we do in DatabaseTests would take too much time, we'll bootstrap a DrupalKernel. Also as PHPUnit assumes database schemas already exists we have to write procedure to drop them in order keep a good level of isolation in the test suit. <- No work has been done yet.
Work In Progress
As of 04 January 2013, the first step has been completed, the second is work in progress and APIs are willing to change a lot to polish developer experience. The third step has not started yet. It follows every agreements in #1567500: [meta] Replace the testing framework with PHPUnit + Ditch and rewrite Simpletest, it is broken beyond repair except one:
- Install Drupal with (stripped down) testing profile + class-specific module(s).
When running UnitTest, we are not installing Drupal at all. For now the bootstrap only instantiate the class loader, and creates an empty container. The Kernel is neither created as well.
git clone --recursive --branch test-phpunit-1801176-sylvain http://git.drupal.org/sandbox/sun/1255586.git phpunit