* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Launches all tests. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id: sfTestAllTask.class.php 29415 2010-05-12 06:24:54Z fabien $ */ class sfTestAllTask extends sfTestBaseTask { /** * @see sfTask */ protected function configure() { $this->addOptions(array( new sfCommandOption('only-failed', 'f', sfCommandOption::PARAMETER_NONE, 'Only run tests that failed last time'), new sfCommandOption('xml', null, sfCommandOption::PARAMETER_REQUIRED, 'The file name for the JUnit compatible XML log file'), )); $this->namespace = 'test'; $this->name = 'all'; $this->briefDescription = 'Launches all tests'; $this->detailedDescription = << isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'], )); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir'); $status = false; $statusFile = sfConfig::get('sf_cache_dir').'/.test_all_status'; if ($options['only-failed']) { if (file_exists($statusFile)) { $status = unserialize(file_get_contents($statusFile)); } } if ($status) { foreach ($status as $file) { $h->register($file); } } else { // filter and register all tests $finder = sfFinder::type('file')->follow_link()->name('*Test.php'); $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options)); } $ret = $h->run() ? 0 : 1; file_put_contents($statusFile, serialize($h->get_failed_files())); if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; } }