Diviner

Class PhpunitTestEngine

Definedsrc/unit/engine/PhpunitTestEngine.php:14
GroupUnit Test Runners
ExtendsArcanistBaseUnitTestEngine

PHPUnit wrapper

To use, set unit.engine in .arcconfig, or use --engine flag with arc unit. Currently supports only class & test files (no directory support). To use custom phpunit configuration, set phpunit_config in .arcconfig (e.g. app/phpunit.xml.dist).

Tasks

Unspecified

Methods

private string|null findTestFile($path)

parametersstring$pathPHP file to locate test cases for.
returnstring|nullPath to test cases, or null.

Search for test cases for a given file in a large number of "reasonable" locations. See getSearchLocationsForTests() for specifics.

TODO: Add support for finding tests in testsuite folders from phpunit.xml configuration.

public static list<string> getSearchLocationsForTests($path)

parametersstring$pathPHP file to locate test cases for.
returnlist<string>List of directories to search for tests in.

Get places to look for PHP Unit tests that cover a given file. For some file "/a/b/c/X.php", we look in the same directory:

/a/b/c/

We then look in all parent directories for a directory named "tests/" (or "Tests/"):

/a/b/c/tests/ /a/b/tests/ /a/tests/ /tests/

We also try to replace each directory component with "tests/":

/a/b/tests/ /a/tests/c/ /tests/b/c/

We also try to add "tests/" at each directory level:

/a/b/c/tests/ /a/b/tests/c/ /a/tests/b/c/ /tests/a/b/c/

This finds tests with a layout like:

docs/ src/ tests/

...or similar. This list will be further pruned by the caller; it is intentionally filesystem-agnostic to be unit testable.

private array parseTestResults($path, $json_tmp, $clover_tmp)

parametersstring$path$path Path to test
string$json_tmp$json_path Path to phpunit json report
string$clover_tmp$clover_tmp Path to phpunit clover report
returnarray

Parse test results from phpunit json report

private prepareConfigFile()

returnwild

Tries to find and update phpunit configuration file based on phpunit_config option in .arcconfig

public run()

returnwild
This method is not documented.