mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Even more tests passing now, almost there
This commit is contained in:
parent
66a568be89
commit
deedd7a3ce
3 changed files with 8 additions and 33 deletions
|
@ -204,7 +204,7 @@ class CakeField {
|
|||
}
|
||||
$message = $rule->message;
|
||||
|
||||
if ($message !== null && !is_string($message)) {
|
||||
if ($message !== null) {
|
||||
$args = null;
|
||||
if (is_array($message)) {
|
||||
$result = $message[0];
|
||||
|
@ -220,6 +220,7 @@ class CakeField {
|
|||
$args[$k] = __d($this->_validationDomain, $arg);
|
||||
}
|
||||
}
|
||||
|
||||
$message = __d($this->_validationDomain, $result, $args);
|
||||
} elseif (is_string($name)) {
|
||||
if (is_array($rule->rule)) {
|
||||
|
|
|
@ -231,8 +231,12 @@ class CakeRule {
|
|||
* @return array
|
||||
*/
|
||||
public function getPropertiesArray() {
|
||||
$rule = $this->rule;
|
||||
if (!is_string($rule)) {
|
||||
unset($rule[0]);
|
||||
}
|
||||
return array(
|
||||
'rule' => $this->rule,
|
||||
'rule' => $rule,
|
||||
'required' => $this->required,
|
||||
'allowEmpty' => $this->allowEmpty,
|
||||
'on' => $this->on,
|
||||
|
@ -318,8 +322,7 @@ class CakeRule {
|
|||
protected function _parseRule(&$data) {
|
||||
if (is_array($this->rule)) {
|
||||
$this->_rule = $this->rule[0];
|
||||
unset($this->rule[0]);
|
||||
$this->_ruleParams = array_merge(array($data[$this->_field]), array_values($this->rule));
|
||||
$this->_ruleParams = array_merge(array($data[$this->_field]), array_values(array_slice($this->rule, 1)));
|
||||
} else {
|
||||
$this->_rule = $this->rule;
|
||||
$this->_ruleParams = array($data[$this->_field]);
|
||||
|
|
|
@ -671,7 +671,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertTrue($result);
|
||||
$result = $Author->validateAssociated($data);
|
||||
$this->assertTrue($result);
|
||||
$result = $Author->validator()->validateAssociated($data);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$Author->create();
|
||||
|
@ -727,8 +726,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
);
|
||||
$TestModel->invalidFields(array('fieldList' => array('title')));
|
||||
$this->assertEquals(array(), $TestModel->validationErrors);
|
||||
$TestModel->validator()->invalidFields(array('fieldList' => array('title')));
|
||||
$this->assertEquals(array(), $TestModel->validator()->validationErrors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -762,10 +759,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$TestModel->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validationErrors);
|
||||
|
||||
$TestModel->validator()->validationErrors = array();
|
||||
$TestModel->validator()->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validator()->validationErrors);
|
||||
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$expected = array(
|
||||
'title' => array(
|
||||
|
@ -775,10 +768,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
);
|
||||
$TestModel->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validationErrors);
|
||||
|
||||
$TestModel->validator()->validationErrors = array();
|
||||
$TestModel->validator()->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validator()->validationErrors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -814,10 +803,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$TestModel->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validationErrors);
|
||||
|
||||
$TestModel->validator()->validationErrors = array();
|
||||
$TestModel->validator()->invalidFields();
|
||||
$this->assertEquals($expected, $TestModel->validator()->validationErrors);
|
||||
|
||||
$TestModel->validationDomain = 'default';
|
||||
Configure::write('Config.language', $lang);
|
||||
App::build();
|
||||
|
@ -851,13 +836,11 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$Article->create($data);
|
||||
$this->assertFalse($Article->validates());
|
||||
$this->assertFalse($Article->validator()->validates());
|
||||
|
||||
$Article->save(null, array('validate' => false));
|
||||
$data['Article']['id'] = $Article->id;
|
||||
$Article->set($data);
|
||||
$this->assertTrue($Article->validates());
|
||||
$this->assertTrue($Article->validator()->validates());
|
||||
|
||||
unset($data['Article']['id']);
|
||||
$Article->validate = array(
|
||||
|
@ -871,13 +854,11 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$Article->create($data);
|
||||
$this->assertTrue($Article->validates());
|
||||
$this->assertTrue($Article->validator()->validates());
|
||||
|
||||
$Article->save(null, array('validate' => false));
|
||||
$data['Article']['id'] = $Article->id;
|
||||
$Article->set($data);
|
||||
$this->assertFalse($Article->validates());
|
||||
$this->assertFalse($Article->validator()->validates());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -908,13 +889,11 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$Article->create($data);
|
||||
$this->assertFalse($Article->validates());
|
||||
$this->assertFalse($Article->validator()->validates());
|
||||
|
||||
$Article->save(null, array('validate' => false));
|
||||
$data['Article']['id'] = $Article->id;
|
||||
$Article->set($data);
|
||||
$this->assertTrue($Article->validates());
|
||||
$this->assertTrue($Article->validator()->validates());
|
||||
|
||||
unset($data['Article']['id']);
|
||||
$Article->validate = array(
|
||||
|
@ -928,13 +907,11 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$Article->create($data);
|
||||
$this->assertTrue($Article->validates());
|
||||
$this->assertTrue($Article->validator()->validates());
|
||||
|
||||
$Article->save(null, array('validate' => false));
|
||||
$data['Article']['id'] = $Article->id;
|
||||
$Article->set($data);
|
||||
$this->assertFalse($Article->validates());
|
||||
$this->assertFalse($Article->validator()->validates());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1086,8 +1063,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertTrue($result);
|
||||
$result = $TestModel->validateAssociated($data, array('deep' => true));
|
||||
$this->assertTrue($result);
|
||||
$result = $TestModel->validator()->validateAssociated($data, array('deep' => true));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$data = array(
|
||||
'Article' => array('id' => 2),
|
||||
|
@ -1100,8 +1075,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertFalse($result);
|
||||
$result = $TestModel->validateAssociated($data, array('deep' => true));
|
||||
$this->assertFalse($result);
|
||||
$result = $TestModel->validator()->validateAssociated($data, array('deep' => true));
|
||||
$this->assertFalse($result);
|
||||
|
||||
$data = array(
|
||||
'Article' => array('id' => 2),
|
||||
|
@ -1121,8 +1094,6 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertSame($expected, $result);
|
||||
$result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => true));
|
||||
$this->assertSame($expected, $result);
|
||||
$result = $TestModel->validator()->validateAssociated($data, array('atomic' => false, 'deep' => true));
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
$data = array(
|
||||
'Article' => array('id' => 2),
|
||||
|
|
Loading…
Add table
Reference in a new issue