/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { require_once dirname(__FILE__) . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => 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; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $app = $arguments['application']; if (count($arguments['controller'])) { $files = array(); foreach ($arguments['controller'] as $controller) { $finder = sfFinder::type('file')->follow_link()->name(basename($controller) . 'Test.php'); $files = array_merge($files, $finder->in(sfConfig::get('sf_test_dir') . '/functional/' . $app . '/' . dirname($controller))); } if ($allFiles = $this->filterTestFiles($files, $arguments, $options)) { foreach ($allFiles as $file) { include $file; } } else { $this->logSection('functional', 'no controller found', null, 'ERROR'); } } else { require_once dirname(__FILE__) . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => $options['color'], 'verbose' => $options['trace'])); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir') . '/functional/' . $app; // filter and register functional 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; if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (count($arguments['name'])) { $files = array(); foreach ($arguments['name'] as $name) { $finder = sfFinder::type('file')->follow_link()->name(basename($name) . 'Test.php'); $files = array_merge($files, $finder->in(sfConfig::get('sf_test_dir') . '/unit/' . dirname($name))); } if ($allFiles = $this->filterTestFiles($files, $arguments, $options)) { foreach ($allFiles as $file) { include $file; } } else { $this->logSection('test', 'no tests found', null, 'ERROR'); } } else { require_once __DIR__ . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'], 'test_path' => sfConfig::get('sf_cache_dir') . '/lime')); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir') . '/unit'; // filter and register unit 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; if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $baseDir = sfConfig::get('sf_test_dir'); $finder = sfFinder::type('file')->follow_link()->name('*Test.php'); $files = array(); if ($arguments['files']) { $files = $this->filterWildcardFiles(array(), $arguments['files'], $arguments); } else { $files = $finder->in($baseDir); } $files = $this->filterTestFiles($files, $arguments, $options); if ($options['verbose'] || count($files) == 1) { $taskVars = array_merge(array_keys(get_defined_vars()), array('taskVars', 'testVars', 'file')); foreach ($files as $file) { $this->logSection('test', $file); include $file; // Free variables from tests. They are no longer needed $testVars = array_diff(array_keys(get_defined_vars()), $taskVars); foreach ($testVars as $varName) { unset(${$varName}); } } } else { require_once sfConfig::get('sf_symfony_lib_dir') . '/task/test/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => 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 = $baseDir; $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 $h->register($files); } $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; } }