[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/data/tasks/ -> sfPakeTest.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
   6   * 
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  pake_desc('launch unit tests');
  12  pake_task('test-unit', 'project_exists');
  13  
  14  pake_desc('launch functional tests for an application');
  15  pake_task('test-functional', 'project_exists');
  16  
  17  pake_desc('launch all tests');
  18  pake_task('test-all', 'project_exists');
  19  
  20  function run_test_all($task, $args)
  21  {
  22    require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
  23  
  24    $h = new lime_harness(new lime_output_color());
  25    $h->base_dir = sfConfig::get('sf_test_dir');
  26  
  27    // register all tests
  28    $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
  29    $h->register($finder->in($h->base_dir));
  30  
  31    $h->run();
  32  }
  33  
  34  function run_test_functional($task, $args)
  35  {
  36    if (!count($args))
  37    {
  38      throw new Exception('You must provide the app to test.');
  39    }
  40  
  41    $app = $args[0];
  42  
  43    if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
  44    {
  45      throw new Exception(sprintf('The app "%s" does not exist.', $app));
  46    }
  47  
  48    if (isset($args[1]))
  49    {
  50      foreach (array_splice($args, 1) as $path)
  51      {
  52        $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($path));
  53        foreach ($files as $file)
  54        {
  55          include($file);
  56        }
  57      }
  58    }
  59    else
  60    {
  61      require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
  62  
  63      $h = new lime_harness(new lime_output_color());
  64      $h->base_dir = sfConfig::get('sf_test_dir').'/functional/'.$app;
  65  
  66      // register functional tests
  67      $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
  68      $h->register($finder->in($h->base_dir));
  69  
  70      $h->run();
  71    }
  72  }
  73  
  74  function run_test_unit($task, $args)
  75  {
  76    if (isset($args[0]))
  77    {
  78      foreach ($args as $path)
  79      {
  80        $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'unit'.DIRECTORY_SEPARATOR.dirname($path));
  81        foreach ($files as $file)
  82        {
  83          include($file);
  84        }
  85      }
  86    }
  87    else
  88    {
  89      require_once(sfConfig::get('sf_symfony_lib_dir').'/vendor/lime/lime.php');
  90  
  91      $h = new lime_harness(new lime_output_color());
  92      $h->base_dir = sfConfig::get('sf_test_dir').'/unit';
  93  
  94      // register unit tests
  95      $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
  96      $h->register($finder->in($h->base_dir));
  97  
  98      $h->run();
  99    }
 100  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7