| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
if (!isset($_SERVER['SYMFONY'])) |
|---|
| 4 |
{ |
|---|
| 5 |
throw new RuntimeException('Could not find symfony core libraries.'); |
|---|
| 6 |
} |
|---|
| 7 |
|
|---|
| 8 |
require_once $_SERVER['SYMFONY'].'/autoload/sfCoreAutoload.class.php'; |
|---|
| 9 |
sfCoreAutoload::register(); |
|---|
| 10 |
|
|---|
| 11 |
$configuration = new sfProjectConfiguration(dirname(__FILE__).'/../fixtures/project'); |
|---|
| 12 |
require_once $configuration->getSymfonyLibDir().'/vendor/lime/lime.php'; |
|---|
| 13 |
|
|---|
| 14 |
function sfTaskExtraPlugin_autoload_again($class) |
|---|
| 15 |
{ |
|---|
| 16 |
$autoload = sfSimpleAutoload::getInstance(); |
|---|
| 17 |
$autoload->reload(); |
|---|
| 18 |
return $autoload->autoload($class); |
|---|
| 19 |
} |
|---|
| 20 |
spl_autoload_register('sfTaskExtraPlugin_autoload_again'); |
|---|
| 21 |
|
|---|
| 22 |
require_once dirname(__FILE__).'/../../config/sfTaskExtraPluginConfiguration.class.php'; |
|---|
| 23 |
$plugin_configuration = new sfTaskExtraPluginConfiguration($configuration, dirname(__FILE__).'/../..'); |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
class task_extra_lime_test extends lime_test |
|---|
| 29 |
{ |
|---|
| 30 |
|
|---|
| 31 |
* Executes a task and tests its success. |
|---|
| 32 |
* |
|---|
| 33 |
* @param string $taskClass |
|---|
| 34 |
* @param array $arguments |
|---|
| 35 |
* @param array $options |
|---|
| 36 |
* @param boolean $boolean |
|---|
| 37 |
* |
|---|
| 38 |
* @return boolean |
|---|
| 39 |
*/ |
|---|
| 40 |
public function task_ok($taskClass, array $arguments = array(), array $options = array(), $boolean = true, $message = null) |
|---|
| 41 |
{ |
|---|
| 42 |
$configuration = sfProjectConfiguration::getActive(); |
|---|
| 43 |
|
|---|
| 44 |
if (is_null($message)) |
|---|
| 45 |
{ |
|---|
| 46 |
$message = sprintf('"%s" execution %s', $taskClass, $boolean ? 'succeeded' : 'failed'); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
chdir(dirname(__FILE__).'/../fixtures/project'); |
|---|
| 50 |
|
|---|
| 51 |
$task = new $taskClass($configuration->getEventDispatcher(), new sfFormatter()); |
|---|
| 52 |
try |
|---|
| 53 |
{ |
|---|
| 54 |
$ok = $boolean === $task->run($arguments, $options) ? false : true; |
|---|
| 55 |
} |
|---|
| 56 |
catch (Exception $e) |
|---|
| 57 |
{ |
|---|
| 58 |
$ok = $boolean === false; |
|---|
| 59 |
if (!$ok) |
|---|
| 60 |
{ |
|---|
| 61 |
$message .= ' ('.$e->getMessage().')'; |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
return $this->ok($ok, $message); |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
function task_extra_cleanup() |
|---|
| 70 |
{ |
|---|
| 71 |
sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/cache'); |
|---|
| 72 |
sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/log'); |
|---|
| 73 |
sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/plugins'); |
|---|
| 74 |
sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/test/unit'); |
|---|
| 75 |
} |
|---|
| 76 |
task_extra_cleanup(); |
|---|
| 77 |
register_shutdown_function('task_extra_cleanup'); |
|---|
| 78 |
|
|---|