Ejemplo n.º 1
0
    }
    public function getMailer()
    {
        return parent::getMailer();
    }
}
chdir($rootDir);
$task = new ApplicationTask($dispatcher, new sfFormatter());
try {
    $task->run();
    $t->pass('->run() creates an application configuration if none is set');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->run() creates an application configuration if none is set');
}
$task = new ApplicationTask($dispatcher, new sfFormatter());
$task->setConfiguration($configuration);
try {
    $task->run();
    $t->pass('->run() creates an application configuration if only a project configuration is set');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->run() creates an application configuration if only a project configuration is set');
}
// ->getServiceContainer()
$t->diag('->getServiceContainer()');
$serviceContainer = $task->getServiceContainer();
$t->ok($serviceContainer instanceof sfServiceContainer, '->getServiceContainer() returns an sfServiceContainer');
$t->is($serviceContainer, $task->getServiceContainer(), '->getServiceContainer() returns always the same instance');
$t->ok($serviceContainer->hasService('my_project_service'), '->getServiceContainer() is correctly configured');
// ->getRouting()
Ejemplo n.º 2
0
class ApplicationTask extends sfBaseTask
{
    protected function configure()
    {
        $this->addOption('application', null, sfCommandOption::PARAMETER_REQUIRED, '', true);
    }
    protected function execute($arguments = array(), $options = array())
    {
        if (!$this->configuration instanceof sfApplicationConfiguration) {
            throw new Exception('This task requires an application configuration be loaded.');
        }
    }
}
chdir($rootDir);
$task = new ApplicationTask($dispatcher, new sfFormatter());
try {
    $task->run();
    $t->pass('->run() creates an application configuration if none is set');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->run() creates an application configuration if none is set');
}
$task = new ApplicationTask($dispatcher, new sfFormatter());
$task->setConfiguration($configuration);
try {
    $task->run();
    $t->pass('->run() creates an application configuration if only a project configuration is set');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->run() creates an application configuration if only a project configuration is set');
}