[Form] Added test case for 4759e062ed004749dbdc2ba31aef0f8ac2601895

This commit is contained in:
Bernhard Schussek 2014-03-28 12:44:24 +01:00
parent 7bc7a8a6ec
commit b44e07b7f6
4 changed files with 64 additions and 0 deletions

View File

@ -11,6 +11,7 @@ CHANGELOG
* [BC BREAK] added two optional parameters to FormInterface::getErrors() and
changed the method to return a Symfony\Component\Form\FormErrorIterator
instance instead of an array
* you can now pass interface names in the "data_class" option
2.4.0
-----

View File

@ -146,6 +146,37 @@ class FormTypeTest extends BaseTypeTest
$this->assertSame(10, $view->vars['attr']['maxlength']);
}
public function testDataClassMayBeNull()
{
$this->factory->createBuilder('form', null, array(
'data_class' => null,
));
}
public function testDataClassMayBeAbstractClass()
{
$this->factory->createBuilder('form', null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor',
));
}
public function testDataClassMayBeInterface()
{
$this->factory->createBuilder('form', null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface',
));
}
/**
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
*/
public function testDataClassMustBeValidClassOrInterface()
{
$this->factory->createBuilder('form', null, array(
'data_class' => 'foobar',
));
}
public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable()
{
$builder = $this->factory->createBuilder('form', null, array(

View File

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Tests\Fixtures;
abstract class AbstractAuthor
{
}

View File

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Tests\Fixtures;
interface AuthorInterface
{
}