Skip to content
Permalink
Browse files

Even more tests passing now, almost there

  • Loading branch information...
lorenzo committed Apr 29, 2012
1 parent 66a568b commit deedd7a3ce55dda1db05f7eb2ba1858a1e6a3635
@@ -204,7 +204,7 @@ protected function _processValidationResponse($rule) {
}
$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 @@ protected function _processValidationResponse($rule) {
$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 @@ public function getValidationResult() {
* @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 @@ protected function _addValidatorProps($validator = array()) {
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 @@ public function testValidatesWithModelsAndSaveAllWithoutId() {
$this->assertTrue($result);
$result = $Author->validateAssociated($data);
$this->assertTrue($result);
$result = $Author->validator()->validateAssociated($data);
$this->assertTrue($result);
$Author->create();
@@ -727,8 +726,6 @@ public function testMissingValidationErrorNoTriggering() {
);
$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 @@ public function testValidationMessageAsArray() {
$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 @@ public function testValidationMessageAsArray() {
);
$TestModel->invalidFields();
$this->assertEquals($expected, $TestModel->validationErrors);
$TestModel->validator()->validationErrors = array();
$TestModel->validator()->invalidFields();
$this->assertEquals($expected, $TestModel->validator()->validationErrors);
}
/**
@@ -814,10 +803,6 @@ public function testValidationMessageTranslation() {
$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 @@ public function testStateValidation() {
$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 @@ public function testStateValidation() {
$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 @@ public function testStateRequiredValidation() {
$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 @@ public function testStateRequiredValidation() {
$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 @@ public function testSaveAllDeepValidateOnly() {
$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 @@ public function testSaveAllDeepValidateOnly() {
$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 @@ public function testSaveAllDeepValidateOnly() {
$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),

0 comments on commit deedd7a

Please sign in to comment.
You can’t perform that action at this time.