/**
  * Listens to context.load_factories. Bootstraps the plugin
  */
 public function bootstrap(sfEvent $event)
 {
     // store the context so we can use it for other listeners
     $this->_context = $event->getSubject();
     // create the theme manager instance
     $this->_themeManager = sfThemeManager::createInstance($this->_context);
     // Refresh the theme from the context
     $this->_refreshTheme();
 }
// remove the extra css
// This is how the css is loaded in if using the alternate syntax in app.yml
$cssOptionThemeconfig = $themeConfig;
$cssOptionThemeconfig['stylesheets'] = array(array('main.css' => array('media' => 'print', 'position' => 'first')));
$manager->addTheme('css_theme', $cssOptionThemeconfig);
$manager->setCurrentTheme('css_theme');
$t->is($context->getResponse()->getStylesheets(), array('main.css' => array('media' => 'print')), 'The stylesheets media option was translated correctly');
$t->is($context->getResponse()->getStylesheets(sfWebResponse::FIRST), array('main.css' => array('media' => 'print')), 'The stylesheet was added to the "first" position');
$t->info('3 - Test the theme.filter_asset_paths method which allows rewriting of asset paths');
$context->getEventDispatcher()->connect('theme.filter_asset_paths', 'rewriteAssets');
function rewriteAssets(sfEvent $event, $assets)
{
    foreach ($assets as $key => $asset) {
        $assets[$key]['file'] = 'changed';
        $assets[$key]['options'] = array('media' => 'print');
    }
    return $assets;
}
$t->info('  3.1 - Set the "good_theme" theme, should bring in main css');
$manager->setCurrentTheme('good_theme');
$t->is($context->getResponse()->getStylesheets(), array('changed' => array('media' => 'print')), 'The main css stylesheet was changed to "changed" and an option was added');
$context->getEventDispatcher()->disconnect('theme.filter_asset_paths', 'rewriteAssets');
$t->info('4 - Test the createInstance() method');
$manager = sfThemeManager::createInstance($context);
$t->is(get_class($manager), 'sfThemeTestManager', 'The class of the created object is sfThemeTestManager, as set in app.yml');
$t->is(array_keys($manager->getThemes()), array('test_theme', 'unavailable_theme', 'app_test'), 'All the themes loaded correctly from app.yml - the disabled theme is NOT loaded');
$t->is(get_class($manager->getThemeObject('app_test')), 'sfTestTheme', 'The theme objects have class sfTestTheme from app.yml');
$t->info('  4.1 - Test ->getAvailableThemes() while I\'m here');
$availableThemes = $manager->getAvailableThemes();
$t->is(isset($availableThemes['unavailable_theme']), false, '->getAvailableThemes() does not include unavailable_theme theme');
$t->is(count($availableThemes), 2, '->getAvailableThemes() returns 2 themes (1 from other plugin, 1 from app)');