Browse Source

Fixed failing tests to reflect new config files.

Renan Gonçalves 13 years ago
parent
commit
711eae9858

App/Test/Case/Controller/Component/empty → App/Test/TestCase/Controller/Component/empty


App/Test/Case/Model/Behavior/empty → App/Test/TestCase/Model/Behavior/empty


App/Test/Case/View/Helper/empty → App/Test/TestCase/View/Helper/empty


+ 2 - 3
lib/Cake/Console/Command/AclShell.php

@@ -89,12 +89,11 @@ class AclShell extends Shell {
 		}
 
 		if ($this->command) {
-			if (!config('database')) {
-				$this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
+			if (Configure::check('Datasource') === null) {
+				$this->out(__d('cake_console', 'Your datasources configuration was not found. Take a moment to create one.'), true);
 				$this->args = null;
 				return $this->DbConfig->execute();
 			}
-			require_once (APP . 'Config/database.php');
 
 			if (!in_array($this->command, array('initdb'))) {
 				$collection = new ComponentCollection();

+ 10 - 40
lib/Cake/Console/Command/Task/ProjectTask.php

@@ -64,7 +64,7 @@ class ProjectTask extends Shell {
 		}
 
 		$response = false;
-		while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
+		while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'boostrap.php')) {
 			$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
 			$response = $this->in($prompt, array('y', 'n'), 'n');
 			if (strtolower($response) === 'n') {
@@ -79,14 +79,14 @@ class ProjectTask extends Shell {
 			if ($this->securitySalt($path) === true) {
 				$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
 			} else {
-				$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
+				$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'app.php'));
 				$success = false;
 			}
 
 			if ($this->securityCipherSeed($path) === true) {
 				$this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\''));
 			} else {
-				$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
+				$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'app.php'));
 				$success = false;
 			}
 
@@ -97,13 +97,6 @@ class ProjectTask extends Shell {
 				$success = false;
 			}
 
-			if ($this->consolePath($path) === true) {
-				$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
-			} else {
-				$this->err(__d('cake_console', 'Unable to set console path for app/Console.'));
-				$success = false;
-			}
-
 			$hardCode = false;
 			if ($this->cakeOnIncludePath()) {
 				$this->out(__d('cake_console', '<info>CakePHP is on your `include_path`. CAKE_CORE_INCLUDE_PATH will be set, but commented out.</info>'));
@@ -114,10 +107,9 @@ class ProjectTask extends Shell {
 			}
 			$success = $this->corePath($path, $hardCode) === true;
 			if ($success) {
-				$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
-				$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
+				$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in Config/paths.php', CAKE_CORE_INCLUDE_PATH));
 			} else {
-				$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php'));
+				$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'Config' . DS . 'paths.php'));
 				$success = false;
 			}
 			if ($success && $hardCode) {
@@ -227,28 +219,6 @@ class ProjectTask extends Shell {
 	}
 
 /**
- * Generates the correct path to the CakePHP libs that are generating the project
- * and points app/console/cake.php to the right place
- *
- * @param string $path Project path.
- * @return boolean success
- */
-	public function consolePath($path) {
-		$File = new File($path . 'Console/cake.php');
-		$contents = $File->read();
-		if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) {
-			$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " \$ds . '" : "'";
-			$replacement = $root . str_replace(DS, "' . \$ds . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
-			$result = str_replace($match[0], $replacement, $contents);
-			if ($File->write($result)) {
-				return true;
-			}
-			return false;
-		}
-		return false;
-	}
-
-/**
  * Generates and writes 'Security.salt'
  *
  * @param string $path Project path
@@ -302,7 +272,7 @@ class ProjectTask extends Shell {
  */
 	public function cachePrefix($dir) {
 		$app = basename($dir);
-		$File = new File($dir . 'Config/core.php');
+		$File = new File($dir . 'Config/cache.php');
 		$contents = $File->read();
 		if (preg_match('/(\$prefix = \'myapp_\';)/', $contents, $match)) {
 			$result = str_replace($match[0], '$prefix = \'' . $app . '_\';', $contents);
@@ -352,7 +322,7 @@ class ProjectTask extends Shell {
 	}
 
 /**
- * Enables Configure::read('Routing.prefixes') in /app/Config/core.php
+ * Enables Configure::read('Routing.prefixes') in /app/Config/routes.php
  *
  * @param string $name Name to use as admin routing
  * @return boolean Success
@@ -402,15 +372,15 @@ class ProjectTask extends Shell {
 		}
 		if ($this->interactive) {
 			$this->hr();
-			$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
+			$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/routes.php to use prefix routing.'));
 			$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
 			$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
 			while (!$admin) {
 				$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
 			}
 			if ($this->cakeAdmin($admin) !== true) {
-				$this->out(__d('cake_console', '<error>Unable to write to</error> /app/Config/core.php.'));
-				$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
+				$this->out(__d('cake_console', '<error>Unable to write to</error> /app/Config/routes.php.'));
+				$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/routes.php to use prefix routing.'));
 				$this->_stop();
 			}
 			return $admin . '_';

+ 1 - 1
lib/Cake/Console/Templates/skel/Config/paths.php

@@ -111,7 +111,7 @@ define('JS_URL', 'js/');
  * Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
  */
 //TODO include_path support.
-define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
+//define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
 
 define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
 

lib/Cake/Console/Templates/skel/Test/Case/Controller/Component/empty → lib/Cake/Console/Templates/skel/Test/TestCase/Controller/Component/empty


lib/Cake/Console/Templates/skel/Test/Case/Model/Behavior/empty → lib/Cake/Console/Templates/skel/Test/TestCase/Model/Behavior/empty


lib/Cake/Console/Templates/skel/Test/Case/View/Helper/empty → lib/Cake/Console/Templates/skel/Test/TestCase/View/Helper/empty


+ 8 - 33
lib/Cake/Test/TestCase/Console/Command/Task/ProjectTaskTest.php

@@ -97,6 +97,8 @@ class ProjectTaskTest extends TestCase {
 			'Test/TestCase/Controller/Component',
 			'Test/TestCase/Model',
 			'Test/TestCase/Model/Behavior',
+			'Test/TestCase/View',
+			'Test/TestCase/View/Helper',
 			'Test/Fixture',
 			'Vendor',
 			'View',
@@ -114,7 +116,6 @@ class ProjectTaskTest extends TestCase {
 			'webroot/files',
 			'webroot/img',
 			'webroot/js',
-
 		);
 		foreach ($dirs as $dir) {
 			$this->assertTrue(is_dir($path . DS . $dir), 'Missing ' . $dir);
@@ -133,10 +134,7 @@ class ProjectTaskTest extends TestCase {
 		$this->Task->execute();
 
 		$this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
-		$File = new File($path . DS . 'webroot/index.php');
-		$contents = $File->read();
-		$this->assertRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', .*?DS/', $contents);
-		$File = new File($path . DS . 'webroot/test.php');
+		$File = new File($path . DS . 'Config/paths.php');
 		$contents = $File->read();
 		$this->assertRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', .*?DS/', $contents);
 	}
@@ -159,10 +157,7 @@ class ProjectTaskTest extends TestCase {
 		$this->Task->execute();
 
 		$this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
-		$contents = file_get_contents($path . DS . 'webroot/index.php');
-		$this->assertRegExp('#//define\(\'CAKE_CORE_INCLUDE_PATH#', $contents);
-
-		$contents = file_get_contents($path . DS . 'webroot/test.php');
+		$contents = file_get_contents($path . DS . 'Config/paths.php');
 		$this->assertRegExp('#//define\(\'CAKE_CORE_INCLUDE_PATH#', $contents);
 
 		ini_set('include_path', $restore);
@@ -253,14 +248,14 @@ class ProjectTaskTest extends TestCase {
 		$result = $this->Task->cachePrefix($path);
 		$this->assertTrue($result);
 
-		$File = new File($path . 'Config/core.php');
+		$File = new File($path . 'Config/cache.php');
 		$contents = $File->read();
 		$this->assertRegExp('/\$prefix = \'.+\';/', $contents, '$prefix is not defined');
 		$this->assertNotRegExp('/\$prefix = \'myapp_\';/', $contents, 'Default cache prefix left behind. %s');
 	}
 
 /**
- * Test that index.php is generated correctly.
+ * Test that Config/paths.php is generated correctly.
  *
  * @return void
  */
@@ -270,10 +265,7 @@ class ProjectTaskTest extends TestCase {
 		$path = $this->Task->path . 'bake_test_app/';
 		$this->Task->corePath($path);
 
-		$File = new File($path . 'webroot/index.php');
-		$contents = $File->read();
-		$this->assertNotRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
-		$File = new File($path . 'webroot/test.php');
+		$File = new File($path . 'Config/paths.php');
 		$contents = $File->read();
 		$this->assertNotRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
 	}
@@ -296,7 +288,7 @@ class ProjectTaskTest extends TestCase {
 		$result = $this->Task->getPrefix();
 		$this->assertEquals('super_duper_admin_', $result);
 
-		$File = new File($this->Task->configPath . 'core.php');
+		$File = new File($this->Task->configPath . 'routes.php');
 		$File->delete();
 	}
 
@@ -359,21 +351,4 @@ class ProjectTaskTest extends TestCase {
 		$this->assertTrue(is_dir($path . DS . 'Test/TestCase'), 'No cases dir');
 		$this->assertTrue(is_dir($path . DS . 'Test/Fixture'), 'No fixtures dir');
 	}
-
-/**
- * test console path
- *
- * @return void
- */
-	public function testConsolePath() {
-		$this->_setupTestProject();
-
-		$path = $this->Task->path . 'bake_test_app/';
-		$result = $this->Task->consolePath($path);
-		$this->assertTrue($result);
-
-		$File = new File($path . 'Console/cake.php');
-		$contents = $File->read();
-		$this->assertNotRegExp('/__CAKE_PATH__/', $contents, 'Console path placeholder left behind.');
-	}
 }