public function testErrors() { $doc = new Document(array('data' => array('title' => 'Post', 'content' => 'Lorem Ipsum', 'parsed' => null, 'permanent' => false))); $errors = array('title' => 'Too short', 'parsed' => 'Empty'); $doc->errors($errors); $expected = $errors; $result = $doc->errors(); $this->assertEqual($expected, $result); $expected = 'Too short'; $result = $doc->errors('title'); $this->assertEqual($expected, $result); $doc->errors('title', 'Too generic'); $expected = 'Too generic'; $result = $doc->errors('title'); $this->assertEqual($expected, $result); }
/** * Tests rendering errors for nested fields. */ public function testNestedFieldError() { $doc = new Document(array('data' => array('foo' => array('bar' => 'value')))); $doc->errors(array('foo.bar' => 'Something bad happened.')); $this->form->create($doc); $result = $this->form->field('foo.bar'); $this->assertTags($result, array(array('div' => array()), 'label' => array('for' => 'FooBar'), 'Foo Bar', '/label', 'input' => array('type' => 'text', 'name' => 'foo[bar]', 'id' => 'FooBar', 'value' => 'value'), 'div' => array('class' => 'error'), 'Something bad happened.', '/div', array('/div' => array()))); }