Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Form] Improved test coverage of FormFactory and improved error handling
- Loading branch information
Showing
10 changed files
with
527 additions
and
68 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/Form/Exception/CreationException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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\Exception; | ||
|
||
/** | ||
* Thrown when a form could not be constructed by a FormFactory | ||
* | ||
* @author Bernhard Schussek <bernhard.schussek@symfony.com> | ||
*/ | ||
class CreationException extends FormException | ||
{ | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/Form/Exception/TypeDefinitionException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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\Exception; | ||
|
||
/** | ||
* Thrown when a form type is configured incorrectly | ||
* | ||
* @author Bernhard Schussek <bernhard.schussek@symfony.com> | ||
*/ | ||
class TypeDefinitionException extends FormException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Symfony\Tests\Component\Form\Fixtures; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilder; | ||
use Symfony\Component\Form\FormFactoryInterface; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
||
class FooType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilder $builder, array $options) | ||
{ | ||
$builder->setAttribute('foo', 'x'); | ||
$builder->setAttribute('data_option', $options['data']); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
public function createBuilder($name, FormFactoryInterface $factory, array $options) | ||
{ | ||
return new FormBuilder($name, $factory, new EventDispatcher()); | ||
} | ||
|
||
public function getDefaultOptions(array $options) | ||
{ | ||
return array( | ||
'data' => null, | ||
'required' => false, | ||
'max_length' => null, | ||
); | ||
} | ||
|
||
public function getParent(array $options) | ||
{ | ||
return null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/Symfony/Tests/Component/Form/Fixtures/FooTypeBarExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Symfony\Tests\Component\Form\Fixtures; | ||
|
||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\FormBuilder; | ||
|
||
class FooTypeBarExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilder $builder, array $options) | ||
{ | ||
$builder->setAttribute('bar', 'x'); | ||
} | ||
|
||
public function getExtendedType() | ||
{ | ||
return 'foo'; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/Symfony/Tests/Component/Form/Fixtures/FooTypeBazExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Symfony\Tests\Component\Form\Fixtures; | ||
|
||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\FormBuilder; | ||
|
||
class FooTypeBazExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilder $builder, array $options) | ||
{ | ||
$builder->setAttribute('baz', 'x'); | ||
} | ||
|
||
public function getExtendedType() | ||
{ | ||
return 'foo'; | ||
} | ||
} |
Oops, something went wrong.