You are here

function PatternsTestCase::runDir in Patterns 7

Same name and namespace in other branches
  1. 7.2 tests/patterns.test \PatternsTestCase::runDir()

Scans a directory for patterns files, and executes them.

Parameters

mixed $dir The path to the directory to scan:

File

tests/patterns.test, line 129
The base of the Patterns Component tests.

Class

PatternsTestCase
Abstract base class for testing pattern component behavior.

Code

function runDir($dir) {
  if (!file_exists($dir) || !is_readable($dir)) {
    $this
      ->error(t('Directory not found or not readable: ' . $dir));
    return FALSE;
  }
  if (!($handle = opendir($dir))) {
    $this
      ->error(t('Error opening directory') . ' ' . $dir);
    return FALSE;
  }
  while (false !== ($file = readdir($handle))) {
    $path_parts = pathinfo($file);
    $format = $path_parts['extension'];
    if (!patterns_parser_exists($format)) {
      continue;
    }
    $this
      ->runFile($file, 'Running' . ' ' . $file, $dir);
  }
  closedir($handle);
}