Skip to content

Commit

Permalink
Adding tests for SchemaShell::generate() with plugins, testing that p…
Browse files Browse the repository at this point in the history
…lugin schema files do not include non plugin models.
  • Loading branch information
markstory committed Oct 9, 2009
1 parent ace784a commit c5ec87e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion cake/tests/cases/console/libs/schema.test.php
Expand Up @@ -116,7 +116,7 @@ class SchemaShellTestSchema extends CakeSchema {
*/
class SchemaShellTest extends CakeTestCase {

var $fixtures = array('core.article', 'core.user');
var $fixtures = array('core.article', 'core.user', 'core.post', 'core.auth_user');
/**
* startTest method
*
Expand Down Expand Up @@ -330,6 +330,36 @@ function testGenerateOverwrite() {
unlink(TMP . 'schema.php');
}

/**
* test that generate() can read plugin dirs and generate schema files for the models
* in a plugin.
*
* @return void
**/
function testGenerateWithPlugins() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->params = array(
'plugin' => 'TestPlugin',
'connection' => 'test_suite'
);
$this->Shell->startup();
$this->Shell->Schema->path = TMP . 'tests' . DS;

$this->Shell->generate();
$file =& new File(TMP . 'tests' . DS . 'schema.php');
$contents = $file->read();

$this->assertPattern('/var \$posts/', $contents);
$this->assertPattern('/var \$auth_users/', $contents);
$this->assertNoPattern('/var \$users/', $contents);
$this->assertNoPattern('/var \$articles/', $contents);

$file->delete();
App::build();
}

/**
* Test schema run create with no table args.
*
Expand Down

0 comments on commit c5ec87e

Please sign in to comment.