/**
  * Shortcut method to enable all Sympal plugins for the given ProjectConfiguration
  *
  * Returns an instance of sfSympalPluginEnabler which allows you to enable
  * disable and override any plugins with a convenient API.
  *
  * @param ProjectConfiguration $configuration
  * @return sfSympalPluginEnabler $enabler  Instance of sfSympalPluginEnabler
  */
 public static function enableSympalPlugins(ProjectConfiguration $configuration)
 {
     require_once dirname(__FILE__) . '/../lib/sfSympalPluginEnabler.class.php';
     $enabler = new sfSympalPluginEnabler($configuration);
     $enabler->enableSympalPlugins();
     return $enabler;
 }
Пример #2
0
$enabler->enableSympalCorePlugins('sfDoctrineGuardPlugin');
$t->is(count($projConfiguration->getPlugins()), 1, '->enableSympalCorePlugins() enables the core plugin');
$paths = $projConfiguration->getPluginPaths();
$t->is($paths[0], realpath(dirname(__FILE__) . '/../../lib/plugins/sfDoctrineGuardPlugin'), 'The plugin path of the core plugin is inside the lib/plugins dir of sympal');
$t->info('  2.4 - Disable a core plugin');
$enabler->disableSympalCorePlugins(array('sfDoctrineGuardPlugin'));
$t->is(count($projConfiguration->getPlugins()), 0, '->disableSympalCorePlugins() disables the core plugin');
$corePluginsCount = count(sfSympalPluginConfiguration::$corePlugins);
$installedPluginsCount = 3;
// in the test project's plugin directory
$otherPluginsCount = 2;
// sfSympalPlugin + sfDoctrinePlugin
$totalPluginsCount = $corePluginsCount + $installedPluginsCount + $otherPluginsCount;
$enabler->enableSympalPlugins();
$enablerApp1->enableSympalPlugins();
$enablerApp2->enableSympalPlugins();
$t->is(count($projConfiguration->getPlugins()), $totalPluginsCount, '->enableSympalPlugins() enables core plugins + anything in the plugins directory');
$t->is(count($appEnabledConfiguration->getPlugins()), $totalPluginsCount, '->enableSympalPlugins() enables core plugins + anything in the plugins directory');
$t->is(count($appDisabledConfiguration->getPlugins()), 0, '->enableSympalPlugins() enables no plugins if sympal is disabled for the application');
$t->info('  2.5 - Test overrideSympalPlugin()');
$projConfiguration->disablePlugins($projConfiguration->getPlugins());
$enabler->enableSympalCorePlugins(array('sfDoctrineGuardPlugin'));
$t->is(count($projConfiguration->getPlugins()), 1, 'Sanity check');
$enabler->overrideSympalPlugin('sfDoctrineGuardPlugin');
$t->is(count($projConfiguration->getPlugins()), 1, 'After overrideSympalPlugin(), the sfDoctrineGuardPlugin is still enabled');
$paths = $projConfiguration->getPluginPaths();
/*
 * The plugin path is false because it doesn't exist in the plugins directory.
 * I can't think of a good way to test this short of creating an sfDoctrineGuardPlugin
 * somewhere and pointing there. sfProjectConfiguration calls realpath, so
 * my attempts to set it to a non-existent dir result in a path of "false"