Browse Source

Add additional tests for error triggering on missing validator.

Closes #3039
mark_story 13 years ago
parent
commit
928de97338
1 changed files with 19 additions and 0 deletions
  1. 19 0
      lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php

+ 19 - 0
lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php

@@ -73,6 +73,7 @@ class CakeValidationRuleTest extends CakeTestCase {
 		$Rule->process('fieldName', $data, $methods);
 		$this->assertTrue($Rule->isValid());
 	}
+
 /**
  * tests that passing custom validation methods work
  *
@@ -99,6 +100,24 @@ class CakeValidationRuleTest extends CakeTestCase {
 	}
 
 /**
+ * Make sure errors are triggered when validation is missing.
+ *
+ * @expectedException PHPUnit_Framework_Error_Warning
+ * @expectedExceptionMessage Could not find validation handler totallyMissing for fieldName
+ * @return void
+ */
+	public function testCustomMethodMissingError() {
+		$def = array('rule' => array('totallyMissing'));
+		$data = array(
+			'fieldName' => 'some data'
+		);
+		$methods = array('mytestrule' => array($this, 'myTestRule'));
+
+		$Rule = new CakeValidationRule($def);
+		$Rule->process('fieldName', $data, $methods);
+	}
+
+/**
  * Test isRequired method
  *
  * @return void