Skip to content
Permalink
Browse files

Made SchemaShell::view() work better with plugins. Tests added.

  • Loading branch information...
markstory committed Oct 4, 2009
1 parent 30ef796 commit 75f21064204bb4a0f15cbf829b58dcfdb330d690
Showing with 38 additions and 4 deletions.
  1. +14 −4 cake/console/libs/schema.php
  2. +24 −0 cake/tests/cases/console/libs/schema.test.php
@@ -61,26 +61,36 @@ function startup() {
$name = $file = $path = $connection = $plugin = null;
if (!empty($this->params['name'])) {
$name = $this->params['name'];
} elseif (!empty($this->args[0])) {
$name = $this->params['name'] = $this->args[0];
}
if (strpos($name, '.')) {
list($this->params['plugin'], $this->params['name']) = explode('.', $name);
$name = $this->params['name'];
}
if ($name) {
$this->params['file'] = Inflector::underscore($name);
}
if (empty($this->params['file'])) {
$this->params['file'] = 'schema.php';
}
if (!empty($this->params['path'])) {
$path = $this->params['path'];
}
if (strpos($this->params['file'], '.php') === false) {
$this->params['file'] .= '.php';
}
$file = $this->params['file'];
if (!empty($this->params['path'])) {
$path = $this->params['path'];
}
if (!empty($this->params['connection'])) {
$connection = $this->params['connection'];
}
if (!empty($this->params['plugin'])) {
$plugin = $this->params['plugin'];
}
$this->Schema =& new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
}
@@ -184,9 +184,33 @@ function testView() {
$this->Shell->Schema->path = APP . 'config' . DS . 'schema';
$this->Shell->params['file'] = 'i18n.php';
$this->Shell->expectOnce('_stop');
$this->Shell->expectOnce('out');
$this->Shell->view();
}
/**
* test that view() can find plugin schema files.
*
* @return void
**/
function testViewWithPlugins() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->args = array('TestPlugin.schema');
$this->Shell->startup();
$this->Shell->expectCallCount('_stop', 2);
$this->Shell->expectCallCount('out', 2);
$this->Shell->view();
$this->Shell->args = array();
$this->Shell->params = array('plugin' => 'TestPlugin');
$this->Shell->startup();
$this->Shell->view();
App::build();
}
/**
* test dump() with sql file generation
*

0 comments on commit 75f2106

Please sign in to comment.
You can’t perform that action at this time.