public function __construct(sfEventDispatcher $dispatcher, sfPearEnvironment $environment = null)
 {
     if (!$environment) {
         $environment = new sfPearEnvironment($dispatcher, array('plugin_dir' => sfConfig::get('sf_plugins_dir'), 'cache_dir' => sfConfig::get('sf_cache_dir') . '/.pear', 'web_dir' => sfConfig::get('sf_web_dir'), 'rest_base_class' => 'opPearRest'));
         try {
             $environment->registerChannel(self::OPENPNE_PLUGIN_CHANNEL, true);
         } catch (sfPluginException $e) {
         }
     }
     parent::__construct($dispatcher, $environment);
 }
 public function __construct(sfEventDispatcher $dispatcher, sfPearEnvironment $environment = null, $channel = null)
 {
     if (!$environment) {
         $tz = @date_default_timezone_get();
         $environment = new sfPearEnvironment($dispatcher, array('plugin_dir' => sfConfig::get('sf_plugins_dir'), 'cache_dir' => sfConfig::get('sf_cache_dir') . '/.pear', 'web_dir' => sfConfig::get('sf_web_dir'), 'rest_base_class' => 'opPearRest', 'downloader_base_class' => 'opPluginDownloader'));
         date_default_timezone_set($tz);
         $this->channel = $channel;
         if (!$this->channel) {
             $this->channel = self::getDefaultPluginChannelServerName();
         }
         try {
             $environment->registerChannel($this->channel, true);
         } catch (sfPluginException $e) {
         }
     }
     parent::__construct($dispatcher, $environment);
     // register OpenPNE for dependencies
     $this->registerOpenPNEPackage();
 }
示例#3
0
@(include_once 'PEAR.php');
if (!class_exists('PEAR')) {
    $t->skip('PEAR must be installed', 5);
    return;
}
require_once __DIR__ . '/sfPearDownloaderTest.class.php';
require_once __DIR__ . '/sfPearRestTest.class.php';
require_once __DIR__ . '/sfPluginTestHelper.class.php';
// setup
$temp = tempnam('/tmp/sf_plugin_test', 'tmp');
unlink($temp);
mkdir($temp, 0777, true);
define('SF_PLUGIN_TEST_DIR', $temp);
$options = array('plugin_dir' => $temp . '/plugins', 'cache_dir' => $temp . '/cache', 'preferred_state' => 'stable', 'rest_base_class' => 'sfPearRestTest', 'downloader_base_class' => 'sfPearDownloaderTest');
$dispatcher = new sfEventDispatcher();
$environment = new sfPearEnvironment($dispatcher, $options);
$environment->registerChannel('pear.example.com', true);
$rest = $environment->getRest();
// ->getPluginVersions()
$t->diag('->getPluginVersions()');
$t->is($rest->getPluginVersions('sfTestPlugin'), array('1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() returns an array of stable versions for a plugin');
$t->is($rest->getPluginVersions('sfTestPlugin', 'stable'), array('1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() accepts stability as a second parameter and returns an array of versions for a plugin based on stability');
$t->is($rest->getPluginVersions('sfTestPlugin', 'beta'), array('1.0.4', '1.1.4', '1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() accepts stability as a second parameter and returns an array of versions for a plugin based on stability cascade (beta includes stable)');
// ->getPluginDependencies()
$t->diag('->getPluginDependencies()');
$dependencies = $rest->getPluginDependencies('sfTestPlugin', '1.1.4');
$t->is($dependencies['required']['package']['min'], '1.1.0', '->getPluginDependencies() returns an array of dependencies');
// ->getPluginDownloadURL()
$t->diag('->getPluginDownloadURL()');
$t->is($rest->getPluginDownloadURL('sfTestPlugin', '1.1.3', 'stable'), 'http://pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.3.tgz', '->getPluginDownloadURL() returns a plugin URL');
// teardown
示例#4
0
}
require_once dirname(__FILE__) . '/sfPearDownloaderTest.class.php';
require_once dirname(__FILE__) . '/sfPearRestTest.class.php';
require_once dirname(__FILE__) . '/sfPluginTestHelper.class.php';
// setup
$temp = tempnam('/tmp/sf_plugin_test', 'tmp');
unlink($temp);
mkdir($temp, 0777, true);
define('SF_PLUGIN_TEST_DIR', $temp);
$options = array('plugin_dir' => $temp . '/plugins', 'cache_dir' => $temp . '/cache', 'preferred_state' => 'stable', 'rest_base_class' => 'sfPearRestTest', 'downloader_base_class' => 'sfPearDownloaderTest');
$dispatcher = new sfEventDispatcher();
// ->initialize()
$t->diag('->initialize()');
foreach (array('plugin_dir', 'cache_dir') as $option) {
    try {
        $localOptions = $options;
        unset($localOptions[$option]);
        $environment = new sfPearEnvironment($dispatcher, $localOptions);
        $t->fail(sprintf('->initialize() throws an exception if you don\'t pass a "%s" option', $option));
    } catch (sfException $e) {
        $t->pass(sprintf('->initialize() throws an exception if you don\'t pass a "%s" option', $option));
    }
}
// ->registerChannel()
$t->diag('->registerChannel()');
$environment = new sfPearEnvironment($dispatcher, $options);
$environment->registerChannel('pear.example.com', true);
$t->pass('->registerChannel() registers a PEAR channel');
// teardown
sfToolkit::clearDirectory($temp);
rmdir($temp);