Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/PhpunitTestEngine.php
| Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | private function findTestFile($path) { | ||||
| $path = Filesystem::resolvePath($path, $root); | $path = Filesystem::resolvePath($path, $root); | ||||
| $file = basename($path); | $file = basename($path); | ||||
| $possible_files = array( | $possible_files = array( | ||||
| $file, | $file, | ||||
| substr($file, 0, -4).'Test.php', | substr($file, 0, -4).'Test.php', | ||||
| ); | ); | ||||
| $search = self::getSearchLocationsForTests($path); | $search = $this->getSearchLocationsForTests($path); | ||||
| foreach ($search as $search_path) { | foreach ($search as $search_path) { | ||||
| foreach ($possible_files as $possible_file) { | foreach ($possible_files as $possible_file) { | ||||
| $full_path = $search_path.$possible_file; | $full_path = $search_path.$possible_file; | ||||
| if (!Filesystem::pathExists($full_path)) { | if (!Filesystem::pathExists($full_path)) { | ||||
| // If the file doesn't exist, it's clearly a miss. | // If the file doesn't exist, it's clearly a miss. | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | final class PhpunitTestEngine extends ArcanistUnitTestEngine { | ||||
| * tests/ | * tests/ | ||||
| * | * | ||||
| * ...or similar. This list will be further pruned by the caller; it is | * ...or similar. This list will be further pruned by the caller; it is | ||||
| * intentionally filesystem-agnostic to be unit testable. | * intentionally filesystem-agnostic to be unit testable. | ||||
| * | * | ||||
| * @param string PHP file to locate test cases for. | * @param string PHP file to locate test cases for. | ||||
| * @return list<string> List of directories to search for tests in. | * @return list<string> List of directories to search for tests in. | ||||
| */ | */ | ||||
| public static function getSearchLocationsForTests($path) { | public function getSearchLocationsForTests($path) { | ||||
| $file = basename($path); | $file = basename($path); | ||||
| $dir = dirname($path); | $dir = dirname($path); | ||||
| $test_dir_names = $this->getConfigurationManager()->getConfigFromAnySource( | |||||
| 'phpunit_test_dirs'); | |||||
| if (empty($test_dir_names)) { | |||||
| $test_dir_names = array('tests', 'Tests'); | $test_dir_names = array('tests', 'Tests'); | ||||
| } | |||||
| $try_directories = array(); | $try_directories = array(); | ||||
| // Try in the current directory. | // Try in the current directory. | ||||
| $try_directories[] = array($dir); | $try_directories[] = array($dir); | ||||
| // Try in a tests/ directory anywhere in the ancestry. | // Try in a tests/ directory anywhere in the ancestry. | ||||
| foreach (Filesystem::walkToRoot($dir) as $parent_dir) { | foreach (Filesystem::walkToRoot($dir) as $parent_dir) { | ||||
| ▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines | |||||