Changeset 2279

Show
Ignore:
Timestamp:
03/10/08 17:43:37 (6 months ago)
Author:
Geert
Message:

Added unit_test config where you can set default test paths.

Location:
trunk/modules/unit_test
Files:
2 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r2278 r2279  
    2929    public function __construct() 
    3030    { 
     31        // Merge possible default test path(s) from config with the rest 
     32        $paths = array_merge(func_get_args(), Config::item('unit_test.paths', FALSE, FALSE)); 
     33 
     34        // Normalize all test paths 
     35        foreach ($paths as $path) 
     36        { 
     37            $path = str_replace('\\', '/', realpath((string) $path)); 
     38        } 
     39 
     40        // Take out duplicate test paths after normalization 
     41        $this->paths = array_unique($paths); 
     42 
    3143        // Loop over each given test path 
    32         foreach (func_get_args() as $path) 
     44        foreach ($this->paths as $path) 
    3345        { 
    34             // Normalize all given test paths and store them 
    35             $this->paths[] = $test_path = str_replace('\\', '/', realpath((string) $path)); 
    36  
    3746            // Validate test path 
    38             if ( ! is_dir($test_path)) 
    39                 throw new Kohana_Exception('unit_test.invalid_test_path', $test_path); 
     47            if ( ! is_dir($path)) 
     48                throw new Kohana_Exception('unit_test.invalid_test_path', $path); 
    4049 
    4150            // Recursively iterate over each file in the test path 
    4251            foreach 
    4352            ( 
    44                 new RecursiveIteratorIterator(new RecursiveDirectoryIterator($test_path, RecursiveDirectoryIterator::KEY_AS_PATHNAME)) 
     53                new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME)) 
    4554                as $path => $file 
    4655            )