0edae91b96db307da5513316bc7395bcc75f498e
Author: gwoo
Date: 2009-07-12 05:05:44 -0700
diff --git a/tests/cases/behaviors/empty b/tests/cases/behaviors/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/cases/controllers/empty b/tests/cases/controllers/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/cases/controllers/plugins_controller.test.php b/tests/cases/controllers/plugins_controller.test.php
index 5503719..e7ff7fc 100644
--- a/tests/cases/controllers/plugins_controller.test.php
+++ b/tests/cases/controllers/plugins_controller.test.php
@@ -9,6 +9,7 @@ class TestPlugins extends PluginsController {
class PluginsControllerTest extends CakeTestCase {
var $Plugins = null;
+ var $fixtures = array('app.plugin');
function setUp() {
$this->Plugins = new TestPlugins();
diff --git a/tests/cases/models/empty b/tests/cases/models/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/cases/models/plugin.test.php b/tests/cases/models/plugin.test.php
index 236d4c7..6316d31 100644
--- a/tests/cases/models/plugin.test.php
+++ b/tests/cases/models/plugin.test.php
@@ -5,7 +5,7 @@ App::import('Model', 'Plugin');
class PluginTestCase extends CakeTestCase {
var $Plugin = null;
- var $fixtures = array('app.plugin', 'app.user');
+ var $fixtures = array('app.plugin');
function startTest() {
$this->Plugin =& ClassRegistry::init('Plugin');
diff --git a/tests/fixtures/empty b/tests/fixtures/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/groups/empty b/tests/groups/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/shells/plugins.test.php b/tests/shells/plugins.test.php
new file mode 100644
index 0000000..8452ef7
--- /dev/null
+++ b/tests/shells/plugins.test.php
@@ -0,0 +1,18 @@
+<?php
+class PluginsShellTestCase extends CakeTestCase {
+ var $Plugin = null;
+ var $fixtures = array('app.plugin');
+
+ function startTest() {
+ $this->Plugin =& ClassRegistry::init('Plugin');
+ }
+
+ function testPluginInstance() {
+ $this->assertTrue(is_a($this->Plugin, 'Plugin'));
+ }
+
+ function testPluginFind() {
+ $this->assertEqual($results, $expected);
+ }
+}
+?>
\ No newline at end of file
diff --git a/vendors/shells/plugins.php b/vendors/shells/plugins.php
index e209b4c..45ab1a8 100644
--- a/vendors/shells/plugins.php
+++ b/vendors/shells/plugins.php
@@ -16,13 +16,6 @@ class PluginsShell extends Shell {
var $Socket = null;
/**
- * Plugins server hostname.
- *
- * @var string
- */
- var $serverUri = 'http://plugins.thoughtglade.com';
-
- /**
* String used to split and concatenate files during plugin packaging.
*
* @var string
@@ -41,21 +34,69 @@ class PluginsShell extends Shell {
*
* @var string
*/
- var $uploadSizeLimit = 5242880;
-
+ var $_uploadSizeLimit = 5242880;
/**
* Main shell logic.
*
* @return void
- * @author John David Anderson
*/
- function main() {
+ function statup() {
+ if(empty($this->params['server'])) {
+ $this->params['server'] = 'http://plugins.cakephp.org';
+ $this->out(sprintf(__('Server: %s', true), $this->params['server']));
+ }
+
+ if (!strpos($this->params['server'] , 'http://') == false) {
+ $this->params['server'] = 'http://' . $this->params['server'];
+ }
+ }
+ /**
+ * Initialize the database and insert the schema.
+ *
+ * @return void
+ **/
+ public function setup() {
+ $this->initdb();
+ $this->set_routes();
+ }
+ /**
+ * Initialize the database and insert the schema.
+ *
+ * @return void
+ **/
+ public function initdb() {
+ $this->Dispatch->args = array('schema', 'run', 'create');
+ $this->Dispatch->params['name'] = 'Plugins';
+ $this->Dispatch->params['path'] = dirname(dirname(dirname(__FILE__))) . DS. 'config';
+ $this->Dispatch->dispatch();
+ }
+ /**
+ * Initialize the database and insert the schema.
+ *
+ * @return void
+ **/
+ public function set_routes() {
+ $Routes = new File(CONFIGS . 'routes.php');
+ $new = array(
+ "Router::mapResources('plugins');",
+ "Router::parseExtensions();"
+ );
- if(isset($this->params['server'])) {
- $this->serverUri = $this->params['server'];
- $this->out('Using specified server: ' . $this->serverUri);
+ $data = rtrim(trim($Routes->read()), "?>") . "\n\n\t" . join("\n\n\t", $new);
+ if ($Routes->write($data)) {
+ $this->out(__('Routes file updated'));
+ return;
}
+ $this->out(__('Routes file NOT updated'));
+ return;
+ }
+ /**
+ * Main shell logic.
+ *
+ * @return void
+ */
+ function main() {
$this->Socket = new HttpSocket();
if(!empty($this->command)) {
@@ -69,7 +110,6 @@ class PluginsShell extends Shell {
* Main application flow control.
*
* @return void
- * @author John David Anderson
*/
function __run() {
$validCommands = array('i','u','c');
@@ -95,19 +135,6 @@ class PluginsShell extends Shell {
break;
}
}
-
- /**
- * Loads a list of plugins in the current app.
- *
- * @return void
- * @author John David Anderson
- */
- function __listPlugins() {
- $pluginsFolder = new Folder(APP . 'plugins');
- $filesAndDirectories = $pluginsFolder->ls(true, true);
- return $filesAndDirectories[0];
- }
-
/**
* Shows a short help screen.
*
@@ -126,7 +153,7 @@ class PluginsShell extends Shell {
* @author John David Anderson
*/
function __doUpload() {
- $plugins = $this->__listPlugins();
+ $plugins = Configure::listObjects('plugins');
$selectedPlugin = null;
@@ -213,7 +240,7 @@ class PluginsShell extends Shell {
$data['Plugin']['data'] = $package->read();
- $xmlResponse = new Xml($this->Socket->post($this->serverUri . '/plugins/upload', array(
+ $xmlResponse = new Xml($this->Socket->post($this->params['server'] . '/plugins/upload', array(
'data' => $data,
)));
@@ -237,7 +264,7 @@ class PluginsShell extends Shell {
* @return boolean $success
*/
function __checkName($name) {
- $xmlResponse = new Xml($this->Socket->get($this->serverUri . '/plugins/checkName/' . $name . '.xml'));
+ $xmlResponse = new Xml($this->Socket->get($this->params['server'] . '/plugins/checkName/' . $name . '.xml'));
return (isset($xmlResponse->children[0]->attributes['type']) && $xmlResponse->children[0]->attributes['type'] == 'success');
}
@@ -279,7 +306,7 @@ class PluginsShell extends Shell {
$package->close();
- if($package->size() >= $this->uploadSizeLimit)
+ if($package->size() >= $this->_uploadSizeLimit)
{
$this->out("Plugin larger than the current limit size. Please contact psychic@cakephp.org if you'd like us to manually upload your (large) plugin.");
die();
@@ -308,7 +335,7 @@ class PluginsShell extends Shell {
$searchTerm = $this->in("\nPlease type the name of the plugin you'd like to install, or a search keyword.");
}
- $xmlResponse = new Xml($this->Socket->post($this->serverUri . '/plugins/search.xml', array(
+ $xmlResponse = new Xml($this->Socket->post($this->params['server'] . '/plugins/search.xml', array(
'data' => array(
'Plugin' => array(
'query' => $searchTerm,
@@ -385,7 +412,7 @@ class PluginsShell extends Shell {
$this->out("\nFetching plugin package...");
- $data = $this->Socket->get($this->serverUri . '/plugins/download/' . $selectedPluginName);
+ $data = $this->Socket->get($this->params['server'] . '/plugins/download/' . $selectedPluginName);
$this->out("Done.");
$files = explode($this->fileDelimiter, $data);
@@ -442,7 +469,7 @@ class PluginsShell extends Shell {
* @author John David Anderson
*/
function __checkForUpdates() {
- $plugins = $this->__listPlugins();
+ $plugins = Configure::listObjects('plugins');
if(count($plugins) < 1) {
$this->out("No plugins found.");
@@ -454,7 +481,7 @@ class PluginsShell extends Shell {
if($manifest->exists()) {
$localXml = new Xml($manifest->read());
- $remoteXml = new Xml($this->serverUri . '/plugins/searchByName/' . $plugin . '.xml');
+ $remoteXml = new Xml($this->params['server'] . '/plugins/searchByName/' . $plugin . '.xml');
$localModified = strtotime($localXml->children[0]->attributes['modified']);
$remoteModified = strtotime($remoteXml->children[0]->attributes['modified']);
@@ -486,20 +513,9 @@ class PluginsShell extends Shell {
* @return boolean $success
*/
function __checkUuid($name, $uuid) {
- $xmlResponse = new Xml($this->Socket->get($this->serverUri . '/plugins/checkId/' . $name . '/' . $uuid . '.xml'));
+ $xmlResponse = new Xml($this->Socket->get($this->params['server'] . '/plugins/checkId/' . $name . '/' . $uuid . '.xml'));
return (isset($xmlResponse->children[0]->attributes['type']) && $xmlResponse->children[0]->attributes['type'] == 'success');
}
-
- /**
- * Initialize the database and insert the schema.
- *
- * @return void
- **/
- public function initdb() {
- $this->Dispatch->args = array('schema', 'run', 'create', 'Plugins');
- $this->Dispatch->params['path'] = dirname(dirname(dirname(__FILE__))) . DS. 'config';
- $this->Dispatch->dispatch();
- }
}
?>
\ No newline at end of file
diff --git a/vendors/shells/tasks/empty b/vendors/shells/tasks/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/vendors/shells/templates/empty b/vendors/shells/templates/empty
deleted file mode 100644
index e69de29..0000000
