mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
updating Helper::setEntity() and form.test
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6464 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
18dc1fd456
commit
fb4244bb89
2 changed files with 32 additions and 7 deletions
|
@ -355,10 +355,11 @@ class Helper extends Overloadable {
|
|||
}
|
||||
}
|
||||
|
||||
if ($parts[0] == $view->field && $view->field != $view->model) {
|
||||
if (!$view->association && $parts[0] == $view->field && $view->field != $view->model) {
|
||||
array_unshift($parts, $model);
|
||||
$hasField = true;
|
||||
}
|
||||
|
||||
$view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
|
||||
|
||||
switch (count($parts)) {
|
||||
|
|
|
@ -59,8 +59,22 @@ class Contact extends CakeTestModel {
|
|||
);
|
||||
return $this->_schema;
|
||||
}
|
||||
}
|
||||
|
||||
var $hasAndBelongsToMany = array('ContactTag' => array());
|
||||
}
|
||||
class ContactTag extends Model {
|
||||
|
||||
var $useTable = false;
|
||||
function schema() {
|
||||
$this->_schema = array(
|
||||
'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'),
|
||||
'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
|
||||
'created' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''),
|
||||
'modified' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null)
|
||||
);
|
||||
return $this->_schema;
|
||||
}
|
||||
}
|
||||
class UserForm extends CakeTestModel {
|
||||
var $useTable = false;
|
||||
var $primaryKey = 'id';
|
||||
|
@ -482,31 +496,37 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertPattern('/<legend>The Legend<\/legend>/', $result);
|
||||
|
||||
$View = ClassRegistry::getObject('view');
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$this->Form->params['prefix'] = 'admin';
|
||||
$this->Form->action = 'admin_edit';
|
||||
$result = $this->Form->inputs();
|
||||
$this->assertPattern('/<legend>Edit Contact<\/legend>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(false);
|
||||
$this->assertNoPattern('/<fieldset[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/<legend>[^<>]*<\/legend>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(array('fieldset' => false, 'legend' => false));
|
||||
$this->assertNoPattern('/<fieldset[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/<legend>[^<>]*<\/legend>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(array('fieldset' => true, 'legend' => false));
|
||||
$this->assertPattern('/<fieldset[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/<legend>[^<>]*<\/legend>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(array('fieldset' => false, 'legend' => 'Hello'));
|
||||
$this->assertNoPattern('/<fieldset[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/<legend>[^<>]*<\/legend>/', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs('Hello');
|
||||
$this->assertPattern('/^<fieldset><legend[^<>]*>Hello<\/legend>.+<\/fieldset>$/s', $result);
|
||||
|
||||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(array('legend' => 'Hello'));
|
||||
$this->assertPattern('/^<fieldset><legend[^<>]*>Hello<\/legend>.+<\/fieldset>$/s', $result);
|
||||
}
|
||||
|
@ -1030,8 +1050,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertPattern('/name="data\[Contact\]\[published2\]\[month\]"/', $result);
|
||||
$this->assertPattern('/name="data\[Contact\]\[published2\]\[day\]"/', $result);
|
||||
$this->assertPattern('/name="data\[Contact\]\[published2\]\[year\]"/', $result);
|
||||
|
||||
$result = $this->Form->input('ContactTag');
|
||||
$this->assertPattern('/name="data\[ContactTag\]\[ContactTag\]\[\]"/', $result);
|
||||
}
|
||||
|
||||
|
||||
function testMonth() {
|
||||
$result = $this->Form->month('Model.field');
|
||||
$this->assertPattern('/^<select[^<>]+name="data\[Model\]\[field\]\[month\]"[^<>]*>/', $result);
|
||||
|
@ -1540,12 +1564,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
function tearDown() {
|
||||
ClassRegistry::removeObject('view');
|
||||
ClassRegistry::removeObject('Contact');
|
||||
ClassRegistry::removeObject('ContactTag');
|
||||
ClassRegistry::removeObject('OpenidUrl');
|
||||
ClassRegistry::removeObject('UserForm');
|
||||
ClassRegistry::removeObject('ValidateItem');
|
||||
ClassRegistry::removeObject('ValidateUser');
|
||||
ClassRegistry::removeObject('ValidateProfile');
|
||||
|
||||
unset($this->Form);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue