mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-08 20:42:42 +00:00
Merge branch '1.3' into merger
Conflicts: cake/libs/controller/components/security.php cake/libs/view/pages/home.ctp cake/libs/view/view.php lib/Cake/Cache/Engine/FileEngine.php lib/Cake/Config/config.php lib/Cake/Model/Datasource/Database/Postgres.php lib/Cake/Test/Case/Utility/SanitizeTest.php lib/Cake/Test/Case/Utility/SetTest.php lib/Cake/Test/Case/View/Helper/CacheHelperTest.php lib/Cake/Test/Case/View/Helper/FormHelperTest.php lib/Cake/VERSION.txt lib/Cake/View/Helper/CacheHelper.php
This commit is contained in:
commit
d93c8cb200
13 changed files with 147 additions and 34 deletions
|
@ -453,6 +453,25 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
$this->assertTrue($this->Controller->Security->validatePost($this->Controller));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that validatePost fails if you are missing the session information.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testValidatePostNoSession() {
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$this->Controller->Session->delete('_Token');
|
||||
|
||||
$key = $this->Controller->params['_Token']['key'];
|
||||
$fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid';
|
||||
|
||||
$this->Controller->data = array(
|
||||
'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'),
|
||||
'_Token' => compact('key', 'fields')
|
||||
);
|
||||
$this->assertFalse($this->Controller->Security->validatePost($this->Controller));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that validatePost fails if any of its required fields are missing.
|
||||
*
|
||||
|
|
|
@ -254,7 +254,12 @@ class SanitizeTest extends CakeTestCase {
|
|||
$string = "This sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be \t \n trimmed.";
|
||||
$expected = "This sentence has lots of whitespace that needs to be trimmed.";
|
||||
$result = Sanitize::stripWhitespace($string);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'I love ßá†ö√ letters.';
|
||||
$result = Sanitize::stripWhitespace($text);
|
||||
$expected = 'I love ßá†ö√ letters.';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -956,7 +956,7 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$result = Set::extract('/ParentNode/name', $hasMany);
|
||||
$expected = array('Second');
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$data = array(
|
||||
array(
|
||||
|
@ -990,7 +990,7 @@ class SetTest extends CakeTestCase {
|
|||
)
|
||||
);
|
||||
$result = Set::extract('/Category[id=1]/..', $data);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$data = array(
|
||||
array(
|
||||
|
@ -1008,7 +1008,7 @@ class SetTest extends CakeTestCase {
|
|||
'Item 2'
|
||||
);
|
||||
$result = Set::extract('/0/name', $data);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$data = array(
|
||||
array('A1', 'B1'),
|
||||
|
@ -1016,7 +1016,7 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$expected = array('A1', 'A2');
|
||||
$result = Set::extract('/0', $data);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -325,6 +325,37 @@ class CacheHelperTest extends CakeTestCase {
|
|||
|
||||
@unlink($filename);
|
||||
}
|
||||
|
||||
function testCacheCallbacks() {
|
||||
$this->Controller->cache_parsing();
|
||||
$this->Controller->params = array(
|
||||
'controller' => 'cache_test',
|
||||
'action' => 'cache_parsing',
|
||||
'url' => array(),
|
||||
'pass' => array(),
|
||||
'named' => array()
|
||||
);
|
||||
$this->Controller->cacheAction = array(
|
||||
'cache_parsing' => array(
|
||||
'duration' => 21600,
|
||||
'callbacks' => true
|
||||
)
|
||||
);
|
||||
$this->Controller->here = '/cacheTest/cache_parsing';
|
||||
$this->Controller->action = 'cache_parsing';
|
||||
|
||||
$View = new View($this->Controller);
|
||||
$result = $View->render('index');
|
||||
|
||||
$filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php';
|
||||
$this->assertTrue(file_exists($filename));
|
||||
|
||||
$contents = file_get_contents($filename);
|
||||
|
||||
$this->assertPattern('/\$controller->startupProcess\(\);/', $contents);
|
||||
|
||||
@unlink($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* test cacheAction set to a boolean
|
||||
|
@ -559,11 +590,17 @@ class CacheHelperTest extends CakeTestCase {
|
|||
* This test must be uncommented/fixed in next release (1.2+)
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*
|
||||
public function testCacheEmptySections () {
|
||||
*/
|
||||
public function testCacheEmptySections() {
|
||||
$this->Controller->cache_parsing();
|
||||
$this->Controller->cacheAction = array('cacheTest' => 21600);
|
||||
$this->Controller->params = array(
|
||||
'controller' => 'cacheTest',
|
||||
'action' => 'cache_empty_sections',
|
||||
'url' => array(),
|
||||
'pass' => array(),
|
||||
'named' => array()
|
||||
);
|
||||
$this->Controller->cacheAction = array('cache_empty_sections' => 21600);
|
||||
$this->Controller->here = '/cacheTest/cache_empty_sections';
|
||||
$this->Controller->action = 'cache_empty_sections';
|
||||
$this->Controller->layout = 'cache_empty_sections';
|
||||
|
@ -571,7 +608,7 @@ class CacheHelperTest extends CakeTestCase {
|
|||
|
||||
$View = new View($this->Controller);
|
||||
$result = $View->render('cache_empty_sections');
|
||||
$this->assertNoPattern('/cake:nocache/', $result);
|
||||
$this->assertNoPattern('/nocache/', $result);
|
||||
$this->assertNoPattern('/php echo/', $result);
|
||||
$this->assertPattern(
|
||||
'@</title>\s*</head>\s*' .
|
||||
|
@ -583,19 +620,18 @@ class CacheHelperTest extends CakeTestCase {
|
|||
$filename = CACHE . 'views' . DS . 'cachetest_cache_empty_sections.php';
|
||||
$this->assertTrue(file_exists($filename));
|
||||
$contents = file_get_contents($filename);
|
||||
$this->assertNoPattern('/cake:nocache/', $contents);
|
||||
$this->assertNoPattern('/nocache/', $contents);
|
||||
$this->assertPattern(
|
||||
'@<head>\s*<title>Posts</title>\s*' .
|
||||
"<\?php \$x = 1; \?>\s*" .
|
||||
'<\?php \$x \= 1; \?>\s*' .
|
||||
'</head>\s*' .
|
||||
'<body>\s*' .
|
||||
"<\?php \$x\+\+; \?>\s*" .
|
||||
"<\?php \$x\+\+; \?>\s*" .
|
||||
'<\?php \$x\+\+; \?>\s*' .
|
||||
'<\?php \$x\+\+; \?>\s*' .
|
||||
'View Content\s*' .
|
||||
"<\?php \$y = 1; \?>\s*" .
|
||||
"<\?php echo 'cached count is:' . \$x; \?>\s*" .
|
||||
'<\?php \$y = 1; \?>\s*' .
|
||||
'<\?php echo \'cached count is: \' . \$x; \?>\s*' .
|
||||
'@', $contents);
|
||||
@unlink($filename);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -4720,13 +4720,14 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$selected = strtotime('2008-10-26 10:33:00');
|
||||
$selected = strtotime('2008-10-26 12:33:00');
|
||||
$result = $this->Form->dateTime('Model.field', 'DMY', '12', array('value' => $selected));
|
||||
$this->assertPattern('/<option[^<>]+value="2008"[^<>]+selected="selected"[^>]*>2008<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="10"[^<>]+selected="selected"[^>]*>10<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="10"[^<>]+selected="selected"[^>]*>October<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="26"[^<>]+selected="selected"[^>]*>26<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="10"[^<>]+selected="selected"[^>]*>10<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="12"[^<>]+selected="selected"[^>]*>12<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="33"[^<>]+selected="selected"[^>]*>33<\/option>/', $result);
|
||||
$this->assertPattern('/<option[^<>]+value="pm"[^<>]+selected="selected"[^>]*>pm<\/option>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->input('published');
|
||||
|
|
|
@ -611,6 +611,12 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->script('http://example.com/test.json');
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'src' => 'http://example.com/test.json.js')
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->script('/plugin/js/jquery-1.3.2.js?someparam=foo');
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue