Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding option to ProjectTask, for setting CAKE_CORE_INCLUDE_PATH. Tes…

…ts added.
  • Loading branch information...
commit a025cb2e016973a562f5b7bdc1e975460de34cf1 1 parent e3dfec9
@ceeram ceeram authored
View
24 lib/Cake/Console/Command/Task/ProjectTask.php
@@ -91,14 +91,6 @@ public function execute() {
$success = false;
}
- if ($this->corePath($path) === true) {
- $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', ' * <warning>Remember to check these value after moving to production server</warning>'));
- } else {
- $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php'));
- $success = false;
- }
if ($this->consolePath($path) === true) {
$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
} else {
@@ -106,6 +98,22 @@ public function execute() {
$success = false;
}
+ $this->out(__d('cake_console', 'The value for CAKE_CORE_INCLUDE_PATH can be hardcoded set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
+ $this->out(__d('cake_console', '<warning>If you hard code it, the project will possibly run only in your computer.</warning>'));
+ $setConstants = $this->in(__d('cake_console', 'Do you want to set CAKE_CORE_INCLUDE_PATH in webroot/index.php?'), array('y', 'n'), 'n');
+ if (strtolower($setConstants) === 'y') {
+ if ($this->corePath($path) === true) {
+ $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', ' * <warning>Remember to check these values after moving to production server</warning>'));
+ } else {
+ $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php'));
+ $success = false;
+ }
+ } else {
+ $this->out(__d('cake_console', '<warning>Please make sure your cake core is accessible, if you have problems edit CAKE_CORE_INCLUDE_PATH in webroot/index.php</warning>'));
+ }
+
$Folder = new Folder($path);
if (!$Folder->chmod($path . 'tmp', 0777)) {
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS .'tmp'));
View
35 lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php
@@ -115,12 +115,40 @@ public function testBake() {
* @return void
*/
public function testExecuteWithAbsolutePath() {
- $this->Task->args[0] = TMP . 'tests' . DS . 'bake_test_app';
+ $path = $this->Task->args[0] = TMP . 'tests' . DS . 'bake_test_app';
$this->Task->params['skel'] = CAKE . 'Console' . DS . 'Templates' . DS . 'skel';
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
+ $this->Task->expects($this->at(3))->method('in')->will($this->returnValue('n'));
$this->Task->execute();
$this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
+ $file = new File($path . DS . 'webroot' . DS . 'index.php');
+ $contents = $file->read();
+ $this->assertPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
+ $file = new File($path . DS . 'webroot' . DS . 'test.php');
+ $contents = $file->read();
+ $this->assertPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
+ }
+
+/**
+ * test bake with setting CAKE_CORE_INCLUDE_PATH in webroot/index.php
+ *
+ * @return void
+ */
+ public function testExecuteWithSettingIncludePath() {
+ $path = $this->Task->args[0] = TMP . 'tests' . DS . 'bake_test_app';
+ $this->Task->params['skel'] = CAKE . 'Console' . DS . 'Templates' . DS . 'skel';
+ $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
+ $this->Task->expects($this->at(3))->method('in')->will($this->returnValue('y'));
+ $this->Task->execute();
+
+ $this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
+ $file = new File($path . DS . 'webroot' . DS . 'index.php');
+ $contents = $file->read();
+ $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
+ $file = new File($path . DS . 'webroot' . DS . 'test.php');
+ $contents = $file->read();
+ $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
}
/**
@@ -199,11 +227,10 @@ public function testIndexPhpGeneration() {
$file = new File($path . 'webroot' . DS . 'index.php');
$contents = $file->read();
- $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', \'ROOT/', $contents);
-
+ $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
$file = new File($path . 'webroot' . DS . 'test.php');
$contents = $file->read();
- $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', \'ROOT/', $contents);
+ $this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.