Skip to content

Instantly share code, notes, and snippets.

@havvg
Created May 1, 2010 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havvg/386638 to your computer and use it in GitHub Desktop.
Save havvg/386638 to your computer and use it in GitHub Desktop.
<?php
require_once(dirname(__FILE__) . '/../bootstrap/task.php');
# load fixtures of this plugin
$propelData->loadData(sfConfig::get('sf_plugins_dir') . '/yetAnotherPlugin/data/fixtures');
$limeTest = new lime_test(1, new lime_output_color());
$task = new ExampleTask($dispatcher, $formatter);
$task->run(array(), array());
$logs = $logger->getLogEntries();
$limeTest->like($logs[0], '/Task did log something/', 'Log entry found.');
<?php
// initialize configuration
$_test_dir = realpath(dirname(__FILE__) . '/..');
require_once(dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php');
$configuration = new ProjectConfiguration(realpath($_test_dir . '/..'));
// initialize lime
require_once($configuration->getSymfonyLibDir() . '/vendor/lime/lime.php');
// add autoloader
require_once($configuration->getSymfonyLibDir() . '/autoload/sfCoreAutoload.class.php');
sfCoreAutoload::register();
// add propel database fixture loader
new sfDatabaseManager(ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true));
$propelData = new sfPropelData();
class TaskLogger
{
protected $logEntries = array();
public function log(sfEvent $event)
{
$params = $event->getParameters();
$this->logEntries[] = $params[0];
}
public function getLogEntries()
{
return $this->logEntries;
}
}
$logger = new TaskLogger();
$formatter = new sfFormatter(80);
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('command.log', array($logger, "log"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment