mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding option to ProjectTask, for setting CAKE_CORE_INCLUDE_PATH. Tests added.
This commit is contained in:
parent
e3dfec98c7
commit
a025cb2e01
2 changed files with 47 additions and 12 deletions
|
@ -91,14 +91,6 @@ class ProjectTask extends Shell {
|
|||
$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 @@ class ProjectTask extends Shell {
|
|||
$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'));
|
||||
|
|
|
@ -115,12 +115,40 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
* @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 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue