mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-01 17:12:39 +00:00
Reformatting tests, and fixing trailing whitespace.
Adding doc comments for new form helper tests.
This commit is contained in:
parent
6123ed47c4
commit
dac26d92bc
2 changed files with 74 additions and 66 deletions
|
@ -438,7 +438,7 @@ class HelperTest extends CakeTestCase {
|
|||
Configure::write('debug', 0);
|
||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
|
||||
$this->assertPattern('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
|
||||
|
||||
|
||||
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css?someparam');
|
||||
$this->assertEqual($result, CSS_URL . 'cake.generic.css?someparam');
|
||||
|
||||
|
@ -592,65 +592,63 @@ class HelperTest extends CakeTestCase {
|
|||
$result = $this->Helper->clean('<script>alert(document.cookie)</script>');
|
||||
$this->assertEqual($result, '&lt;script&gt;alert(document.cookie)&lt;/script&gt;');
|
||||
}
|
||||
|
||||
/**
|
||||
* testMultiDimensionalField method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testMultiDimensionalField() {
|
||||
// PHP4 reference hack
|
||||
ClassRegistry::removeObject('view');
|
||||
ClassRegistry::addObject('view', $this->View);
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost', true);
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.2.HelperTestComment.1.title');
|
||||
$this->assertEqual($this->View->model, 'HelperTestPost');
|
||||
$this->assertEqual($this->View->association, 'HelperTestComment');
|
||||
$this->assertEqual($this->View->modelId,2);
|
||||
$this->assertEqual($this->View->field, 'title');
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.1.HelperTestComment.1.HelperTestTag.1.created');
|
||||
$this->assertEqual($this->View->field,'created');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->modelId,1);
|
||||
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.0.HelperTestComment.1.HelperTestTag.1.fake');
|
||||
$this->assertEqual($this->View->model,'HelperTestPost');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->field,null);
|
||||
|
||||
$this->Helper->setEntity('1.HelperTestComment.1.HelperTestTag.created.year');
|
||||
$this->assertEqual($this->View->model,'HelperTestPost');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->field,'created');
|
||||
$this->assertEqual($this->View->modelId,1);
|
||||
$this->assertEqual($this->View->fieldSuffix,'year');
|
||||
|
||||
$this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['title'] = 'My Title';
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
|
||||
$this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['created']['year'] = 2008;
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year');
|
||||
$this->assertEqual($result,2008);
|
||||
|
||||
$this->Helper->data[2]['HelperTestComment'][1]['created']['year'] = 2008;
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year');
|
||||
$this->assertEqual($result,2008);
|
||||
|
||||
$this->Helper->data['HelperTestPost']['title'] = 'My Title';
|
||||
$result = $this->Helper->value('title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
|
||||
$this->Helper->data['My']['title'] = 'My Title';
|
||||
$result = $this->Helper->value('My.title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testMultiDimensionalField method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testMultiDimensionalField() {
|
||||
// PHP4 reference hack
|
||||
ClassRegistry::removeObject('view');
|
||||
ClassRegistry::addObject('view', $this->View);
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost', true);
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.2.HelperTestComment.1.title');
|
||||
$this->assertEqual($this->View->model, 'HelperTestPost');
|
||||
$this->assertEqual($this->View->association, 'HelperTestComment');
|
||||
$this->assertEqual($this->View->modelId,2);
|
||||
$this->assertEqual($this->View->field, 'title');
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.1.HelperTestComment.1.HelperTestTag.1.created');
|
||||
$this->assertEqual($this->View->field,'created');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->modelId,1);
|
||||
|
||||
$this->Helper->setEntity('HelperTestPost.0.HelperTestComment.1.HelperTestTag.1.fake');
|
||||
$this->assertEqual($this->View->model,'HelperTestPost');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->field,null);
|
||||
|
||||
$this->Helper->setEntity('1.HelperTestComment.1.HelperTestTag.created.year');
|
||||
$this->assertEqual($this->View->model,'HelperTestPost');
|
||||
$this->assertEqual($this->View->association,'HelperTestTag');
|
||||
$this->assertEqual($this->View->field,'created');
|
||||
$this->assertEqual($this->View->modelId,1);
|
||||
$this->assertEqual($this->View->fieldSuffix,'year');
|
||||
|
||||
$this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['title'] = 'My Title';
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
|
||||
$this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['created']['year'] = 2008;
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year');
|
||||
$this->assertEqual($result,2008);
|
||||
|
||||
$this->Helper->data[2]['HelperTestComment'][1]['created']['year'] = 2008;
|
||||
$result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year');
|
||||
$this->assertEqual($result,2008);
|
||||
|
||||
$this->Helper->data['HelperTestPost']['title'] = 'My Title';
|
||||
$result = $this->Helper->value('title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
|
||||
$this->Helper->data['My']['title'] = 'My Title';
|
||||
$result = $this->Helper->value('My.title');
|
||||
$this->assertEqual($result,'My Title');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -709,7 +709,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
unset($this->Form->Html, $this->Form, $this->Controller, $this->View);
|
||||
Configure::write('Security.salt', $this->oldSalt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -5478,6 +5478,11 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the generation of fields for a multi record form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMultiRecordForm() {
|
||||
$this->Form->create('ValidateProfile');
|
||||
$this->Form->data['ValidateProfile'][1]['ValidateItem'][2]['name'] = 'Value';
|
||||
|
@ -5498,7 +5503,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Form->input('ValidateProfile.1.ValidateItem.2.created',array('empty' => true));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input date'),
|
||||
|
@ -5532,7 +5537,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Form->validationErrors['ValidateProfile'][1]['ValidateItem'][2]['profile_id'] = 'Error';
|
||||
$this->Form->data['ValidateProfile'][1]['ValidateItem'][2]['profile_id'] = '1';
|
||||
$result = $this->Form->input('ValidateProfile.1.ValidateItem.2.profile_id');
|
||||
|
@ -5555,17 +5560,22 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected,true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test the correct display of multi-record form validation errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMultiRecordFormValidationErrors() {
|
||||
$this->Form->create('ValidateProfile');
|
||||
$this->Form->validationErrors['ValidateProfile'][2]['ValidateItem'][1]['name'] = 'Error in field name';
|
||||
$result = $this->Form->error('ValidateProfile.2.ValidateItem.1.name');
|
||||
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field name', '/div'));
|
||||
|
||||
|
||||
$this->Form->validationErrors['ValidateProfile'][2]['city'] = 'Error in field city';
|
||||
$result = $this->Form->error('ValidateProfile.2.city');
|
||||
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field city', '/div'));
|
||||
|
||||
|
||||
$result = $this->Form->error('2.city');
|
||||
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field city', '/div'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue