2009-06-17 02:34:16 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ProjectTask Test file
|
|
|
|
*
|
|
|
|
* Test Case for project generation shell task
|
|
|
|
*
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2009-06-17 02:34:16 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2009-06-17 02:34:16 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-06-17 02:34:16 +00:00
|
|
|
* @since CakePHP v 1.3.0
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2009-06-17 02:34:16 +00:00
|
|
|
*/
|
|
|
|
|
2010-12-09 03:45:18 +00:00
|
|
|
App::uses('ShellDispatcher', 'Console');
|
2011-03-07 05:55:05 +00:00
|
|
|
App::uses('ConsoleOutput', 'Console');
|
|
|
|
App::uses('ConsoleInput', 'Console');
|
2010-12-09 03:45:18 +00:00
|
|
|
App::uses('Shell', 'Console');
|
2011-03-07 05:55:05 +00:00
|
|
|
App::uses('ProjectTask', 'Console/Command/Task');
|
|
|
|
App::uses('Folder', 'Utility');
|
2010-12-09 05:13:11 +00:00
|
|
|
App::uses('File', 'Utility');
|
2009-06-17 02:34:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ProjectTask Test class
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-06-17 02:34:16 +00:00
|
|
|
*/
|
|
|
|
class ProjectTaskTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-06-17 02:34:16 +00:00
|
|
|
/**
|
2011-12-04 21:27:51 +00:00
|
|
|
* setUp method
|
2009-06-17 02:34:16 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2022-12-28 07:03:39 +00:00
|
|
|
public function setUp() : void {
|
2010-09-26 01:36:49 +00:00
|
|
|
parent::setUp();
|
2010-10-07 02:52:42 +00:00
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
2011-04-17 10:35:21 +00:00
|
|
|
|
|
|
|
$this->Task = $this->getMock('ProjectTask',
|
2010-06-10 04:59:19 +00:00
|
|
|
array('in', 'err', 'createFile', '_stop'),
|
2010-10-24 19:27:04 +00:00
|
|
|
array($out, $out, $in)
|
2010-06-10 04:59:19 +00:00
|
|
|
);
|
2009-06-17 03:05:48 +00:00
|
|
|
$this->Task->path = TMP . 'tests' . DS;
|
2009-06-17 02:34:16 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-06-17 02:34:16 +00:00
|
|
|
/**
|
2011-12-04 21:27:51 +00:00
|
|
|
* tearDown method
|
2009-06-17 02:34:16 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2022-12-28 07:03:39 +00:00
|
|
|
public function tearDown() : void {
|
2010-09-26 01:36:49 +00:00
|
|
|
parent::tearDown();
|
2009-06-30 22:30:39 +00:00
|
|
|
|
2010-06-10 04:59:19 +00:00
|
|
|
$Folder = new Folder($this->Task->path . 'bake_test_app');
|
2009-06-30 22:30:39 +00:00
|
|
|
$Folder->delete();
|
2010-10-24 19:27:04 +00:00
|
|
|
unset($this->Task);
|
2009-06-17 02:34:16 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-06-17 03:05:48 +00:00
|
|
|
/**
|
2009-07-01 00:44:09 +00:00
|
|
|
* creates a test project that is used for testing project task.
|
2009-06-17 03:05:48 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:21:28 +00:00
|
|
|
protected function _setupTestProject() {
|
2011-05-31 03:03:49 +00:00
|
|
|
$skel = CAKE . 'Console' . DS . 'Templates' . DS . 'skel';
|
2010-06-10 04:59:19 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
2009-06-17 03:05:48 +00:00
|
|
|
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
|
2009-07-01 00:44:09 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-07-01 00:44:09 +00:00
|
|
|
/**
|
|
|
|
* test bake() method and directory creation.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testBake() {
|
2009-07-01 00:44:09 +00:00
|
|
|
$this->_setupTestProject();
|
2009-06-17 03:05:48 +00:00
|
|
|
$path = $this->Task->path . 'bake_test_app';
|
2010-10-17 23:01:44 +00:00
|
|
|
|
2009-06-17 03:05:48 +00:00
|
|
|
$this->assertTrue(is_dir($path), 'No project dir %s');
|
2010-10-17 23:01:44 +00:00
|
|
|
$dirs = array(
|
2011-05-13 08:06:45 +00:00
|
|
|
'Config',
|
2011-05-15 04:10:09 +00:00
|
|
|
'Config' . DS . 'Schema',
|
2011-04-12 02:45:51 +00:00
|
|
|
'Console',
|
|
|
|
'Console' . DS . 'Command',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Console' . DS . 'Templates',
|
2011-04-12 02:45:51 +00:00
|
|
|
'Console' . DS . 'Command' . DS . 'Task',
|
2011-04-17 10:35:21 +00:00
|
|
|
'Controller',
|
2012-03-11 04:32:02 +00:00
|
|
|
'Controller' . DS . 'Component',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Locale',
|
2011-04-17 10:35:21 +00:00
|
|
|
'Model',
|
2012-03-11 04:32:02 +00:00
|
|
|
'Model' . DS . 'Behavior',
|
|
|
|
'Model' . DS . 'Datasource',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Plugin',
|
2011-05-15 04:10:09 +00:00
|
|
|
'Test',
|
2011-04-17 10:35:21 +00:00
|
|
|
'Test' . DS . 'Case',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Test' . DS . 'Case' . DS . 'Controller',
|
|
|
|
'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component',
|
2011-05-15 04:10:09 +00:00
|
|
|
'Test' . DS . 'Case' . DS . 'Model',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior',
|
2011-05-15 04:10:09 +00:00
|
|
|
'Test' . DS . 'Fixture',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Vendor',
|
|
|
|
'View',
|
|
|
|
'View' . DS . 'Helper',
|
2010-10-17 23:01:44 +00:00
|
|
|
'tmp',
|
2012-02-07 17:51:04 +00:00
|
|
|
'tmp' . DS . 'cache',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'models',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'persistent',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'views',
|
|
|
|
'tmp' . DS . 'logs',
|
|
|
|
'tmp' . DS . 'sessions',
|
|
|
|
'tmp' . DS . 'tests',
|
2010-10-17 23:01:44 +00:00
|
|
|
'webroot',
|
|
|
|
'webroot' . DS . 'css',
|
2012-02-07 17:51:04 +00:00
|
|
|
'webroot' . DS . 'files',
|
|
|
|
'webroot' . DS . 'img',
|
|
|
|
'webroot' . DS . 'js',
|
2012-02-15 20:52:20 +00:00
|
|
|
|
2010-10-17 23:01:44 +00:00
|
|
|
);
|
|
|
|
foreach ($dirs as $dir) {
|
|
|
|
$this->assertTrue(is_dir($path . DS . $dir), 'Missing ' . $dir);
|
|
|
|
}
|
2009-06-17 03:05:48 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2011-05-22 12:49:51 +00:00
|
|
|
/**
|
|
|
|
* test bake with an absolute path.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testExecuteWithAbsolutePath() {
|
2011-07-13 21:54:24 +00:00
|
|
|
$path = $this->Task->args[0] = TMP . 'tests' . DS . 'bake_test_app';
|
2011-05-31 03:03:49 +00:00
|
|
|
$this->Task->params['skel'] = CAKE . 'Console' . DS . 'Templates' . DS . 'skel';
|
2011-05-22 12:49:51 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
|
|
|
$this->Task->execute();
|
|
|
|
|
|
|
|
$this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
|
2012-03-11 04:32:02 +00:00
|
|
|
$File = new File($path . DS . 'webroot' . DS . 'index.php');
|
2011-10-20 23:10:09 +00:00
|
|
|
$contents = $File->read();
|
2011-07-31 19:15:43 +00:00
|
|
|
$this->assertRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', .*?DS/', $contents);
|
2012-03-11 04:32:02 +00:00
|
|
|
$File = new File($path . DS . 'webroot' . DS . 'test.php');
|
2011-10-20 23:10:09 +00:00
|
|
|
$contents = $File->read();
|
2011-07-31 19:15:43 +00:00
|
|
|
$this->assertRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', .*?DS/', $contents);
|
2011-07-13 21:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-22 22:48:15 +00:00
|
|
|
* test bake with CakePHP on the include path. The constants should remain commented out.
|
2011-07-13 21:54:24 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-07-31 19:15:03 +00:00
|
|
|
public function testExecuteWithCakeOnIncludePath() {
|
|
|
|
if (!function_exists('ini_set')) {
|
|
|
|
$this->markTestAsSkipped('Not access to ini_set, cannot proceed.');
|
|
|
|
}
|
|
|
|
$restore = ini_get('include_path');
|
|
|
|
ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . $restore);
|
|
|
|
|
2011-07-13 21:54:24 +00:00
|
|
|
$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->execute();
|
|
|
|
|
|
|
|
$this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
|
2012-03-11 04:32:02 +00:00
|
|
|
$contents = file_get_contents($path . DS . 'webroot' . DS . 'index.php');
|
2011-07-31 19:15:03 +00:00
|
|
|
$this->assertRegExp('#//define\(\'CAKE_CORE_INCLUDE_PATH#', $contents);
|
|
|
|
|
2012-03-11 04:32:02 +00:00
|
|
|
$contents = file_get_contents($path . DS . 'webroot' . DS . 'test.php');
|
2011-07-31 19:15:03 +00:00
|
|
|
$this->assertRegExp('#//define\(\'CAKE_CORE_INCLUDE_PATH#', $contents);
|
|
|
|
|
|
|
|
ini_set('include_path', $restore);
|
2011-05-22 12:49:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 23:04:33 +00:00
|
|
|
/**
|
|
|
|
* test bake() method with -empty flag, directory creation and empty files.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testBakeEmptyFlag() {
|
2009-11-16 23:04:33 +00:00
|
|
|
$this->Task->params['empty'] = true;
|
|
|
|
$this->_setupTestProject();
|
|
|
|
$path = $this->Task->path . 'bake_test_app';
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2010-10-17 23:01:44 +00:00
|
|
|
$empty = array(
|
2011-10-19 14:48:03 +00:00
|
|
|
'Console' . DS . 'Command' . DS . 'Task' => 'empty',
|
|
|
|
'Controller' . DS . 'Component' => 'empty',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Lib' => 'empty',
|
2011-10-19 14:48:03 +00:00
|
|
|
'Model' . DS . 'Behavior' => 'empty',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Model' . DS . 'Datasource' => 'empty',
|
|
|
|
'Plugin' => 'empty',
|
2011-10-19 14:48:03 +00:00
|
|
|
'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior' => 'empty',
|
|
|
|
'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component' => 'empty',
|
|
|
|
'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' => 'empty',
|
|
|
|
'Test' . DS . 'Fixture' => 'empty',
|
2012-02-07 17:51:04 +00:00
|
|
|
'Vendor' => 'empty',
|
|
|
|
'View' . DS . 'Scaffolds' => 'empty',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'models' => 'empty',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'persistent' => 'empty',
|
|
|
|
'tmp' . DS . 'cache' . DS . 'views' => 'empty',
|
|
|
|
'tmp' . DS . 'logs' => 'empty',
|
|
|
|
'tmp' . DS . 'sessions' => 'empty',
|
|
|
|
'tmp' . DS . 'tests' => 'empty',
|
|
|
|
'webroot' . DS . 'js' => 'empty',
|
|
|
|
'webroot' . DS . 'files' => 'empty'
|
2010-10-17 23:01:44 +00:00
|
|
|
);
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2011-10-19 14:48:03 +00:00
|
|
|
foreach ($empty as $dir => $file) {
|
|
|
|
$this->assertTrue(is_file($path . DS . $dir . DS . $file), sprintf('Missing %s file in %s', $file, $dir));
|
2010-10-17 23:01:44 +00:00
|
|
|
}
|
2009-11-16 23:04:33 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* test generation of Security.salt
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testSecuritySaltGeneration() {
|
2009-07-01 00:44:09 +00:00
|
|
|
$this->_setupTestProject();
|
|
|
|
|
2009-06-30 22:30:39 +00:00
|
|
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
|
|
|
$result = $this->Task->securitySalt($path);
|
|
|
|
$this->assertTrue($result);
|
2009-07-01 00:44:09 +00:00
|
|
|
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($path . 'Config' . DS . 'core.php');
|
|
|
|
$contents = $File->read();
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertNotRegExp('/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/', $contents, 'Default Salt left behind. %s');
|
2009-06-30 22:30:39 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-06-10 04:59:19 +00:00
|
|
|
/**
|
|
|
|
* test generation of Security.cipherSeed
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSecurityCipherSeedGeneration() {
|
|
|
|
$this->_setupTestProject();
|
2010-01-25 16:14:18 +00:00
|
|
|
|
2010-06-10 04:59:19 +00:00
|
|
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
|
|
|
$result = $this->Task->securityCipherSeed($path);
|
|
|
|
$this->assertTrue($result);
|
2010-01-25 16:14:18 +00:00
|
|
|
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($path . 'Config' . DS . 'core.php');
|
|
|
|
$contents = $File->read();
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertNotRegExp('/76859309657453542496749683645/', $contents, 'Default CipherSeed left behind. %s');
|
2010-06-10 04:59:19 +00:00
|
|
|
}
|
2010-01-25 16:14:18 +00:00
|
|
|
|
2012-01-23 01:23:42 +00:00
|
|
|
/**
|
|
|
|
* test generation of cache prefix
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCachePrefixGeneration() {
|
|
|
|
$this->_setupTestProject();
|
|
|
|
|
|
|
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
|
|
|
$result = $this->Task->cachePrefix($path);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
|
|
$File = new File($path . 'Config' . DS . 'core.php');
|
|
|
|
$contents = $File->read();
|
|
|
|
$this->assertRegExp('/\$prefix = \'.+\';/', $contents, '$prefix is not defined');
|
|
|
|
$this->assertNotRegExp('/\$prefix = \'myapp_\';/', $contents, 'Default cache prefix left behind. %s');
|
|
|
|
}
|
|
|
|
|
2009-11-10 01:10:24 +00:00
|
|
|
/**
|
|
|
|
* Test that index.php is generated correctly.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testIndexPhpGeneration() {
|
2009-11-10 01:10:24 +00:00
|
|
|
$this->_setupTestProject();
|
2009-11-16 23:04:33 +00:00
|
|
|
|
2009-11-10 01:10:24 +00:00
|
|
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
|
|
|
$this->Task->corePath($path);
|
|
|
|
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($path . 'webroot' . DS . 'index.php');
|
|
|
|
$contents = $File->read();
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertNotRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($path . 'webroot' . DS . 'test.php');
|
|
|
|
$contents = $File->read();
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertNotRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', ROOT/', $contents);
|
2009-11-10 01:10:24 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 00:44:09 +00:00
|
|
|
/**
|
2009-10-07 04:46:13 +00:00
|
|
|
* test getPrefix method, and that it returns Routing.prefix or writes to config file.
|
2009-07-01 00:44:09 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testGetPrefix() {
|
2009-10-07 04:46:13 +00:00
|
|
|
Configure::write('Routing.prefixes', array('admin'));
|
|
|
|
$result = $this->Task->getPrefix();
|
2012-03-23 06:37:12 +00:00
|
|
|
$this->assertEquals('admin_', $result);
|
2009-07-01 00:44:09 +00:00
|
|
|
|
2009-10-07 04:46:13 +00:00
|
|
|
Configure::write('Routing.prefixes', null);
|
2009-07-01 00:44:09 +00:00
|
|
|
$this->_setupTestProject();
|
2011-05-13 08:06:45 +00:00
|
|
|
$this->Task->configPath = $this->Task->path . 'bake_test_app' . DS . 'Config' . DS;
|
2010-06-10 04:59:19 +00:00
|
|
|
$this->Task->expects($this->once())->method('in')->will($this->returnValue('super_duper_admin'));
|
2009-07-01 00:44:09 +00:00
|
|
|
|
2009-10-07 04:46:13 +00:00
|
|
|
$result = $this->Task->getPrefix();
|
2012-03-23 06:37:12 +00:00
|
|
|
$this->assertEquals('super_duper_admin_', $result);
|
2009-10-07 04:46:13 +00:00
|
|
|
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($this->Task->configPath . 'core.php');
|
|
|
|
$File->delete();
|
2009-10-07 04:46:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test cakeAdmin() writing core.php
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testCakeAdmin() {
|
2017-05-12 06:02:36 +00:00
|
|
|
$File = new File(CONFIG . 'core.php');
|
2011-10-20 23:10:09 +00:00
|
|
|
$contents = $File->read();
|
|
|
|
$File = new File(TMP . 'tests' . DS . 'core.php');
|
|
|
|
$File->write($contents);
|
2009-10-07 04:46:13 +00:00
|
|
|
|
|
|
|
Configure::write('Routing.prefixes', null);
|
|
|
|
$this->Task->configPath = TMP . 'tests' . DS;
|
|
|
|
$result = $this->Task->cakeAdmin('my_prefix');
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertEquals(Configure::read('Routing.prefixes'), array('my_prefix'));
|
2011-10-20 23:10:09 +00:00
|
|
|
$File->delete();
|
2009-10-07 04:46:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test getting the prefix with more than one prefix setup
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testGetPrefixWithMultiplePrefixes() {
|
2009-10-07 04:46:13 +00:00
|
|
|
Configure::write('Routing.prefixes', array('admin', 'ninja', 'shinobi'));
|
|
|
|
$this->_setupTestProject();
|
2011-05-13 08:06:45 +00:00
|
|
|
$this->Task->configPath = $this->Task->path . 'bake_test_app' . DS . 'Config' . DS;
|
2010-06-10 04:59:19 +00:00
|
|
|
$this->Task->expects($this->once())->method('in')->will($this->returnValue(2));
|
2009-10-07 04:46:13 +00:00
|
|
|
|
|
|
|
$result = $this->Task->getPrefix();
|
2012-03-23 06:37:12 +00:00
|
|
|
$this->assertEquals('ninja_', $result);
|
2009-07-01 00:44:09 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-07-01 02:23:48 +00:00
|
|
|
/**
|
|
|
|
* Test execute method with one param to destination folder.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function testExecute() {
|
2011-12-16 06:52:07 +00:00
|
|
|
$this->Task->params['skel'] = CAKE . 'Console' . DS . 'Templates' . DS . 'skel';
|
2009-07-01 02:23:48 +00:00
|
|
|
$this->Task->params['working'] = TMP . 'tests' . DS;
|
|
|
|
|
|
|
|
$path = $this->Task->path . 'bake_test_app';
|
2010-06-10 04:59:19 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($path));
|
|
|
|
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
|
2009-07-01 02:23:48 +00:00
|
|
|
|
|
|
|
$this->Task->execute();
|
2010-12-06 04:32:34 +00:00
|
|
|
$this->assertTrue(is_dir($path), 'No project dir');
|
2011-04-12 02:45:51 +00:00
|
|
|
$this->assertTrue(is_dir($path . DS . 'Controller'), 'No controllers dir ');
|
2012-03-11 04:32:02 +00:00
|
|
|
$this->assertTrue(is_dir($path . DS . 'Controller' . DS . 'Component'), 'No components dir ');
|
2011-04-12 02:45:51 +00:00
|
|
|
$this->assertTrue(is_dir($path . DS . 'Model'), 'No models dir');
|
|
|
|
$this->assertTrue(is_dir($path . DS . 'View'), 'No views dir');
|
|
|
|
$this->assertTrue(is_dir($path . DS . 'View' . DS . 'Helper'), 'No helpers dir');
|
2011-05-15 04:10:09 +00:00
|
|
|
$this->assertTrue(is_dir($path . DS . 'Test'), 'No tests dir');
|
|
|
|
$this->assertTrue(is_dir($path . DS . 'Test' . DS . 'Case'), 'No cases dir');
|
|
|
|
$this->assertTrue(is_dir($path . DS . 'Test' . DS . 'Fixture'), 'No fixtures dir');
|
2010-10-18 02:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test console path
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testConsolePath() {
|
2010-10-18 02:38:32 +00:00
|
|
|
$this->_setupTestProject();
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2010-10-18 02:38:32 +00:00
|
|
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
|
|
|
$result = $this->Task->consolePath($path);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
2011-10-20 23:10:09 +00:00
|
|
|
$File = new File($path . 'Console' . DS . 'cake.php');
|
|
|
|
$contents = $File->read();
|
2011-11-16 00:07:56 +00:00
|
|
|
$this->assertNotRegExp('/__CAKE_PATH__/', $contents, 'Console path placeholder left behind.');
|
2009-07-01 02:23:48 +00:00
|
|
|
}
|
2009-06-17 02:34:16 +00:00
|
|
|
}
|