mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing label tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4906 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
aee7405863
commit
70b9de6903
1 changed files with 29 additions and 29 deletions
|
@ -122,7 +122,7 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -147,13 +147,13 @@
|
||||||
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeValidate() {
|
function beforeValidate() {
|
||||||
$this->invalidate('email');
|
$this->invalidate('email');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -183,14 +183,14 @@
|
||||||
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeValidate() {
|
function beforeValidate() {
|
||||||
$this->invalidate('full_name');
|
$this->invalidate('full_name');
|
||||||
$this->invalidate('city');
|
$this->invalidate('city');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -216,7 +216,7 @@
|
||||||
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeValidate() {
|
function beforeValidate() {
|
||||||
$this->invalidate('description');
|
$this->invalidate('description');
|
||||||
return false;
|
return false;
|
||||||
|
@ -239,7 +239,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
ClassRegistry::addObject('view', $view);
|
ClassRegistry::addObject('view', $view);
|
||||||
ClassRegistry::addObject('Contact', new Contact());
|
ClassRegistry::addObject('Contact', new Contact());
|
||||||
}
|
}
|
||||||
|
|
||||||
function endTest($method) {
|
function endTest($method) {
|
||||||
unset($this->Form->Html);
|
unset($this->Form->Html);
|
||||||
unset($this->Form);
|
unset($this->Form);
|
||||||
|
@ -283,11 +283,11 @@ class FormHelperTest extends CakeTestCase {
|
||||||
unset($this->UserForm->OpenidUrl);
|
unset($this->UserForm->OpenidUrl);
|
||||||
unset($this->UserForm);
|
unset($this->UserForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFormValidationAssociatedFirstLevel() {
|
function testFormValidationAssociatedFirstLevel() {
|
||||||
$this->ValidateUser =& new ValidateUser();
|
$this->ValidateUser =& new ValidateUser();
|
||||||
$this->ValidateUser->ValidateProfile =& new ValidateProfile();
|
$this->ValidateUser->ValidateProfile =& new ValidateProfile();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'ValidateUser' => array(
|
'ValidateUser' => array(
|
||||||
'name' => 'mariano'
|
'name' => 'mariano'
|
||||||
|
@ -302,13 +302,13 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->ValidateUser->validates();
|
$result = $this->ValidateUser->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$result = $this->ValidateUser->ValidateProfile->validates();
|
$result = $this->ValidateUser->ValidateProfile->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
|
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
|
||||||
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
|
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'OpenidUrl' => array(
|
'OpenidUrl' => array(
|
||||||
'openid_not_registered' => 1
|
'openid_not_registered' => 1
|
||||||
|
@ -327,12 +327,12 @@ class FormHelperTest extends CakeTestCase {
|
||||||
unset($this->ValidateUser->ValidateProfile);
|
unset($this->ValidateUser->ValidateProfile);
|
||||||
unset($this->ValidateUser);
|
unset($this->ValidateUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFormValidationAssociatedSecondLevel() {
|
function testFormValidationAssociatedSecondLevel() {
|
||||||
$this->ValidateUser =& new ValidateUser();
|
$this->ValidateUser =& new ValidateUser();
|
||||||
$this->ValidateUser->ValidateProfile =& new ValidateProfile();
|
$this->ValidateUser->ValidateProfile =& new ValidateProfile();
|
||||||
$this->ValidateUser->ValidateProfile->ValidateItem =& new ValidateItem();
|
$this->ValidateUser->ValidateProfile->ValidateItem =& new ValidateItem();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'ValidateUser' => array(
|
'ValidateUser' => array(
|
||||||
'name' => 'mariano'
|
'name' => 'mariano'
|
||||||
|
@ -350,16 +350,16 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->ValidateUser->validates();
|
$result = $this->ValidateUser->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$result = $this->ValidateUser->ValidateProfile->validates();
|
$result = $this->ValidateUser->ValidateProfile->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$result = $this->ValidateUser->ValidateProfile->ValidateItem->validates();
|
$result = $this->ValidateUser->ValidateProfile->ValidateItem->validates();
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
|
$result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
|
||||||
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
|
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'OpenidUrl' => array(
|
'OpenidUrl' => array(
|
||||||
'openid_not_registered' => 1
|
'openid_not_registered' => 1
|
||||||
|
@ -377,7 +377,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEqual($this->Form->validationErrors, $expected);
|
$this->assertEqual($this->Form->validationErrors, $expected);
|
||||||
|
|
||||||
unset($this->ValidateUser->ValidateProfile->ValidateItem);
|
unset($this->ValidateUser->ValidateProfile->ValidateItem);
|
||||||
unset($this->ValidateUser->ValidateProfile);
|
unset($this->ValidateUser->ValidateProfile);
|
||||||
unset($this->ValidateUser);
|
unset($this->ValidateUser);
|
||||||
|
@ -397,7 +397,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Form->input('Model/field', array('type' => 'file', 'class' => 'textbox'));
|
$result = $this->Form->input('Model/field', array('type' => 'file', 'class' => 'textbox'));
|
||||||
$this->assertPattern('/class="textbox"/', $result);
|
$this->assertPattern('/class="textbox"/', $result);
|
||||||
|
|
||||||
$this->Form->data = array('Model' => array( 'field' => 'Hello & World > weird chars' ));
|
$this->Form->data = array('Model' => array( 'field' => 'Hello & World > weird chars' ));
|
||||||
$result = $this->Form->input('Model/field');
|
$result = $this->Form->input('Model/field');
|
||||||
$expected = '<div class="input"><label for="ModelField">Field</label><input name="data[Model][field]" type="text" value="Hello & World > weird chars" id="ModelField" /></div>';
|
$expected = '<div class="input"><label for="ModelField">Field</label><input name="data[Model][field]" type="text" value="Hello & World > weird chars" id="ModelField" /></div>';
|
||||||
|
@ -420,19 +420,19 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, '<label for="PersonName">Name</label>');
|
$this->assertEqual($result, '<label for="PersonName">Name</label>');
|
||||||
|
|
||||||
$result = $this->Form->label('first_name');
|
$result = $this->Form->label('first_name');
|
||||||
$this->assertEqual($result, '<label for="first_name">First Name</label>');
|
$this->assertEqual($result, '<label for="PersonFirstName">First Name</label>');
|
||||||
|
|
||||||
$result = $this->Form->label('first_name', 'Your first name');
|
$result = $this->Form->label('first_name', 'Your first name');
|
||||||
$this->assertEqual($result, '<label for="first_name">Your first name</label>');
|
$this->assertEqual($result, '<label for="PersonFirstName">Your first name</label>');
|
||||||
|
|
||||||
$result = $this->Form->label('first_name', 'Your first name', array('class' => 'my-class'));
|
$result = $this->Form->label('first_name', 'Your first name', array('class' => 'my-class'));
|
||||||
$this->assertEqual($result, '<label for="first_name" class="my-class">Your first name</label>');
|
$this->assertEqual($result, '<label for="PersonFirstName" class="my-class">Your first name</label>');
|
||||||
|
|
||||||
$result = $this->Form->label('first_name', 'Your first name', array('class' => 'my-class', 'id' => 'LabelID'));
|
$result = $this->Form->label('first_name', 'Your first name', array('class' => 'my-class', 'id' => 'LabelID'));
|
||||||
$this->assertEqual($result, '<label for="first_name" class="my-class" id="LabelID">Your first name</label>');
|
$this->assertEqual($result, '<label for="PersonFirstName" class="my-class" id="LabelID">Your first name</label>');
|
||||||
|
|
||||||
$result = $this->Form->label('first_name', '');
|
$result = $this->Form->label('first_name', '');
|
||||||
$this->assertEqual($result, '<label for="first_name"></label>');
|
$this->assertEqual($result, '<label for="PersonFirstName"></label>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTextbox() {
|
function testTextbox() {
|
||||||
|
@ -603,10 +603,10 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$result = $this->Form->submit('Test Submit', array('div' => array('id' => 'SaveButton')));
|
$result = $this->Form->submit('Test Submit', array('div' => array('id' => 'SaveButton')));
|
||||||
$this->assertPattern('/^<div[^<>]+id="SaveButton"[^<>]*><input type="submit"[^<>]+value="Test Submit"[^<>]+\/><\/div>$/', $result);
|
$this->assertPattern('/^<div[^<>]+id="SaveButton"[^<>]*><input type="submit"[^<>]+value="Test Submit"[^<>]+\/><\/div>$/', $result);
|
||||||
$this->assertNoPattern('/<input[^<>]+[^type|value]=[^<>]*>/', $result);
|
$this->assertNoPattern('/<input[^<>]+[^type|value]=[^<>]*>/', $result);
|
||||||
|
|
||||||
$result = $this->Form->submit('Next >');
|
$result = $this->Form->submit('Next >');
|
||||||
$this->assertPattern('/^<div\s+class="submit"><input type="submit"[^<>]+value="Next >"[^<>]+\/><\/div>$/', $result);
|
$this->assertPattern('/^<div\s+class="submit"><input type="submit"[^<>]+value="Next >"[^<>]+\/><\/div>$/', $result);
|
||||||
|
|
||||||
$result = $this->Form->submit('Next >', array('escape'=>false));
|
$result = $this->Form->submit('Next >', array('escape'=>false));
|
||||||
$this->assertPattern('/^<div\s+class="submit"><input type="submit"[^<>]+value="Next >"[^<>]+\/><\/div>$/', $result);
|
$this->assertPattern('/^<div\s+class="submit"><input type="submit"[^<>]+value="Next >"[^<>]+\/><\/div>$/', $result);
|
||||||
}
|
}
|
||||||
|
@ -632,7 +632,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertPattern('/^<form[^<>]+id="ContactEditForm"[^<>]+>/', $result);
|
$this->assertPattern('/^<form[^<>]+id="ContactEditForm"[^<>]+>/', $result);
|
||||||
$this->assertPattern('/^<form[^<>]+action="\/contacts\/edit\/1"[^<>]*>/', $result);
|
$this->assertPattern('/^<form[^<>]+action="\/contacts\/edit\/1"[^<>]*>/', $result);
|
||||||
$this->assertNoPattern('/^<form[^<>]+[^id|method|action]=[^<>]*>/', $result);
|
$this->assertNoPattern('/^<form[^<>]+[^id|method|action]=[^<>]*>/', $result);
|
||||||
|
|
||||||
$result = $this->Form->create('Contact', array('id' => 'TestId'));
|
$result = $this->Form->create('Contact', array('id' => 'TestId'));
|
||||||
$this->assertPattern('/id="TestId"/', $result);
|
$this->assertPattern('/id="TestId"/', $result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue