Example #1
0
 /**
  * @depends testGetSetErrors
  */
 public function testHasErrors()
 {
     $form = new Form();
     $this->assertFalse($form->hasErrors());
     $this->assertFalse($form->hasErrors('first_name'));
     $form->setErrors(array('first_name' => array('required')));
     $this->assertTrue($form->hasErrors());
     $this->assertTrue($form->hasErrors('first_name'));
 }
Example #2
0
 public function testErrors()
 {
     $actual = Form::open()->setErrors(array('test' => 'There is a problem'))->text('test')->close();
     $expected = '<form action="" method="post" class="" id="" ><div class="error">There is a problem</div>
         <input type="text" name="test" id="test" value="" class="text" /></form>';
     $this->assertEquals(trim_html($expected), trim_html($actual));
     Form::setErrors(array('test' => 'There is a problem'));
     $actual = Form::open()->text('test')->close();
     $expected = '<form action="" method="post" class="" id="" ><div class="error">There is a problem</div>
         <input type="text" name="test" id="test" value="" class="text" /></form>';
     $this->assertEquals(trim_html($expected), trim_html($actual));
     // Test merge
     Form::setErrors(array('test' => 'There is a problem'));
     Form::setErrors(array('test2' => 'There is another problem'));
     $actual = array('test' => 'There is a problem', 'test2' => 'There is another problem');
     $this->assertTrue(isset(Form::$errors['test']));
     $this->assertTrue(isset(Form::$errors['test2']));
     $this->assertTrue(Form::$errors['test'] == 'There is a problem');
     $this->assertTrue(Form::$errors['test2'] == 'There is another problem');
 }