From c5ec87e57769faf5101f19a14e1de3818342bebc Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 8 Oct 2009 22:40:17 -0400 Subject: [PATCH] Adding tests for SchemaShell::generate() with plugins, testing that plugin schema files do not include non plugin models. --- cake/tests/cases/console/libs/schema.test.php | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/console/libs/schema.test.php b/cake/tests/cases/console/libs/schema.test.php index c75789ebe27..e4b5921eef7 100644 --- a/cake/tests/cases/console/libs/schema.test.php +++ b/cake/tests/cases/console/libs/schema.test.php @@ -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 * @@ -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. *