You are here

protected function CoderSniffUnitTest::getTestFiles in Coder 7.2

Returns a list of test files that should be checked.

Return value

array The list of test files.

1 call to CoderSniffUnitTest::getTestFiles()
CoderSniffUnitTest::testSniff in coder_sniffer/Test/CoderSniffUnitTest.php
Tests the extending classes Sniff class.
2 methods override CoderSniffUnitTest::getTestFiles()
Drupal_BadUnitTest::getTestFiles in coder_sniffer/Test/bad/BadUnitTest.php
Returns a list of test files that should be checked.
Drupal_GoodUnitTest::getTestFiles in coder_sniffer/Test/good/GoodUnitTest.php
Returns a list of test files that should be checked.

File

coder_sniffer/Test/CoderSniffUnitTest.php, line 85

Class

CoderSniffUnitTest
An abstract class that all sniff unit tests must extend.

Code

protected function getTestFiles() {

  // The basis for determining file locations.
  $basename = substr(get_class($this), 0, -8);
  $parts = explode('_', $basename);

  // The name of the dummy file we are testing.
  $testFileBase = dirname(__FILE__) . DIRECTORY_SEPARATOR . $parts[2] . DIRECTORY_SEPARATOR . $parts[3] . 'UnitTest.';

  // Get a list of all test files to check. These will have the same base
  // name but different extensions. We ignore the .php file as it is the class.
  $testFiles = array();
  $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR));
  $di = new DirectoryIterator($dir);
  foreach ($di as $file) {
    $path = $file
      ->getPathname();
    if (substr($path, 0, strlen($testFileBase)) === $testFileBase) {
      if ($path !== $testFileBase . 'php') {
        $testFiles[] = $path;
      }
    }
  }

  // Get them in order.
  sort($testFiles);
  return $testFiles;
}