Development

Changeset 23205

You must first sign up to be able to contribute.

Changeset 23205

Show
Ignore:
Timestamp:
10/20/09 15:20:17 (4 years ago)
Author:
Kris.Wallsmith
Message:

[1.3] fixed project autoloading in unit tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.3/lib/autoload/sfAutoload.class.php

    r20867 r23205  
    7474  } 
    7575 
     76  /** 
     77   * Sets the path for a particular class. 
     78   * 
     79   * @param string $class A PHP class name 
     80   * @param string $path  An absolute path 
     81   */ 
    7682  public function setClassPath($class, $path) 
    7783  { 
     
    8389  } 
    8490 
     91  /** 
     92   * Returns the path where a particular class can be found. 
     93   * 
     94   * @param string $class A PHP class name 
     95   * 
     96   * @return string|null An absolute path 
     97   */ 
    8598  public function getClassPath($class) 
    8699  { 
  • branches/1.3/lib/autoload/sfCoreAutoload.class.php

    r23200 r23205  
    410410    'sfpropelupgrade' => 'task/project/upgrade1.3/sfPropelUpgrade.class.php', 
    411411    'sftasksupgrade' => 'task/project/upgrade1.3/sfTasksUpgrade.class.php', 
     412    'sftestsupgrade' => 'task/project/upgrade1.3/sfTestsUpgrade.class.php', 
    412413    'sfupgrade' => 'task/project/upgrade1.3/sfUpgrade.class.php', 
    413414    'sfyamlupgrade' => 'task/project/upgrade1.3/sfYamlUpgrade.class.php', 
  • branches/1.3/lib/autoload/sfSimpleAutoload.class.php

    r23063 r23205  
    100100 
    101101  /** 
    102    * Returns true if sfSimpleAutoload is registered as an autoloader. 
    103    */ 
    104   static public function isRegistered() 
    105   { 
    106     return self::$registered; 
    107   } 
    108  
    109   /** 
    110102   * Handles autoloading of classes. 
    111103   * 
     
    317309  } 
    318310 
     311  /** 
     312   * Returns the path where a particular class can be found. 
     313   * 
     314   * @param string $class A PHP class name 
     315   * 
     316   * @return string|null An absolute path 
     317   */ 
    319318  public function getClassPath($class) 
    320319  { 
     
    323322    return isset($this->classes[$class]) ? $this->classes[$class] : null; 
    324323  } 
     324 
     325  /** 
     326   * Loads configuration from the supplied files. 
     327   * 
     328   * @param array $files An array of autoload.yml files 
     329   *  
     330   * @see sfAutoloadConfigHandler 
     331   */ 
     332  public function loadConfiguration(array $files) 
     333  { 
     334    $config = new sfAutoloadConfigHandler(); 
     335    foreach ($config->evaluate($files) as $class => $file) 
     336    { 
     337      $this->setClassPath($class, $file); 
     338    } 
     339  } 
    325340} 
  • branches/1.3/lib/config/sfPluginConfiguration.class.php

    r23060 r23205  
    114114    { 
    115115      $this->configuration->getEventDispatcher()->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); 
    116  
    117       $config = new sfAutoloadConfigHandler(); 
    118       $mappings = $config->evaluate(array($file)); 
    119  
    120       foreach ($mappings as $class => $file) 
    121       { 
    122         $autoload->setClassPath($class, $file); 
    123       } 
     116      $autoload->loadConfiguration(array($file)); 
    124117    } 
    125118    else 
  • branches/1.3/lib/task/generator/skeleton/project/test/bootstrap/unit.php

    r14688 r23205  
    33/* 
    44 * This file is part of the symfony package. 
    5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
     5 * (c) Fabien Potencier <fabien.potencier@symfony-project.com> 
    66 *  
    77 * For the full copyright and license information, please view the LICENSE 
     
    1111$_test_dir = realpath(dirname(__FILE__).'/..'); 
    1212 
     13// configuration 
    1314require_once dirname(__FILE__).'/../../config/ProjectConfiguration.class.php'; 
     15$configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir.'/..')); 
    1416 
    15 if (ProjectConfiguration::hasActive()) 
    16 
    17   $configuration = ProjectConfiguration::getActive(); 
    18 
    19 else 
    20 
    21   $configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 
    22 
     17// autoloader 
     18$autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir').'/project_autoload.cache'); 
     19$autoload->loadConfiguration(sfFinder::type('file')->name('autoload.yml')->in(array( 
     20  sfConfig::get('sf_symfony_lib_dir').'/config/config', 
     21  sfConfig::get('sf_config_dir'), 
     22))); 
     23$autoload->register(); 
    2324 
     25// lime 
    2426include $configuration->getSymfonyLibDir().'/vendor/lime/lime.php'; 
  • branches/1.3/lib/task/sfBaseTask.class.php

    r23063 r23205  
    239239    if (!$configuration instanceof sfApplicationConfiguration) 
    240240    { 
    241       $autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir').'/project_autoload.cache'); 
    242  
    243241      // plugins 
    244242      if ($reload) 
     
    251249 
    252250      // project 
    253       $files = array(sfConfig::get('sf_symfony_lib_dir').'/config/config/autoload.yml'); 
    254       if (is_readable($file = sfConfig::get('sf_config_dir').'/autoload.yml')) 
    255       { 
    256         $files[] = $file; 
    257       } 
    258  
    259       $config = new sfAutoloadConfigHandler(); 
    260       foreach ($config->evaluate($files) as $class => $file) 
    261       { 
    262         $autoload->setClassPath($class, $file); 
    263       } 
     251      $autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir').'/project_autoload.cache'); 
     252      $autoload->loadConfiguration(sfFinder::type('file')->name('autoload.yml')->in(array( 
     253        sfConfig::get('sf_symfony_lib_dir').'/config/config', 
     254        sfConfig::get('sf_config_dir'), 
     255      ))); 
     256      $autoload->register(); 
    264257 
    265258      if ($reload) 
     
    268261        $autoload->reload(); 
    269262      } 
    270  
    271       $autoload->register(); 
    272263    } 
    273264  }