mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding tests for security salt generation.
This commit is contained in:
parent
8c2a027842
commit
198511f639
2 changed files with 23 additions and 4 deletions
|
@ -61,7 +61,7 @@ class ProjectTask extends Shell {
|
|||
if ($project) {
|
||||
$response = false;
|
||||
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
|
||||
$response = $this->in('A project already exists in this location: '.$project.' Overwrite?', array('y','n'), 'n');
|
||||
$response = $this->in('A project already exists in this location: ' . $project . ' Overwrite?', array('y','n'), 'n');
|
||||
if (strtolower($response) === 'n') {
|
||||
$response = $project = false;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,9 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
*/
|
||||
function endTest() {
|
||||
ClassRegistry::flush();
|
||||
|
||||
$Folder =& new Folder($this->Task->path . 'bake_test_app');
|
||||
$Folder->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,10 +103,26 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
||||
|
||||
$Folder =& new Folder($this->Task->path . 'bake_test_app');
|
||||
$Folder->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* test generation of Security.salt
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testSecuritySaltGeneration() {
|
||||
$skel = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS . 'templates' . DS . 'skel';
|
||||
$this->Task->setReturnValueAt(0, 'in', 'y');
|
||||
$this->Task->setReturnValueAt(1, 'in', 'n');
|
||||
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
|
||||
|
||||
$path = $this->Task->path . 'bake_test_app' . DS;
|
||||
$result = $this->Task->securitySalt($path);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$file =& new File($path . 'config' . DS . 'core.php');
|
||||
$contents = $file->read();
|
||||
$this->assertNoPattern('/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/', $contents, 'Default Salt left behind. %s');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue