Browse Source

Updated test related to displaying errors in nested properties

Jose Lorenzo Rodriguez 12 years ago
parent
commit
cd9e2ca8ad
1 changed files with 18 additions and 0 deletions
  1. 18 0
      tests/TestCase/View/Helper/FormHelperTest.php

+ 18 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -2025,6 +2025,24 @@ class FormHelperTest extends TestCase {
 	}
 
 /**
+ * Tests displaying errors for nested entities
+ *
+ * @return void
+ */
+	public function testFormValidationAssociated() {
+		TableRegistry::get('Contacts', [
+			'className' => __NAMESPACE__ . '\ContactsTable'
+		]);
+		$nested = new Entity(['foo' => 'bar']);
+		$nested->errors('foo', ['not a valid bar']);
+		$entity = new Entity(['nested' => $nested]);
+		$this->Form->create($entity, ['context' => ['table' => 'Contacts']]);
+
+		$result = $this->Form->error('nested.foo');
+		$this->assertEquals('<div class="error-message">not a valid bar</div>', $result);
+	}
+
+/**
  * testFormValidationAssociatedFirstLevel method
  *
  * test form error display with associated model.