Added more tests for the forms.
This commit is contained in:
parent
c05d3d6c90
commit
09cee5a5df
2 changed files with 46 additions and 20 deletions
|
|
@ -68,6 +68,19 @@ class FormTest extends TestCase
|
|||
self::assertTrue(is_callable($f->getValidator()));
|
||||
}
|
||||
|
||||
public function testInputCreate()
|
||||
{
|
||||
$text = Form\Element\Text::create(
|
||||
'input-name',
|
||||
'input-label',
|
||||
true
|
||||
);
|
||||
|
||||
self::assertEquals('input-name', $text->getName());
|
||||
self::assertEquals('input-label', $text->getLabel());
|
||||
self::assertTrue($text->getRequired());
|
||||
}
|
||||
|
||||
public function testInputValidation()
|
||||
{
|
||||
$f = new Form\Element\Text();
|
||||
|
|
@ -98,6 +111,16 @@ class FormTest extends TestCase
|
|||
self::assertFalse($f->validate());
|
||||
}
|
||||
|
||||
public function testInputValidationWithCustomError()
|
||||
{
|
||||
$f = new Form\Element\Text();
|
||||
$f->setRequired(true);
|
||||
$f->setValue('input-value');
|
||||
$f->setError('Error!');
|
||||
|
||||
self::assertFalse($f->validate());
|
||||
}
|
||||
|
||||
public function testFieldSetBasics()
|
||||
{
|
||||
$f = new Form\FieldSet();
|
||||
|
|
@ -188,5 +211,8 @@ class FormTest extends TestCase
|
|||
|
||||
$e = new Form\Element\Url();
|
||||
self::assertTrue(strpos($e->render(), 'url') !== false);
|
||||
|
||||
$e = new Form\Element\Password();
|
||||
self::assertTrue(strpos($e->render(), 'password') !== false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue