feature #15079 [Form] Deprecated FormTypeInterface::getName() and passing of type instances (webmozart)
This PR was merged into the 2.8 branch.
Discussion
----------
[Form] Deprecated FormTypeInterface::getName() and passing of type instances
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #5321, #15008
| License | MIT
| Doc PR | TODO
#### Type Names
This PR deprecates the definition of the `getName()` method of form types. See #15008 for a more detailed description.
Before:
```php
class MyType extends AbstractType
{
public function getName()
{
return 'mytype';
}
// ...
}
```
After:
```php
class MyType extends AbstractType
{
// ...
}
```
You should always reference other types by their fully-qualified class names. Thanks to PHP 5.5, that's easy:
Before:
```php
$form = $this->createFormBuilder()
->add('name', 'text')
->add('age', 'integer')
->getForm();
```
After:
```php
$form = $this->createFormBuilder()
->add('name', TextType::class)
->add('age', IntegerType::class)
->getForm();
```
#### Type Instances
Furthermore, passing of type instances is deprecated.
Before:
```php
$form = $this->createForm(new AuthorType());
```
After:
```php
$form = $this->createForm(AuthorType::class);
```
#### DIC Aliases
When registering a type in the DIC, you should omit the "alias" attribute now.
Before:
```xml
<service id="my.type" class="Vendor\Type\MyType">
<tag name="form.type" alias="mytype" />
<argument type="service" id="some.service.id" />
</service>
```
After:
```xml
<service id="my.type" class="Vendor\Type\MyType">
<tag name="form.type" />
<argument type="service" id="some.service.id" />
</service>
```
Types without dependencies don't need to be registered in the DIC as they can be instantiated right away.
#### Template Block Prefixes
By default, the class name of the type in underscore notation minus "Type" suffix is used as Twig template block prefix (e.g. `UserProfileType` => `user_profile_*`). If you want to customize that, overwrite the new `getBlockPrefix()` method in your type:
```php
class UserProfileType extends AbstractType
{
public function getBlockPrefix()
{
return 'profile';
}
// ...
}
```
Commits
-------
3d9e5de
[Form] Deprecated FormTypeInterface::getName() and passing of type instances
This commit is contained in:
commit
5b38d74128
192
UPGRADE-2.8.md
192
UPGRADE-2.8.md
@ -12,7 +12,7 @@ Form
|
|||||||
Before:
|
Before:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$form = $this->createForm('form', $article, array('cascade_validation' => true))
|
$form = $this->createFormBuilder($article, array('cascade_validation' => true))
|
||||||
->add('author', new AuthorType())
|
->add('author', new AuthorType())
|
||||||
->getForm();
|
->getForm();
|
||||||
```
|
```
|
||||||
@ -22,7 +22,7 @@ Form
|
|||||||
```php
|
```php
|
||||||
use Symfony\Component\Validator\Constraints\Valid;
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
|
|
||||||
$form = $this->createForm('form', $article)
|
$form = $this->createFormBuilder($article)
|
||||||
->add('author', new AuthorType(), array(
|
->add('author', new AuthorType(), array(
|
||||||
'constraints' => new Valid(),
|
'constraints' => new Valid(),
|
||||||
))
|
))
|
||||||
@ -43,6 +43,194 @@ Form
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Type names were deprecated and will be removed in Symfony 3.0. Instead of
|
||||||
|
referencing types by name, you should reference them by their
|
||||||
|
fully-qualified class name (FQCN) instead. With PHP 5.5 or later, you can
|
||||||
|
use the "class" constant for that:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form = $this->createFormBuilder()
|
||||||
|
->add('name', 'text')
|
||||||
|
->add('age', 'integer')
|
||||||
|
->getForm();
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
|
||||||
|
$form = $this->createFormBuilder()
|
||||||
|
->add('name', TextType::class)
|
||||||
|
->add('age', IntegerType::class)
|
||||||
|
->getForm();
|
||||||
|
```
|
||||||
|
|
||||||
|
As a further consequence, the method `FormTypeInterface::getName()` was
|
||||||
|
deprecated and will be removed in Symfony 3.0. You should remove this method
|
||||||
|
from your form types.
|
||||||
|
|
||||||
|
If you want to customize the block prefix of a type in Twig, you should now
|
||||||
|
implement `FormTypeInterface::getBlockPrefix()` instead:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class UserProfileType extends AbstractType
|
||||||
|
{
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'profile';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class UserProfileType extends AbstractType
|
||||||
|
{
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return 'profile';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't customize `getBlockPrefix()`, it defaults to the class name
|
||||||
|
without "Type" suffix in underscore notation (here: "user_profile").
|
||||||
|
|
||||||
|
If you want to create types that are compatible with Symfony 2.3 up to 2.8
|
||||||
|
and don't trigger deprecation errors, implement *both* `getName()` and
|
||||||
|
`getBlockPrefix()`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class ProfileType extends AbstractType
|
||||||
|
{
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return 'profile';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you define your form types in the Dependency Injection configuration, you
|
||||||
|
should further remove the "alias" attribute:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="my.type" class="Vendor\Type\MyType">
|
||||||
|
<tag name="form.type" alias="mytype" />
|
||||||
|
</service>
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="my.type" class="Vendor\Type\MyType">
|
||||||
|
<tag name="form.type" />
|
||||||
|
</service>
|
||||||
|
```
|
||||||
|
|
||||||
|
Type extension should return the fully-qualified class name of the extended
|
||||||
|
type from `FormTypeExtensionInterface::getExtendedType()` now.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class MyTypeExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'form';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
|
|
||||||
|
class MyTypeExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return FormType::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If your extension has to be compatible with Symfony 2.3-2.8, use the
|
||||||
|
following statement:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
|
|
||||||
|
class MyTypeExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
method_exists(AbstractType::class, 'getBlockPrefix') ? FormType::class : 'form';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* Returning type instances from `FormTypeInterface::getParent()` is deprecated
|
||||||
|
and will not be supported anymore in Symfony 3.0. Return the fully-qualified
|
||||||
|
class name of the parent type class instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class MyType
|
||||||
|
{
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return new ParentType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class MyType
|
||||||
|
{
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return ParentType::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* Passing type instances to `Form::add()`, `FormBuilder::add()` and the
|
||||||
|
`FormFactory::create*()` methods is deprecated and will not be supported
|
||||||
|
anymore in Symfony 3.0. Pass the fully-qualified class name of the type
|
||||||
|
instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form = $this->createForm(new MyType());
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form = $this->createForm(MyType::class);
|
||||||
|
```
|
||||||
|
|
||||||
Translator
|
Translator
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -335,6 +335,6 @@ abstract class DoctrineType extends AbstractType
|
|||||||
|
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,18 @@ class EntityType extends DoctrineType
|
|||||||
return new ORMQueryBuilderLoader($queryBuilder, $manager, $class);
|
return new ORMQueryBuilderLoader($queryBuilder, $manager, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'entity';
|
return 'entity';
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,22 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
// be managed!
|
// be managed!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$field = $this->factory->createNamed('name', 'entity', null, array(
|
||||||
|
'em' => 'default',
|
||||||
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertSame('entity', $field->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
|
* @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
|
||||||
*/
|
*/
|
||||||
public function testClassOptionIsRequired()
|
public function testClassOptionIsRequired()
|
||||||
{
|
{
|
||||||
$this->factory->createNamed('name', 'entity');
|
$this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +125,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidClassOption()
|
public function testInvalidClassOption()
|
||||||
{
|
{
|
||||||
$this->factory->createNamed('name', 'entity', null, array(
|
$this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'class' => 'foo',
|
'class' => 'foo',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -127,7 +137,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -144,7 +154,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -161,7 +171,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
$qb = $this->em->createQueryBuilder()->select('e')->from(self::SINGLE_IDENT_CLASS, 'e');
|
$qb = $this->em->createQueryBuilder()->select('e')->from(self::SINGLE_IDENT_CLASS, 'e');
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -177,7 +187,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
|
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => new \stdClass(),
|
'query_builder' => new \stdClass(),
|
||||||
@ -189,7 +199,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
|
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => function () {
|
'query_builder' => function () {
|
||||||
@ -202,7 +212,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSetDataSingleNull()
|
public function testSetDataSingleNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
@ -215,7 +225,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSetDataMultipleExpandedNull()
|
public function testSetDataMultipleExpandedNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -229,7 +239,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSetDataMultipleNonExpandedNull()
|
public function testSetDataMultipleNonExpandedNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -243,7 +253,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNull()
|
public function testSubmitSingleExpandedNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -257,7 +267,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedNull()
|
public function testSubmitSingleNonExpandedNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -271,7 +281,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNull()
|
public function testSubmitMultipleNull()
|
||||||
{
|
{
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
@ -289,7 +299,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -311,7 +321,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -335,7 +345,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -360,7 +370,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -391,7 +401,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -417,7 +427,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -447,7 +457,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -473,7 +483,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -528,7 +538,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
// not all persisted entities should be displayed
|
// not all persisted entities should be displayed
|
||||||
@ -553,7 +563,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($item1, $item2, $item3, $item4));
|
$this->persist(array($item1, $item2, $item3, $item4));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::ITEM_GROUP_CLASS,
|
'class' => self::ITEM_GROUP_CLASS,
|
||||||
'choices' => array($item1, $item2, $item3, $item4),
|
'choices' => array($item1, $item2, $item3, $item4),
|
||||||
@ -584,7 +594,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'preferred_choices' => array($entity3, $entity2),
|
'preferred_choices' => array($entity3, $entity2),
|
||||||
@ -603,7 +613,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'choices' => array($entity2, $entity3),
|
'choices' => array($entity2, $entity3),
|
||||||
@ -623,7 +633,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'choices' => array($entity1, $entity2),
|
'choices' => array($entity1, $entity2),
|
||||||
@ -644,7 +654,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::COMPOSITE_IDENT_CLASS,
|
'class' => self::COMPOSITE_IDENT_CLASS,
|
||||||
'choices' => array($entity1, $entity2),
|
'choices' => array($entity1, $entity2),
|
||||||
@ -667,7 +677,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS);
|
$repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS);
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => $repository->createQueryBuilder('e')
|
'query_builder' => $repository->createQueryBuilder('e')
|
||||||
@ -689,7 +699,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => function ($repository) {
|
'query_builder' => function ($repository) {
|
||||||
@ -713,7 +723,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2, $entity3));
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::COMPOSITE_IDENT_CLASS,
|
'class' => self::COMPOSITE_IDENT_CLASS,
|
||||||
'query_builder' => function ($repository) {
|
'query_builder' => function ($repository) {
|
||||||
@ -735,7 +745,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1));
|
$this->persist(array($entity1));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -756,7 +766,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1));
|
$this->persist(array($entity1));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
@ -782,7 +792,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
->with(self::SINGLE_IDENT_CLASS)
|
->with(self::SINGLE_IDENT_CLASS)
|
||||||
->will($this->returnValue($this->em));
|
->will($this->returnValue($this->em));
|
||||||
|
|
||||||
$this->factory->createNamed('name', 'entity', null, array(
|
$this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choice_label' => 'name',
|
'choice_label' => 'name',
|
||||||
@ -797,7 +807,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
$this->emRegistry->expects($this->never())
|
$this->emRegistry->expects($this->never())
|
||||||
->method('getManagerForClass');
|
->method('getManagerForClass');
|
||||||
|
|
||||||
$this->factory->createNamed('name', 'entity', null, array(
|
$this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => $this->em,
|
'em' => $this->em,
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'choice_label' => 'name',
|
'choice_label' => 'name',
|
||||||
@ -826,15 +836,15 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
->addTypeGuesser($entityTypeGuesser)
|
->addTypeGuesser($entityTypeGuesser)
|
||||||
->getFormFactory();
|
->getFormFactory();
|
||||||
|
|
||||||
$formBuilder = $factory->createNamedBuilder('form', 'form');
|
$formBuilder = $factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
|
|
||||||
$formBuilder->add('property1', 'entity', array(
|
$formBuilder->add('property1', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'),
|
'query_builder' => $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$formBuilder->add('property2', 'entity', array(
|
$formBuilder->add('property2', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => function (EntityRepository $repo) {
|
'query_builder' => function (EntityRepository $repo) {
|
||||||
@ -842,7 +852,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
$formBuilder->add('property3', 'entity', array(
|
$formBuilder->add('property3', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'query_builder' => function (EntityRepository $repo) {
|
'query_builder' => function (EntityRepository $repo) {
|
||||||
@ -873,14 +883,14 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1));
|
$this->persist(array($entity1));
|
||||||
|
|
||||||
$field1 = $this->factory->createNamed('name', 'entity', null, array(
|
$field1 = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choice_label' => 'name',
|
'choice_label' => 'name',
|
||||||
));
|
));
|
||||||
|
|
||||||
$field2 = $this->factory->createNamed('name', 'entity', null, array(
|
$field2 = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -901,7 +911,7 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->persist(array($entity1, $entity2));
|
$this->persist(array($entity1, $entity2));
|
||||||
|
|
||||||
$field = $this->factory->createNamed('name', 'entity', null, array(
|
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"symfony/phpunit-bridge": "~2.7|~3.0.0",
|
"symfony/phpunit-bridge": "~2.7|~3.0.0",
|
||||||
"symfony/stopwatch": "~2.2|~3.0.0",
|
"symfony/stopwatch": "~2.2|~3.0.0",
|
||||||
"symfony/dependency-injection": "~2.2|~3.0.0",
|
"symfony/dependency-injection": "~2.2|~3.0.0",
|
||||||
"symfony/form": "~2.7,>=2.7.1|~3.0.0",
|
"symfony/form": "~2.8|~3.0.0",
|
||||||
"symfony/http-kernel": "~2.2|~3.0.0",
|
"symfony/http-kernel": "~2.2|~3.0.0",
|
||||||
"symfony/property-access": "~2.3|~3.0.0",
|
"symfony/property-access": "~2.3|~3.0.0",
|
||||||
"symfony/security": "~2.2|~3.0.0",
|
"symfony/security": "~2.2|~3.0.0",
|
||||||
|
@ -69,7 +69,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
public function testThemeBlockInheritanceUsingUse()
|
public function testThemeBlockInheritanceUsingUse()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('name', 'email')
|
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType')
|
||||||
->createView()
|
->createView()
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
public function testThemeBlockInheritanceUsingExtend()
|
public function testThemeBlockInheritanceUsingExtend()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('name', 'email')
|
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType')
|
||||||
->createView()
|
->createView()
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
public function testThemeBlockInheritanceUsingDynamicExtend()
|
public function testThemeBlockInheritanceUsingDynamicExtend()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('name', 'email')
|
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType')
|
||||||
->createView()
|
->createView()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -33,16 +33,29 @@ class FormPass implements CompilerPassInterface
|
|||||||
// Builds an array with service IDs as keys and tag aliases as values
|
// Builds an array with service IDs as keys and tag aliases as values
|
||||||
$types = array();
|
$types = array();
|
||||||
|
|
||||||
foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
|
// Remember which names will not be supported in Symfony 3.0 to trigger
|
||||||
$alias = isset($tag[0]['alias'])
|
// deprecation errors
|
||||||
? $tag[0]['alias']
|
$legacyNames = array();
|
||||||
: $serviceId;
|
|
||||||
|
|
||||||
// Flip, because we want tag aliases (= type identifiers) as keys
|
foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
|
||||||
$types[$alias] = $serviceId;
|
// The following if-else block is deprecated and will be removed
|
||||||
|
// in Symfony 3.0
|
||||||
|
// Deprecation errors are triggered in DependencyInjectionExtension
|
||||||
|
if (isset($tag[0]['alias'])) {
|
||||||
|
$types[$tag[0]['alias']] = $serviceId;
|
||||||
|
$legacyNames[$tag[0]['alias']] = true;
|
||||||
|
} else {
|
||||||
|
$types[$serviceId] = $serviceId;
|
||||||
|
$legacyNames[$serviceId] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support type access by FQCN
|
||||||
|
$serviceDefinition = $container->getDefinition($serviceId);
|
||||||
|
$types[$serviceDefinition->getClass()] = $serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition->replaceArgument(1, $types);
|
$definition->replaceArgument(1, $types);
|
||||||
|
$definition->replaceArgument(4, $legacyNames);
|
||||||
|
|
||||||
$typeExtensions = array();
|
$typeExtensions = array();
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
<!-- All services with tag "form.type_guesser" are inserted here by FormPass -->
|
<!-- All services with tag "form.type_guesser" are inserted here by FormPass -->
|
||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
|
<!-- The deprecated type names are inserted here by FormPass -->
|
||||||
|
<argument type="collection" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- ValidatorTypeGuesser -->
|
<!-- ValidatorTypeGuesser -->
|
||||||
|
@ -0,0 +1,223 @@
|
|||||||
|
<?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\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class FormPassTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testDoNothingIfFormExtensionNotLoaded()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$this->assertFalse($container->hasDefinition('form.extension'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddTaggedTypes()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||||
|
$extDefinition->setArguments(array(
|
||||||
|
new Reference('service_container'),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definition1 = new Definition(__CLASS__.'_Type1');
|
||||||
|
$definition1->addTag('form.type');
|
||||||
|
$definition2 = new Definition(__CLASS__.'_Type2');
|
||||||
|
$definition2->addTag('form.type');
|
||||||
|
|
||||||
|
$container->setDefinition('form.extension', $extDefinition);
|
||||||
|
$container->setDefinition('my.type1', $definition1);
|
||||||
|
$container->setDefinition('my.type2', $definition2);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$extDefinition = $container->getDefinition('form.extension');
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
// As of Symfony 2.8, the class is used to look up types
|
||||||
|
__CLASS__.'_Type1' => 'my.type1',
|
||||||
|
__CLASS__.'_Type2' => 'my.type2',
|
||||||
|
// Before Symfony 2.8, the service ID was used as default alias
|
||||||
|
'my.type1' => 'my.type1',
|
||||||
|
'my.type2' => 'my.type2',
|
||||||
|
), $extDefinition->getArgument(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUseCustomAliasIfSet()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||||
|
$extDefinition->setArguments(array(
|
||||||
|
new Reference('service_container'),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definition1 = new Definition(__CLASS__.'_Type1');
|
||||||
|
$definition1->addTag('form.type', array('alias' => 'mytype1'));
|
||||||
|
$definition2 = new Definition(__CLASS__.'_Type2');
|
||||||
|
$definition2->addTag('form.type', array('alias' => 'mytype2'));
|
||||||
|
|
||||||
|
$container->setDefinition('form.extension', $extDefinition);
|
||||||
|
$container->setDefinition('my.type1', $definition1);
|
||||||
|
$container->setDefinition('my.type2', $definition2);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$extDefinition = $container->getDefinition('form.extension');
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
__CLASS__.'_Type1' => 'my.type1',
|
||||||
|
__CLASS__.'_Type2' => 'my.type2',
|
||||||
|
'mytype1' => 'my.type1',
|
||||||
|
'mytype2' => 'my.type2',
|
||||||
|
), $extDefinition->getArgument(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPassLegacyNames()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||||
|
$extDefinition->setArguments(array(
|
||||||
|
new Reference('service_container'),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definition1 = new Definition(__CLASS__.'_Type1');
|
||||||
|
$definition1->addTag('form.type');
|
||||||
|
$definition2 = new Definition(__CLASS__.'_Type2');
|
||||||
|
$definition2->addTag('form.type', array('alias' => 'mytype2'));
|
||||||
|
|
||||||
|
$container->setDefinition('form.extension', $extDefinition);
|
||||||
|
$container->setDefinition('my.type1', $definition1);
|
||||||
|
$container->setDefinition('my.type2', $definition2);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$extDefinition = $container->getDefinition('form.extension');
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
// Service ID if no alias is set
|
||||||
|
'my.type1' => true,
|
||||||
|
// Alias if set
|
||||||
|
'mytype2' => true,
|
||||||
|
), $extDefinition->getArgument(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddTaggedTypeExtensions()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||||
|
$extDefinition->setArguments(array(
|
||||||
|
new Reference('service_container'),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definition1 = new Definition('stdClass');
|
||||||
|
$definition1->addTag('form.type_extension', array('alias' => 'type1'));
|
||||||
|
$definition2 = new Definition('stdClass');
|
||||||
|
$definition2->addTag('form.type_extension', array('alias' => 'type1'));
|
||||||
|
$definition3 = new Definition('stdClass');
|
||||||
|
$definition3->addTag('form.type_extension', array('alias' => 'type2'));
|
||||||
|
|
||||||
|
$container->setDefinition('form.extension', $extDefinition);
|
||||||
|
$container->setDefinition('my.type_extension1', $definition1);
|
||||||
|
$container->setDefinition('my.type_extension2', $definition2);
|
||||||
|
$container->setDefinition('my.type_extension3', $definition3);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$extDefinition = $container->getDefinition('form.extension');
|
||||||
|
|
||||||
|
$this->assertSame(array(
|
||||||
|
'type1' => array(
|
||||||
|
'my.type_extension1',
|
||||||
|
'my.type_extension2',
|
||||||
|
),
|
||||||
|
'type2' => array(
|
||||||
|
'my.type_extension3',
|
||||||
|
),
|
||||||
|
), $extDefinition->getArgument(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddTaggedGuessers()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->addCompilerPass(new FormPass());
|
||||||
|
|
||||||
|
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||||
|
$extDefinition->setArguments(array(
|
||||||
|
new Reference('service_container'),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
array(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definition1 = new Definition('stdClass');
|
||||||
|
$definition1->addTag('form.type_guesser');
|
||||||
|
$definition2 = new Definition('stdClass');
|
||||||
|
$definition2->addTag('form.type_guesser');
|
||||||
|
|
||||||
|
$container->setDefinition('form.extension', $extDefinition);
|
||||||
|
$container->setDefinition('my.guesser1', $definition1);
|
||||||
|
$container->setDefinition('my.guesser2', $definition2);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$extDefinition = $container->getDefinition('form.extension');
|
||||||
|
|
||||||
|
$this->assertSame(array(
|
||||||
|
'my.guesser1',
|
||||||
|
'my.guesser2',
|
||||||
|
), $extDefinition->getArgument(3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FormPassTest_Type1 extends AbstractType
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
class FormPassTest_Type2 extends AbstractType
|
||||||
|
{
|
||||||
|
}
|
@ -19,7 +19,7 @@ class LoginController extends ContainerAware
|
|||||||
{
|
{
|
||||||
public function loginAction()
|
public function loginAction()
|
||||||
{
|
{
|
||||||
$form = $this->container->get('form.factory')->create('user_login');
|
$form = $this->container->get('form.factory')->create('Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType');
|
||||||
|
|
||||||
return $this->container->get('templating')->renderResponse('CsrfFormLoginBundle:Login:login.html.twig', array(
|
return $this->container->get('templating')->renderResponse('CsrfFormLoginBundle:Login:login.html.twig', array(
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
|
@ -27,7 +27,7 @@ use Symfony\Component\Security\Core\Security;
|
|||||||
* @author Henrik Bjornskov <henrik@bjrnskov.dk>
|
* @author Henrik Bjornskov <henrik@bjrnskov.dk>
|
||||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||||
*/
|
*/
|
||||||
class UserLoginFormType extends AbstractType
|
class UserLoginType extends AbstractType
|
||||||
{
|
{
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
|
|
||||||
@ -45,9 +45,9 @@ class UserLoginFormType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('username', 'text')
|
->add('username', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('password', 'password')
|
->add('password', 'Symfony\Component\Form\Extension\Core\Type\PasswordType')
|
||||||
->add('_target_path', 'hidden')
|
->add('_target_path', 'Symfony\Component\Form\Extension\Core\Type\HiddenType')
|
||||||
;
|
;
|
||||||
|
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
@ -87,12 +87,4 @@ class UserLoginFormType extends AbstractType
|
|||||||
'intention' => 'authenticate',
|
'intention' => 'authenticate',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'user_login';
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,11 +3,11 @@ imports:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
csrf_form_login.form.type:
|
csrf_form_login.form.type:
|
||||||
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType
|
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType
|
||||||
arguments:
|
arguments:
|
||||||
- @request_stack
|
- @request_stack
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: user_login }
|
- { name: form.type }
|
||||||
|
|
||||||
security:
|
security:
|
||||||
encoders:
|
encoders:
|
||||||
|
@ -156,7 +156,15 @@ abstract class AbstractExtension implements FormExtensionInterface
|
|||||||
throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface');
|
throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->types[$type->getName()] = $type;
|
// Since Symfony 3.0 types are identified by their FQCN
|
||||||
|
$fqcn = get_class($type);
|
||||||
|
$legacyName = $type->getName();
|
||||||
|
|
||||||
|
$this->types[$fqcn] = $type;
|
||||||
|
|
||||||
|
if ($legacyName) {
|
||||||
|
$this->types[$legacyName] = $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Util\StringUtil;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||||
|
|
||||||
@ -61,11 +62,37 @@ abstract class AbstractType implements FormTypeInterface
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
// As of Symfony 2.8, the name defaults to the fully-qualified class name
|
||||||
|
return get_class($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the prefix of the template block name for this type.
|
||||||
|
*
|
||||||
|
* The block prefixes defaults to the underscored short class name with
|
||||||
|
* the "Type" suffix removed (e.g. "UserProfileType" => "user_profile").
|
||||||
|
*
|
||||||
|
* @return string The prefix of the template block name
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
$fqcn = get_class($this);
|
||||||
|
$name = $this->getName();
|
||||||
|
|
||||||
|
// For BC: Use the name as block prefix if one is set
|
||||||
|
return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'Symfony\Component\Form\Extension\Core\Type\FormType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\Form\Util\StringUtil;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +78,17 @@ abstract class BaseType extends AbstractType
|
|||||||
|
|
||||||
$blockPrefixes = array();
|
$blockPrefixes = array();
|
||||||
for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
|
for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
|
||||||
array_unshift($blockPrefixes, $type->getName());
|
if (method_exists($type, 'getBlockPrefix')) {
|
||||||
|
array_unshift($blockPrefixes, $type->getBlockPrefix());
|
||||||
|
} else {
|
||||||
|
@trigger_error(get_class($type).': The ResolvedFormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should add it to your implementation.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$fqcn = get_class($type->getInnerType());
|
||||||
|
$name = $type->getName();
|
||||||
|
$hasCustomName = $name !== $fqcn;
|
||||||
|
|
||||||
|
array_unshift($blockPrefixes, $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$blockPrefixes[] = $uniqueBlockPrefix;
|
$blockPrefixes[] = $uniqueBlockPrefix;
|
||||||
|
|
||||||
|
@ -31,13 +31,21 @@ class BirthdayType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'date';
|
return __NAMESPACE__.'\DateType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'birthday';
|
return 'birthday';
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,14 @@ class ButtonType extends BaseType implements ButtonTypeInterface
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'button';
|
return 'button';
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,14 @@ class CheckboxType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'checkbox';
|
return 'checkbox';
|
||||||
}
|
}
|
||||||
|
@ -361,6 +361,14 @@ class ChoiceType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return 'choice';
|
||||||
}
|
}
|
||||||
@ -424,12 +432,12 @@ class ChoiceType extends AbstractType
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($options['multiple']) {
|
if ($options['multiple']) {
|
||||||
$choiceType = 'checkbox';
|
$choiceType = __NAMESPACE__.'\CheckboxType';
|
||||||
// The user can check 0 or more checkboxes. If required
|
// The user can check 0 or more checkboxes. If required
|
||||||
// is true, he is required to check all of them.
|
// is true, he is required to check all of them.
|
||||||
$choiceOpts['required'] = false;
|
$choiceOpts['required'] = false;
|
||||||
} else {
|
} else {
|
||||||
$choiceType = 'radio';
|
$choiceType = __NAMESPACE__.'\RadioType';
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add($name, $choiceType, $choiceOpts);
|
$builder->add($name, $choiceType, $choiceOpts);
|
||||||
|
@ -88,7 +88,7 @@ class CollectionType extends AbstractType
|
|||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_data' => null,
|
'prototype_data' => null,
|
||||||
'prototype_name' => '__name__',
|
'prototype_name' => '__name__',
|
||||||
'type' => 'text',
|
'type' => __NAMESPACE__.'\TextType',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
'delete_empty' => false,
|
'delete_empty' => false,
|
||||||
));
|
));
|
||||||
@ -100,6 +100,14 @@ class CollectionType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'collection';
|
return 'collection';
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,21 @@ class CountryType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return __NAMESPACE__.'\ChoiceType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'country';
|
return 'country';
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,21 @@ class CurrencyType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return __NAMESPACE__.'\ChoiceType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'currency';
|
return 'currency';
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,8 @@ class DateTimeType extends AbstractType
|
|||||||
'time' => $timeParts,
|
'time' => $timeParts,
|
||||||
)),
|
)),
|
||||||
)))
|
)))
|
||||||
->add('date', 'date', $dateOptions)
|
->add('date', __NAMESPACE__.'\DateType', $dateOptions)
|
||||||
->add('time', 'time', $timeOptions)
|
->add('time', __NAMESPACE__.'\TimeType', $timeOptions)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +284,14 @@ class DateTimeType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'datetime';
|
return 'datetime';
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,11 @@ class DateType extends AbstractType
|
|||||||
\IntlDateFormatter::SHORT,
|
\IntlDateFormatter::SHORT,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $widgets = array(
|
||||||
|
'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
|
'choice' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -101,9 +106,9 @@ class DateType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('year', $options['widget'], $yearOptions)
|
->add('year', self::$widgets[$options['widget']], $yearOptions)
|
||||||
->add('month', $options['widget'], $monthOptions)
|
->add('month', self::$widgets[$options['widget']], $monthOptions)
|
||||||
->add('day', $options['widget'], $dayOptions)
|
->add('day', self::$widgets[$options['widget']], $dayOptions)
|
||||||
->addViewTransformer(new DateTimeToArrayTransformer(
|
->addViewTransformer(new DateTimeToArrayTransformer(
|
||||||
$options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day')
|
$options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day')
|
||||||
))
|
))
|
||||||
@ -253,6 +258,14 @@ class DateType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'date';
|
return 'date';
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,21 @@ class EmailType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'email';
|
return 'email';
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,14 @@ class FileType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'file';
|
return 'file';
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,14 @@ class FormType extends BaseType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'form';
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,14 @@ class HiddenType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'hidden';
|
return 'hidden';
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,14 @@ class IntegerType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'integer';
|
return 'integer';
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,21 @@ class LanguageType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return __NAMESPACE__.'\ChoiceType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'language';
|
return 'language';
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,21 @@ class LocaleType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return __NAMESPACE__.'\ChoiceType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'locale';
|
return 'locale';
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,14 @@ class MoneyType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'money';
|
return 'money';
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,14 @@ class NumberType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'number';
|
return 'number';
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,21 @@ class PasswordType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'password';
|
return 'password';
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,14 @@ class PercentType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'percent';
|
return 'percent';
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,21 @@ class RadioType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'checkbox';
|
return __NAMESPACE__.'\CheckboxType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'radio';
|
return 'radio';
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,21 @@ class RangeType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'range';
|
return 'range';
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class RepeatedType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'type' => 'text',
|
'type' => __NAMESPACE__.'\TextType',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
'first_options' => array(),
|
'first_options' => array(),
|
||||||
'second_options' => array(),
|
'second_options' => array(),
|
||||||
@ -65,6 +65,14 @@ class RepeatedType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'repeated';
|
return 'repeated';
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,21 @@ class ResetType extends AbstractType implements ButtonTypeInterface
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'button';
|
return __NAMESPACE__.'\ButtonType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'reset';
|
return 'reset';
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,21 @@ class SearchType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'search';
|
return 'search';
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,21 @@ class SubmitType extends AbstractType implements SubmitButtonTypeInterface
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'button';
|
return __NAMESPACE__.'\ButtonType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'submit';
|
return 'submit';
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,14 @@ class TextType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'text';
|
return 'text';
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,21 @@ class TextareaType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'textarea';
|
return 'textarea';
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
|
|
||||||
class TimeType extends AbstractType
|
class TimeType extends AbstractType
|
||||||
{
|
{
|
||||||
|
private static $widgets = array(
|
||||||
|
'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
|
'choice' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -99,14 +104,14 @@ class TimeType extends AbstractType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('hour', $options['widget'], $hourOptions);
|
$builder->add('hour', self::$widgets[$options['widget']], $hourOptions);
|
||||||
|
|
||||||
if ($options['with_minutes']) {
|
if ($options['with_minutes']) {
|
||||||
$builder->add('minute', $options['widget'], $minuteOptions);
|
$builder->add('minute', self::$widgets[$options['widget']], $minuteOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($options['with_seconds']) {
|
if ($options['with_seconds']) {
|
||||||
$builder->add('second', $options['widget'], $secondOptions);
|
$builder->add('second', self::$widgets[$options['widget']], $secondOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget']));
|
$builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget']));
|
||||||
@ -238,6 +243,14 @@ class TimeType extends AbstractType
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'time';
|
return 'time';
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,21 @@ class TimezoneType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return __NAMESPACE__.'\ChoiceType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'timezone';
|
return 'timezone';
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,21 @@ class UrlType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'text';
|
return __NAMESPACE__.'\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'url';
|
return 'url';
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
|||||||
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: get_class($form->getConfig()->getType()->getInnerType()));
|
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: get_class($form->getConfig()->getType()->getInnerType()));
|
||||||
$data = (string) $options['csrf_token_manager']->getToken($tokenId);
|
$data = (string) $options['csrf_token_manager']->getToken($tokenId);
|
||||||
|
|
||||||
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array(
|
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, array(
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -153,6 +153,6 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
|||||||
*/
|
*/
|
||||||
public function getExtendedType()
|
public function getExtendedType()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'Symfony\Component\Form\Extension\Core\Type\FormType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,14 @@ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
|
|||||||
return $this->proxiedType->getName();
|
return $this->proxiedType->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return method_exists($this->proxiedType, 'getBlockPrefix') ? $this->proxiedType->getBlockPrefix() : $this->getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -22,17 +22,19 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
|||||||
private $typeServiceIds;
|
private $typeServiceIds;
|
||||||
private $typeExtensionServiceIds;
|
private $typeExtensionServiceIds;
|
||||||
private $guesserServiceIds;
|
private $guesserServiceIds;
|
||||||
|
private $legacyNames;
|
||||||
private $guesser;
|
private $guesser;
|
||||||
private $guesserLoaded = false;
|
private $guesserLoaded = false;
|
||||||
|
|
||||||
public function __construct(ContainerInterface $container,
|
public function __construct(ContainerInterface $container,
|
||||||
array $typeServiceIds, array $typeExtensionServiceIds,
|
array $typeServiceIds, array $typeExtensionServiceIds,
|
||||||
array $guesserServiceIds)
|
array $guesserServiceIds, array $legacyNames = array())
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->typeServiceIds = $typeServiceIds;
|
$this->typeServiceIds = $typeServiceIds;
|
||||||
$this->typeExtensionServiceIds = $typeExtensionServiceIds;
|
$this->typeExtensionServiceIds = $typeExtensionServiceIds;
|
||||||
$this->guesserServiceIds = $guesserServiceIds;
|
$this->guesserServiceIds = $guesserServiceIds;
|
||||||
|
$this->legacyNames = $legacyNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType($name)
|
public function getType($name)
|
||||||
@ -41,15 +43,21 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
|||||||
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name));
|
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
$type = $this->container->get($this->typeServiceIds[$name]);
|
$type = $this->container->get($this->typeServiceIds[$name]);
|
||||||
|
|
||||||
if ($type->getName() !== $name) {
|
// BC: validate result of getName() for legacy names (non-FQCN)
|
||||||
|
if (isset($this->legacyNames[$name]) && $type->getName() !== $name) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"',
|
sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"',
|
||||||
$this->typeServiceIds[$name],
|
$this->typeServiceIds[$name],
|
||||||
$name,
|
$name,
|
||||||
$type->getName()
|
$type->getName()
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
@ -57,11 +65,23 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
|||||||
|
|
||||||
public function hasType($name)
|
public function hasType($name)
|
||||||
{
|
{
|
||||||
return isset($this->typeServiceIds[$name]);
|
if (isset($this->typeServiceIds[$name])) {
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTypeExtensions($name)
|
public function getTypeExtensions($name)
|
||||||
{
|
{
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
|
|
||||||
if (isset($this->typeExtensionServiceIds[$name])) {
|
if (isset($this->typeExtensionServiceIds[$name])) {
|
||||||
@ -75,6 +95,10 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
|||||||
|
|
||||||
public function hasTypeExtensions($name)
|
public function hasTypeExtensions($name)
|
||||||
{
|
{
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
return isset($this->typeExtensionServiceIds[$name]);
|
return isset($this->typeExtensionServiceIds[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,6 @@ class FormTypeValidatorExtension extends BaseValidatorExtension
|
|||||||
*/
|
*/
|
||||||
public function getExtendedType()
|
public function getExtendedType()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'Symfony\Component\Form\Extension\Core\Type\FormType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,6 @@ class RepeatedTypeValidatorExtension extends AbstractTypeExtension
|
|||||||
*/
|
*/
|
||||||
public function getExtendedType()
|
public function getExtendedType()
|
||||||
{
|
{
|
||||||
return 'repeated';
|
return 'Symfony\Component\Form\Extension\Core\Type\RepeatedType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,6 @@ class SubmitTypeValidatorExtension extends BaseValidatorExtension
|
|||||||
*/
|
*/
|
||||||
public function getExtendedType()
|
public function getExtendedType()
|
||||||
{
|
{
|
||||||
return 'submit';
|
return 'Symfony\Component\Form\Extension\Core\Type\SubmitType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $type && null === $this->getDataClass()) {
|
if (null === $type && null === $this->getDataClass()) {
|
||||||
$type = 'text';
|
$type = 'Symfony\Component\Form\Extension\Core\Type\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $type) {
|
if (null !== $type) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
|
use Symfony\Component\Form\Util\StringUtil;
|
||||||
|
|
||||||
class FormFactory implements FormFactoryInterface
|
class FormFactory implements FormFactoryInterface
|
||||||
{
|
{
|
||||||
@ -34,7 +35,7 @@ class FormFactory implements FormFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function create($type = 'form', $data = null, array $options = array())
|
public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
|
||||||
{
|
{
|
||||||
return $this->createBuilder($type, $data, $options)->getForm();
|
return $this->createBuilder($type, $data, $options)->getForm();
|
||||||
}
|
}
|
||||||
@ -42,7 +43,7 @@ class FormFactory implements FormFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function createNamed($name, $type = 'form', $data = null, array $options = array())
|
public function createNamed($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
|
||||||
{
|
{
|
||||||
return $this->createNamedBuilder($name, $type, $data, $options)->getForm();
|
return $this->createNamedBuilder($name, $type, $data, $options)->getForm();
|
||||||
}
|
}
|
||||||
@ -58,11 +59,37 @@ class FormFactory implements FormFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function createBuilder($type = 'form', $data = null, array $options = array())
|
public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
|
||||||
{
|
{
|
||||||
$name = $type instanceof FormTypeInterface || $type instanceof ResolvedFormTypeInterface
|
$name = null;
|
||||||
? $type->getName()
|
$typeName = null;
|
||||||
: $type;
|
|
||||||
|
if ($type instanceof ResolvedFormTypeInterface) {
|
||||||
|
if (method_exists($type, 'getBlockPrefix')) {
|
||||||
|
// As of Symfony 3.0, the block prefix of the type is used as
|
||||||
|
// default name
|
||||||
|
$name = $type->getBlockPrefix();
|
||||||
|
} else {
|
||||||
|
// BC
|
||||||
|
$typeName = $type->getName();
|
||||||
|
}
|
||||||
|
} elseif ($type instanceof FormTypeInterface) {
|
||||||
|
// BC
|
||||||
|
$typeName = $type->getName();
|
||||||
|
} else {
|
||||||
|
// BC
|
||||||
|
$typeName = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $name) {
|
||||||
|
if (false === strpos($typeName, '\\')) {
|
||||||
|
// No FQCN - leave unchanged for BC
|
||||||
|
$name = $typeName;
|
||||||
|
} else {
|
||||||
|
// FQCN
|
||||||
|
$name = StringUtil::fqcnToBlockPrefix($typeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->createNamedBuilder($name, $type, $data, $options);
|
return $this->createNamedBuilder($name, $type, $data, $options);
|
||||||
}
|
}
|
||||||
@ -70,17 +97,20 @@ class FormFactory implements FormFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array())
|
public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
|
||||||
{
|
{
|
||||||
if (null !== $data && !array_key_exists('data', $options)) {
|
if (null !== $data && !array_key_exists('data', $options)) {
|
||||||
$options['data'] = $data;
|
$options['data'] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type instanceof FormTypeInterface) {
|
if ($type instanceof FormTypeInterface) {
|
||||||
|
@trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
$type = $this->resolveType($type);
|
$type = $this->resolveType($type);
|
||||||
} elseif (is_string($type)) {
|
} elseif (is_string($type)) {
|
||||||
$type = $this->registry->getType($type);
|
$type = $this->registry->getType($type);
|
||||||
} elseif (!$type instanceof ResolvedFormTypeInterface) {
|
} elseif ($type instanceof ResolvedFormTypeInterface) {
|
||||||
|
@trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
} else {
|
||||||
throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface');
|
throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +129,7 @@ class FormFactory implements FormFactoryInterface
|
|||||||
public function createBuilderForProperty($class, $property, $data = null, array $options = array())
|
public function createBuilderForProperty($class, $property, $data = null, array $options = array())
|
||||||
{
|
{
|
||||||
if (null === $guesser = $this->registry->getTypeGuesser()) {
|
if (null === $guesser = $this->registry->getTypeGuesser()) {
|
||||||
return $this->createNamedBuilder($property, 'text', $data, $options);
|
return $this->createNamedBuilder($property, 'Symfony\Component\Form\Extension\Core\Type\TextType', $data, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$typeGuess = $guesser->guessType($class, $property);
|
$typeGuess = $guesser->guessType($class, $property);
|
||||||
@ -107,7 +137,7 @@ class FormFactory implements FormFactoryInterface
|
|||||||
$requiredGuess = $guesser->guessRequired($class, $property);
|
$requiredGuess = $guesser->guessRequired($class, $property);
|
||||||
$patternGuess = $guesser->guessPattern($class, $property);
|
$patternGuess = $guesser->guessPattern($class, $property);
|
||||||
|
|
||||||
$type = $typeGuess ? $typeGuess->getType() : 'text';
|
$type = $typeGuess ? $typeGuess->getType() : 'Symfony\Component\Form\Extension\Core\Type\TextType';
|
||||||
|
|
||||||
$maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null;
|
$maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null;
|
||||||
$pattern = $patternGuess ? $patternGuess->getValue() : null;
|
$pattern = $patternGuess ? $patternGuess->getValue() : null;
|
||||||
|
@ -78,7 +78,7 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function addType(FormTypeInterface $type)
|
public function addType(FormTypeInterface $type)
|
||||||
{
|
{
|
||||||
$this->types[$type->getName()] = $type;
|
$this->types[] = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
|
|||||||
public function addTypes(array $types)
|
public function addTypes(array $types)
|
||||||
{
|
{
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$this->types[$type->getName()] = $type;
|
$this->types[] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -29,7 +29,7 @@ interface FormFactoryInterface
|
|||||||
*
|
*
|
||||||
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
||||||
*/
|
*/
|
||||||
public function create($type = 'form', $data = null, array $options = array());
|
public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a form.
|
* Returns a form.
|
||||||
@ -45,7 +45,7 @@ interface FormFactoryInterface
|
|||||||
*
|
*
|
||||||
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
||||||
*/
|
*/
|
||||||
public function createNamed($name, $type = 'form', $data = null, array $options = array());
|
public function createNamed($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a form for a property of a class.
|
* Returns a form for a property of a class.
|
||||||
@ -74,7 +74,7 @@ interface FormFactoryInterface
|
|||||||
*
|
*
|
||||||
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
||||||
*/
|
*/
|
||||||
public function createBuilder($type = 'form', $data = null, array $options = array());
|
public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a form builder.
|
* Returns a form builder.
|
||||||
@ -88,7 +88,7 @@ interface FormFactoryInterface
|
|||||||
*
|
*
|
||||||
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
|
||||||
*/
|
*/
|
||||||
public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array());
|
public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a form builder for a property of a class.
|
* Returns a form builder for a property of a class.
|
||||||
|
@ -34,6 +34,11 @@ class FormRegistry implements FormRegistryInterface
|
|||||||
*/
|
*/
|
||||||
private $types = array();
|
private $types = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private $legacyNames = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FormTypeGuesserInterface|false|null
|
* @var FormTypeGuesserInterface|false|null
|
||||||
*/
|
*/
|
||||||
@ -84,12 +89,21 @@ class FormRegistry implements FormRegistryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$type) {
|
if (!$type) {
|
||||||
|
// Support fully-qualified class names
|
||||||
|
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
|
||||||
|
$type = new $name();
|
||||||
|
} else {
|
||||||
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
|
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->resolveAndAddType($type);
|
$this->resolveAndAddType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing types by their string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->types[$name];
|
return $this->types[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,27 +117,52 @@ class FormRegistry implements FormRegistryInterface
|
|||||||
*/
|
*/
|
||||||
private function resolveAndAddType(FormTypeInterface $type)
|
private function resolveAndAddType(FormTypeInterface $type)
|
||||||
{
|
{
|
||||||
|
$typeExtensions = array();
|
||||||
$parentType = $type->getParent();
|
$parentType = $type->getParent();
|
||||||
|
$fqcn = get_class($type);
|
||||||
|
$name = $type->getName();
|
||||||
|
$hasCustomName = $name !== $fqcn;
|
||||||
|
|
||||||
if ($parentType instanceof FormTypeInterface) {
|
if ($parentType instanceof FormTypeInterface) {
|
||||||
|
@trigger_error('Returning a FormTypeInterface from FormTypeInterface::getParent() is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->resolveAndAddType($parentType);
|
$this->resolveAndAddType($parentType);
|
||||||
$parentType = $parentType->getName();
|
$parentType = $parentType->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$typeExtensions = array();
|
if ($hasCustomName) {
|
||||||
|
foreach ($this->extensions as $extension) {
|
||||||
|
$typeExtensions = array_merge(
|
||||||
|
$typeExtensions,
|
||||||
|
$extension->getTypeExtensions($name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($typeExtensions) {
|
||||||
|
@trigger_error('Returning a type name from FormTypeExtensionInterface::getExtendedType() is deprecated since version 2.8 and will be removed in 3.0. Return the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->extensions as $extension) {
|
foreach ($this->extensions as $extension) {
|
||||||
$typeExtensions = array_merge(
|
$typeExtensions = array_merge(
|
||||||
$typeExtensions,
|
$typeExtensions,
|
||||||
$extension->getTypeExtensions($type->getName())
|
$extension->getTypeExtensions($fqcn)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->types[$type->getName()] = $this->resolvedTypeFactory->createResolvedType(
|
$resolvedType = $this->resolvedTypeFactory->createResolvedType(
|
||||||
$type,
|
$type,
|
||||||
$typeExtensions,
|
$typeExtensions,
|
||||||
$parentType ? $this->getType($parentType) : null
|
$parentType ? $this->getType($parentType) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->types[$fqcn] = $resolvedType;
|
||||||
|
|
||||||
|
if ($hasCustomName) {
|
||||||
|
// Enable access by the explicit type name until Symfony 3.0
|
||||||
|
$this->types[$name] = $resolvedType;
|
||||||
|
$this->legacyNames[$name] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +170,10 @@ class FormRegistry implements FormRegistryInterface
|
|||||||
*/
|
*/
|
||||||
public function hasType($name)
|
public function hasType($name)
|
||||||
{
|
{
|
||||||
|
if (isset($this->legacyNames[$name])) {
|
||||||
|
@trigger_error('Accessing types by their string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->types[$name])) {
|
if (isset($this->types[$name])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,12 @@ interface FormTypeInterface
|
|||||||
* is discouraged because it leads to a performance penalty. The support
|
* is discouraged because it leads to a performance penalty. The support
|
||||||
* for returning type instances may be dropped from future releases.
|
* for returning type instances may be dropped from future releases.
|
||||||
*
|
*
|
||||||
* @return string|null|FormTypeInterface The name of the parent type if any, null otherwise.
|
* Returning a {@link FormTypeInterface} instance is deprecated since
|
||||||
|
* Symfony 2.8 and will be unsupported as of Symfony 3.0. Return the
|
||||||
|
* fully-qualified class name of the parent type instead.
|
||||||
|
*
|
||||||
|
* @return string|null|FormTypeInterface The name of the parent type if any,
|
||||||
|
* null otherwise.
|
||||||
*/
|
*/
|
||||||
public function getParent();
|
public function getParent();
|
||||||
|
|
||||||
@ -94,6 +99,9 @@ interface FormTypeInterface
|
|||||||
* Returns the name of this type.
|
* Returns the name of this type.
|
||||||
*
|
*
|
||||||
* @return string The name of this type
|
* @return string The name of this type
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||||
|
* Use the fully-qualified class name of the type instead.
|
||||||
*/
|
*/
|
||||||
public function getName();
|
public function getName();
|
||||||
}
|
}
|
||||||
|
@ -38,15 +38,22 @@ class PreloadedExtension implements FormExtensionInterface
|
|||||||
/**
|
/**
|
||||||
* Creates a new preloaded extension.
|
* Creates a new preloaded extension.
|
||||||
*
|
*
|
||||||
* @param FormTypeInterface[] $types The types that the extension should support.
|
* @param FormTypeInterface[] $types The types that the extension should support
|
||||||
* @param array[FormTypeExtensionInterface[]] $typeExtensions The type extensions that the extension should support.
|
* @param FormTypeExtensionInterface[][] $typeExtensions The type extensions that the extension should support
|
||||||
* @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support.
|
* @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support
|
||||||
*/
|
*/
|
||||||
public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null)
|
public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null)
|
||||||
{
|
{
|
||||||
$this->types = $types;
|
|
||||||
$this->typeExtensions = $typeExtensions;
|
$this->typeExtensions = $typeExtensions;
|
||||||
$this->typeGuesser = $typeGuesser;
|
$this->typeGuesser = $typeGuesser;
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
// Up to Symfony 2.8, types were identified by their names
|
||||||
|
$this->types[$type->getName()] = $type;
|
||||||
|
|
||||||
|
// Since Symfony 2.8, types are identified by their FQCN
|
||||||
|
$this->types[get_class($type)] = $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form;
|
|||||||
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
use Symfony\Component\Form\Util\StringUtil;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,6 +24,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
*/
|
*/
|
||||||
class ResolvedFormType implements ResolvedFormTypeInterface
|
class ResolvedFormType implements ResolvedFormTypeInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $blockPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FormTypeInterface
|
* @var FormTypeInterface
|
||||||
*/
|
*/
|
||||||
@ -45,11 +56,40 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
|||||||
|
|
||||||
public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null)
|
public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null)
|
||||||
{
|
{
|
||||||
if (!preg_match('/^[a-z0-9_]*$/i', $innerType->getName())) {
|
$fqcn = get_class($innerType);
|
||||||
|
$name = $innerType->getName();
|
||||||
|
$hasCustomName = $name !== $fqcn;
|
||||||
|
|
||||||
|
if (method_exists($innerType, 'getBlockPrefix')) {
|
||||||
|
$reflector = new \ReflectionMethod($innerType, 'getName');
|
||||||
|
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';
|
||||||
|
|
||||||
|
$reflector = new \ReflectionMethod($innerType, 'getBlockPrefix');
|
||||||
|
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';
|
||||||
|
|
||||||
|
// Bundles compatible with both 2.3 and 2.8 should implement both methods
|
||||||
|
// Anyone else should only override getBlockPrefix() if they actually
|
||||||
|
// want to have a different block prefix than the default one
|
||||||
|
if ($isOldOverwritten && !$isNewOverwritten) {
|
||||||
|
@trigger_error(get_class($this->innerType).': The FormTypeInterface::getName() method is deprecated since version 2.8 and will be removed in 3.0. Remove it from your classes. Use getBlockPrefix() if you want to customize the template block prefix. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
$blockPrefix = $innerType->getBlockPrefix();
|
||||||
|
} else {
|
||||||
|
@trigger_error(get_class($this->innerType).': The FormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should extend AbstractType or add it to your implementation.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
// Deal with classes that don't extend AbstractType
|
||||||
|
// Calculate block prefix from the FQCN by default
|
||||||
|
$blockPrefix = $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// As of Symfony 2.8, getName() returns the FQCN by default
|
||||||
|
// Otherwise check that the name matches the old naming restrictions
|
||||||
|
if ($hasCustomName && !preg_match('/^[a-z0-9_]*$/i', $name)) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new InvalidArgumentException(sprintf(
|
||||||
'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".',
|
'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".',
|
||||||
get_class($innerType),
|
get_class($innerType),
|
||||||
$innerType->getName()
|
$name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +99,8 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->name = $name;
|
||||||
|
$this->blockPrefix = $blockPrefix;
|
||||||
$this->innerType = $innerType;
|
$this->innerType = $innerType;
|
||||||
$this->typeExtensions = $typeExtensions;
|
$this->typeExtensions = $typeExtensions;
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
@ -69,7 +111,17 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->innerType->getName();
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the prefix of the template block name for this type.
|
||||||
|
*
|
||||||
|
* @return string The prefix of the template block name
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return $this->blockPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
{
|
{
|
||||||
public function testLabelOnForm()
|
public function testLabelOnForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->renderWidget($view, array('label' => 'foo'));
|
$this->renderWidget($view, array('label' => 'foo'));
|
||||||
$html = $this->renderLabel($view);
|
$html = $this->renderLabel($view);
|
||||||
@ -32,7 +32,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelDoesNotRenderFieldAttributes()
|
public function testLabelDoesNotRenderFieldAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
'attr' => array(
|
'attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -49,7 +49,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelWithCustomAttributesPassedDirectly()
|
public function testLabelWithCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
'label_attr' => array(
|
'label_attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -66,7 +66,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
||||||
'label_attr' => array(
|
'label_attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -84,7 +84,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => 'Custom label',
|
'label' => 'Custom label',
|
||||||
));
|
));
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
@ -104,7 +104,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testErrors()
|
public function testErrors()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form->addError(new FormError('[trans]Error 1[/trans]'));
|
$form->addError(new FormError('[trans]Error 1[/trans]'));
|
||||||
$form->addError(new FormError('[trans]Error 2[/trans]'));
|
$form->addError(new FormError('[trans]Error 2[/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -137,7 +137,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
public function testOverrideWidgetBlock()
|
public function testOverrideWidgetBlock()
|
||||||
{
|
{
|
||||||
// see custom_widgets.html.twig
|
// see custom_widgets.html.twig
|
||||||
$form = $this->factory->createNamed('text_id', 'text');
|
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderWidget($form->createView());
|
$html = $this->renderWidget($form->createView());
|
||||||
|
|
||||||
$this->assertMatchesXpath($html,
|
$this->assertMatchesXpath($html,
|
||||||
@ -155,7 +155,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCheckedCheckbox()
|
public function testCheckedCheckbox()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', true);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
||||||
'/div
|
'/div
|
||||||
@ -173,7 +173,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testUncheckedCheckbox()
|
public function testUncheckedCheckbox()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', false);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
||||||
'/div
|
'/div
|
||||||
@ -191,7 +191,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCheckboxWithValue()
|
public function testCheckboxWithValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', false, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array(
|
||||||
'value' => 'foo&bar',
|
'value' => 'foo&bar',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoice()
|
public function testSingleChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -256,7 +256,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceAttributes()
|
public function testSingleChoiceAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -281,7 +281,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferred()
|
public function testSingleChoiceWithPreferred()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -305,7 +305,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferredAndNoSeparator()
|
public function testSingleChoiceWithPreferredAndNoSeparator()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -328,7 +328,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -352,7 +352,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testChoiceWithOnlyPreferred()
|
public function testChoiceWithOnlyPreferred()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&a', '&b'),
|
'preferred_choices' => array('&a', '&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -369,7 +369,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequired()
|
public function testSingleChoiceNonRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -393,7 +393,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequiredNoneSelected()
|
public function testSingleChoiceNonRequiredNoneSelected()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -417,7 +417,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequiredWithPlaceholder()
|
public function testSingleChoiceNonRequiredWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -442,7 +442,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceRequiredWithPlaceholder()
|
public function testSingleChoiceRequiredWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -467,7 +467,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -491,7 +491,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceGrouped()
|
public function testSingleChoiceGrouped()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'Group&2' => array('&c' => 'Choice&C'),
|
'Group&2' => array('&c' => 'Choice&C'),
|
||||||
@ -522,7 +522,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoice()
|
public function testMultipleChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -546,7 +546,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoiceAttributes()
|
public function testMultipleChoiceAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -573,7 +573,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoiceSkipsPlaceholder()
|
public function testMultipleChoiceSkipsPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -596,7 +596,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoiceNonRequired()
|
public function testMultipleChoiceNonRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -619,7 +619,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceExpanded()
|
public function testSingleChoiceExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -690,7 +690,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedAttributes()
|
public function testSingleChoiceExpandedAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -728,7 +728,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedWithPlaceholder()
|
public function testSingleChoiceExpandedWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -773,7 +773,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedWithBooleanValue()
|
public function testSingleChoiceExpandedWithBooleanValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', true, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array(
|
||||||
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -808,7 +808,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoiceExpanded()
|
public function testMultipleChoiceExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -899,7 +899,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMultipleChoiceExpandedAttributes()
|
public function testMultipleChoiceExpandedAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -947,7 +947,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCountry()
|
public function testCountry()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'country', 'AT');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/select
|
'/select
|
||||||
@ -961,7 +961,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCountryWithPlaceholder()
|
public function testCountryWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'country', 'AT', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', array(
|
||||||
'placeholder' => 'Select&Country',
|
'placeholder' => 'Select&Country',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -979,7 +979,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTime()
|
public function testDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
));
|
));
|
||||||
@ -1015,7 +1015,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTimeWithPlaceholderGlobal()
|
public function testDateTimeWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1055,7 +1055,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
{
|
{
|
||||||
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
||||||
|
|
||||||
$form = $this->factory->createNamed('name', 'datetime', $data, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array(
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -1092,7 +1092,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTimeWithSeconds()
|
public function testDateTimeWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -1133,7 +1133,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTimeSingleText()
|
public function testDateTimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'date_widget' => 'single_text',
|
'date_widget' => 'single_text',
|
||||||
'time_widget' => 'single_text',
|
'time_widget' => 'single_text',
|
||||||
@ -1162,7 +1162,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTimeWithWidgetSingleText()
|
public function testDateTimeWithWidgetSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
@ -1181,7 +1181,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
|
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
@ -1202,7 +1202,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateChoice()
|
public function testDateChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
@ -1231,7 +1231,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateChoiceWithPlaceholderGlobal()
|
public function testDateChoiceWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
@ -1262,7 +1262,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateChoiceWithPlaceholderOnYear()
|
public function testDateChoiceWithPlaceholderOnYear()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1293,7 +1293,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateText()
|
public function testDateText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
@ -1325,7 +1325,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDateSingleText()
|
public function testDateSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -1342,7 +1342,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testBirthDay()
|
public function testBirthDay()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1370,7 +1370,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testBirthDayWithPlaceholder()
|
public function testBirthDayWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1403,7 +1403,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testEmail()
|
public function testEmail()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'email', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1418,7 +1418,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testEmailWithMaxLength()
|
public function testEmailWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'email', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1435,7 +1435,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testHidden()
|
public function testHidden()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'hidden', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1452,7 +1452,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
*/
|
*/
|
||||||
public function testLegacyReadOnly()
|
public function testLegacyReadOnly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'read_only' => true,
|
'read_only' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1468,7 +1468,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testDisabled()
|
public function testDisabled()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1484,7 +1484,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testInteger()
|
public function testInteger()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'integer', 123);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1498,7 +1498,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLanguage()
|
public function testLanguage()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'language', 'de');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/select
|
'/select
|
||||||
@ -1512,7 +1512,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLocale()
|
public function testLocale()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'locale', 'de_AT');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/select
|
'/select
|
||||||
@ -1526,7 +1526,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testMoney()
|
public function testMoney()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'money', 1234.56, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array(
|
||||||
'currency' => 'EUR',
|
'currency' => 'EUR',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1550,7 +1550,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testNumber()
|
public function testNumber()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'number', 1234.56);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1564,7 +1564,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testPassword()
|
public function testPassword()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1577,7 +1577,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testPasswordSubmittedWithNotAlwaysEmpty()
|
public function testPasswordSubmittedWithNotAlwaysEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array(
|
||||||
'always_empty' => false,
|
'always_empty' => false,
|
||||||
));
|
));
|
||||||
$form->submit('foo&bar');
|
$form->submit('foo&bar');
|
||||||
@ -1594,7 +1594,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testPasswordWithMaxLength()
|
public function testPasswordWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1610,7 +1610,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testPercent()
|
public function testPercent()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'percent', 0.1);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
||||||
'/div
|
'/div
|
||||||
@ -1632,7 +1632,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCheckedRadio()
|
public function testCheckedRadio()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', true);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
||||||
'/div
|
'/div
|
||||||
@ -1656,7 +1656,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testUncheckedRadio()
|
public function testUncheckedRadio()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', false);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
|
||||||
'/div
|
'/div
|
||||||
@ -1679,7 +1679,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRadioWithValue()
|
public function testRadioWithValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', false, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array(
|
||||||
'value' => 'foo&bar',
|
'value' => 'foo&bar',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1704,7 +1704,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRange()
|
public function testRange()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5)));
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5)));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1719,7 +1719,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRangeWithMinMaxValues()
|
public function testRangeWithMinMaxValues()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5, 'max' => 57)));
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5, 'max' => 57)));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1735,7 +1735,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTextarea()
|
public function testTextarea()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', array(
|
||||||
'attr' => array('pattern' => 'foo'),
|
'attr' => array('pattern' => 'foo'),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1751,7 +1751,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testText()
|
public function testText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1766,7 +1766,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTextWithMaxLength()
|
public function testTextWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1783,7 +1783,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSearch()
|
public function testSearch()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'search', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -1798,7 +1798,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTime()
|
public function testTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
));
|
));
|
||||||
@ -1825,7 +1825,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimeWithSeconds()
|
public function testTimeWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -1860,7 +1860,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimeText()
|
public function testTimeText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
@ -1893,7 +1893,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimeSingleText()
|
public function testTimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -1911,7 +1911,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimeWithPlaceholderGlobal()
|
public function testTimeWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1938,7 +1938,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimeWithPlaceholderOnYear()
|
public function testTimeWithPlaceholderOnYear()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => array('hour' => 'Change&Me'),
|
'placeholder' => array('hour' => 'Change&Me'),
|
||||||
@ -1965,7 +1965,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimezone()
|
public function testTimezone()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/select
|
'/select
|
||||||
@ -1984,7 +1984,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testTimezoneWithPlaceholder()
|
public function testTimezoneWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'timezone', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, array(
|
||||||
'placeholder' => 'Select&Timezone',
|
'placeholder' => 'Select&Timezone',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -2002,7 +2002,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
public function testUrl()
|
public function testUrl()
|
||||||
{
|
{
|
||||||
$url = 'http://www.google.com?foo1=bar1&foo2=bar2';
|
$url = 'http://www.google.com?foo1=bar1&foo2=bar2';
|
||||||
$form = $this->factory->createNamed('name', 'url', $url);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/input
|
'/input
|
||||||
@ -2016,7 +2016,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testButton()
|
public function testButton()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'button');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/button[@type="button"][@name="name"][.="[trans]Name[/trans]"][@class="my&class btn"]'
|
'/button[@type="button"][@name="name"][.="[trans]Name[/trans]"][@class="my&class btn"]'
|
||||||
@ -2025,7 +2025,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSubmit()
|
public function testSubmit()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'submit');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/button[@type="submit"][@name="name"][@class="my&class btn"]'
|
'/button[@type="submit"][@name="name"][@class="my&class btn"]'
|
||||||
@ -2034,7 +2034,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testReset()
|
public function testReset()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'reset');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ResetType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
|
||||||
'/button[@type="reset"][@name="name"][@class="my&class btn"]'
|
'/button[@type="reset"][@name="name"][@class="my&class btn"]'
|
||||||
@ -2043,7 +2043,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetAttributes()
|
public function testWidgetAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
@ -2057,7 +2057,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetAttributeNameRepeatedIfTrue()
|
public function testWidgetAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2069,7 +2069,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testButtonAttributes()
|
public function testButtonAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('button', 'button', null, array(
|
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
));
|
));
|
||||||
@ -2082,7 +2082,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testButtonAttributeNameRepeatedIfTrue()
|
public function testButtonAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('button', 'button', null, array(
|
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
{
|
{
|
||||||
public function testRow()
|
public function testRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form->addError(new FormError('[trans]Error![/trans]'));
|
$form->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
@ -39,7 +39,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRowOverrideVariables()
|
public function testRowOverrideVariables()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamed('name', 'text')->createView();
|
$view = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType')->createView();
|
||||||
$html = $this->renderRow($view, array(
|
$html = $this->renderRow($view, array(
|
||||||
'attr' => array('class' => 'my&class'),
|
'attr' => array('class' => 'my&class'),
|
||||||
'label' => 'foo&bar',
|
'label' => 'foo&bar',
|
||||||
@ -58,7 +58,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeatedRow()
|
public function testRepeatedRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType');
|
||||||
$form->addError(new FormError('[trans]Error![/trans]'));
|
$form->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
@ -85,7 +85,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testButtonRow()
|
public function testButtonRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'button');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
|
|
||||||
@ -101,11 +101,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRest()
|
public function testRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'repeated')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType')
|
||||||
->add('field3', 'text')
|
->add('field3', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field4', 'text')
|
->add('field4', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -142,15 +142,15 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRestWithChildrenForms()
|
public function testRestWithChildrenForms()
|
||||||
{
|
{
|
||||||
$child1 = $this->factory->createNamedBuilder('child1', 'form')
|
$child1 = $this->factory->createNamedBuilder('child1', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text');
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
|
|
||||||
$child2 = $this->factory->createNamedBuilder('child2', 'form')
|
$child2 = $this->factory->createNamedBuilder('child2', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text');
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
|
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($child1)
|
->add($child1)
|
||||||
->add($child2)
|
->add($child2)
|
||||||
->getForm()
|
->getForm()
|
||||||
@ -200,9 +200,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRestAndRepeatedWithRow()
|
public function testRestAndRepeatedWithRow()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('first', 'text')
|
->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('password', 'repeated')
|
->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -226,9 +226,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRestAndRepeatedWithRowPerChild()
|
public function testRestAndRepeatedWithRowPerChild()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('first', 'text')
|
->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('password', 'repeated')
|
->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -254,9 +254,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRestAndRepeatedWithWidgetPerChild()
|
public function testRestAndRepeatedWithWidgetPerChild()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('first', 'text')
|
->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('password', 'repeated')
|
->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -284,8 +284,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCollection()
|
public function testCollection()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array(
|
$form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -306,8 +306,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
array('title' => 'a'),
|
array('title' => 'a'),
|
||||||
array('title' => 'b'),
|
array('title' => 'b'),
|
||||||
);
|
);
|
||||||
$form = $this->factory->createNamed('names', 'collection', $data, array(
|
$form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $data, array(
|
||||||
'type' => new AlternatingRowType(),
|
'type' => 'Symfony\Component\Form\Tests\Fixtures\AlternatingRowType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -324,8 +324,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testEmptyCollection()
|
public function testEmptyCollection()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('names', 'collection', array(), array(
|
$form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -340,12 +340,12 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
{
|
{
|
||||||
$collection = $this->factory->createNamedBuilder(
|
$collection = $this->factory->createNamedBuilder(
|
||||||
'collection',
|
'collection',
|
||||||
'collection',
|
'Symfony\Component\Form\Extension\Core\Type\CollectionType',
|
||||||
array('a', 'b'),
|
array('a', 'b'),
|
||||||
array('type' => 'text')
|
array('type' => 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
);
|
);
|
||||||
|
|
||||||
$form = $this->factory->createNamedBuilder('form', 'form')
|
$form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($collection)
|
->add($collection)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
@ -378,11 +378,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testForm()
|
public function testForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->setMethod('PUT')
|
->setMethod('PUT')
|
||||||
->setAction('http://example.com')
|
->setAction('http://example.com')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('lastName', 'text')
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
// include ampersands everywhere to validate escaping
|
// include ampersands everywhere to validate escaping
|
||||||
@ -422,9 +422,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormWidget()
|
public function testFormWidget()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('lastName', 'text')
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -450,10 +450,10 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
// https://github.com/symfony/symfony/issues/2308
|
// https://github.com/symfony/symfony/issues/2308
|
||||||
public function testNestedFormError()
|
public function testNestedFormError()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
->createNamedBuilder('child', 'form', null, array('error_bubbling' => false))
|
->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('error_bubbling' => false))
|
||||||
->add('grandChild', 'form')
|
->add('grandChild', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
)
|
)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
@ -476,11 +476,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
->method('getToken')
|
->method('getToken')
|
||||||
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
|
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
|
||||||
|
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
// No CSRF protection on nested forms
|
// No CSRF protection on nested forms
|
||||||
->createNamedBuilder('child', 'form')
|
->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory->createNamedBuilder('grandchild', 'text'))
|
->add($this->factory->createNamedBuilder('grandchild', 'Symfony\Component\Form\Extension\Core\Type\TextType'))
|
||||||
)
|
)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
@ -497,8 +497,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeated()
|
public function testRepeated()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated', 'foobar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -523,7 +523,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeatedWithCustomOptions()
|
public function testRepeatedWithCustomOptions()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
// the global required value cannot be overridden
|
// the global required value cannot be overridden
|
||||||
'first_options' => array('label' => 'Test', 'required' => false),
|
'first_options' => array('label' => 'Test', 'required' => false),
|
||||||
'second_options' => array('label' => 'Test2'),
|
'second_options' => array('label' => 'Test2'),
|
||||||
@ -551,8 +551,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testSearchInputName()
|
public function testSearchInputName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('full', 'form')
|
$form = $this->factory->createNamedBuilder('full', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('name', 'search')
|
->add('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -572,7 +572,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelHasNoId()
|
public function testLabelHasNoId()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderRow($form->createView());
|
$html = $this->renderRow($form->createView());
|
||||||
|
|
||||||
$this->assertMatchesXpath($html,
|
$this->assertMatchesXpath($html,
|
||||||
@ -587,7 +587,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelIsNotRenderedWhenSetToFalse()
|
public function testLabelIsNotRenderedWhenSetToFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => false,
|
'label' => false,
|
||||||
));
|
));
|
||||||
$html = $this->renderRow($form->createView());
|
$html = $this->renderRow($form->createView());
|
||||||
@ -608,7 +608,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
public function testThemeBlockInheritance($theme)
|
public function testThemeBlockInheritance($theme)
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('name', 'email')
|
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType')
|
||||||
->createView()
|
->createView()
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -625,11 +625,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
*/
|
*/
|
||||||
public function testThemeInheritance($parentTheme, $childTheme)
|
public function testThemeInheritance($parentTheme, $childTheme)
|
||||||
{
|
{
|
||||||
$child = $this->factory->createNamedBuilder('child', 'form')
|
$child = $this->factory->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field', 'text');
|
->add('field', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
|
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field', 'text')
|
->add('field', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add($child)
|
->add($child)
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView()
|
->createView()
|
||||||
@ -671,7 +671,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
public function testCollectionRowWithCustomBlock()
|
public function testCollectionRowWithCustomBlock()
|
||||||
{
|
{
|
||||||
$collection = array('one', 'two', 'three');
|
$collection = array('one', 'two', 'three');
|
||||||
$form = $this->factory->createNamedBuilder('names', 'collection', $collection)
|
$form = $this->factory->createNamedBuilder('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $collection)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -691,7 +691,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
*/
|
*/
|
||||||
public function testChoiceRowWithCustomBlock()
|
public function testChoiceRowWithCustomBlock()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name_c', 'choice', 'a', array(
|
$form = $this->factory->createNamedBuilder('name_c', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', 'a', array(
|
||||||
'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'),
|
'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'),
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
))
|
))
|
||||||
@ -709,9 +709,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormEndWithRest()
|
public function testFormEndWithRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -739,9 +739,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormEndWithoutRest()
|
public function testFormEndWithoutRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -755,11 +755,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetContainerAttributes()
|
public function testWidgetContainerAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('form', 'form', null, array(
|
$form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('text', 'text');
|
$form->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
|
|
||||||
$html = $this->renderWidget($form->createView());
|
$html = $this->renderWidget($form->createView());
|
||||||
|
|
||||||
@ -769,7 +769,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetContainerAttributeNameRepeatedIfTrue()
|
public function testWidgetContainerAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('form', 'form', null, array(
|
$form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ class AbstractExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testHasType()
|
public function testHasType()
|
||||||
{
|
{
|
||||||
$loader = new ConcreteExtension();
|
$loader = new ConcreteExtension();
|
||||||
$this->assertTrue($loader->hasType('foo'));
|
$this->assertTrue($loader->hasType('Symfony\Component\Form\Tests\Fixtures\FooType'));
|
||||||
$this->assertFalse($loader->hasType('bar'));
|
$this->assertFalse($loader->hasType('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetType()
|
public function testGetType()
|
||||||
{
|
{
|
||||||
$loader = new ConcreteExtension();
|
$loader = new ConcreteExtension();
|
||||||
$this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('foo'));
|
$this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +35,7 @@ class AbstractExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCustomOptionsResolver()
|
public function testCustomOptionsResolver()
|
||||||
{
|
{
|
||||||
$extension = new Fixtures\FooTypeBarExtension();
|
$extension = new Fixtures\LegacyFooTypeBarExtension();
|
||||||
$resolver = new Fixtures\CustomOptionsResolver();
|
$resolver = new Fixtures\CustomOptionsResolver();
|
||||||
$extension->setDefaultOptions($resolver);
|
$extension->setDefaultOptions($resolver);
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
*/
|
*/
|
||||||
public function testEnctype()
|
public function testEnctype()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('file', 'file')
|
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView()));
|
$this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView()));
|
||||||
@ -146,8 +146,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
*/
|
*/
|
||||||
public function testNoEnctype()
|
public function testNoEnctype()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('text', 'text')
|
->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertEquals('', $this->renderEnctype($form->createView()));
|
$this->assertEquals('', $this->renderEnctype($form->createView()));
|
||||||
@ -155,7 +155,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabel()
|
public function testLabel()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->renderWidget($view, array('label' => 'foo'));
|
$this->renderWidget($view, array('label' => 'foo'));
|
||||||
$html = $this->renderLabel($view);
|
$html = $this->renderLabel($view);
|
||||||
@ -184,7 +184,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelOnForm()
|
public function testLabelOnForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->renderWidget($view, array('label' => 'foo'));
|
$this->renderWidget($view, array('label' => 'foo'));
|
||||||
$html = $this->renderLabel($view);
|
$html = $this->renderLabel($view);
|
||||||
@ -199,7 +199,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelWithCustomTextPassedAsOption()
|
public function testLabelWithCustomTextPassedAsOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => 'Custom label',
|
'label' => 'Custom label',
|
||||||
));
|
));
|
||||||
$html = $this->renderLabel($form->createView());
|
$html = $this->renderLabel($form->createView());
|
||||||
@ -214,7 +214,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelWithCustomTextPassedDirectly()
|
public function testLabelWithCustomTextPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), 'Custom label');
|
$html = $this->renderLabel($form->createView(), 'Custom label');
|
||||||
|
|
||||||
$this->assertMatchesXpath($html,
|
$this->assertMatchesXpath($html,
|
||||||
@ -227,7 +227,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelWithCustomTextPassedAsOptionAndDirectly()
|
public function testLabelWithCustomTextPassedAsOptionAndDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => 'Custom label',
|
'label' => 'Custom label',
|
||||||
));
|
));
|
||||||
$html = $this->renderLabel($form->createView(), 'Overridden label');
|
$html = $this->renderLabel($form->createView(), 'Overridden label');
|
||||||
@ -242,7 +242,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelDoesNotRenderFieldAttributes()
|
public function testLabelDoesNotRenderFieldAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
'attr' => array(
|
'attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -259,7 +259,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelWithCustomAttributesPassedDirectly()
|
public function testLabelWithCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
'label_attr' => array(
|
'label_attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -276,7 +276,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
||||||
'label_attr' => array(
|
'label_attr' => array(
|
||||||
'class' => 'my&class',
|
'class' => 'my&class',
|
||||||
@ -295,7 +295,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
// https://github.com/symfony/symfony/issues/5029
|
// https://github.com/symfony/symfony/issues/5029
|
||||||
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => 'Custom label',
|
'label' => 'Custom label',
|
||||||
));
|
));
|
||||||
$html = $this->renderLabel($form->createView(), null, array(
|
$html = $this->renderLabel($form->createView(), null, array(
|
||||||
@ -316,7 +316,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testLabelFormatName()
|
public function testLabelFormatName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('myform')
|
$form = $this->factory->createNamedBuilder('myform')
|
||||||
->add('myfield', 'text')
|
->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('myfield')->createView();
|
$view = $form->get('myfield')->createView();
|
||||||
$html = $this->renderLabel($view, null, array('label_format' => 'form.%name%'));
|
$html = $this->renderLabel($view, null, array('label_format' => 'form.%name%'));
|
||||||
@ -332,7 +332,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testLabelFormatId()
|
public function testLabelFormatId()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('myform')
|
$form = $this->factory->createNamedBuilder('myform')
|
||||||
->add('myfield', 'text')
|
->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('myfield')->createView();
|
$view = $form->get('myfield')->createView();
|
||||||
$html = $this->renderLabel($view, null, array('label_format' => 'form.%id%'));
|
$html = $this->renderLabel($view, null, array('label_format' => 'form.%id%'));
|
||||||
@ -349,8 +349,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
{
|
{
|
||||||
$options = array('label_format' => 'form.%name%');
|
$options = array('label_format' => 'form.%name%');
|
||||||
|
|
||||||
$form = $this->factory->createNamedBuilder('myform', 'form', null, $options)
|
$form = $this->factory->createNamedBuilder('myform', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, $options)
|
||||||
->add('myfield', 'text')
|
->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('myfield')->createView();
|
$view = $form->get('myfield')->createView();
|
||||||
$html = $this->renderLabel($view);
|
$html = $this->renderLabel($view);
|
||||||
@ -367,8 +367,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
{
|
{
|
||||||
$options = array('label_format' => 'form.%name%');
|
$options = array('label_format' => 'form.%name%');
|
||||||
|
|
||||||
$form = $this->factory->createNamedBuilder('myform', 'form', null, $options)
|
$form = $this->factory->createNamedBuilder('myform', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, $options)
|
||||||
->add('myfield', 'text', array('label_format' => 'field.%name%'))
|
->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('label_format' => 'field.%name%'))
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('myfield')->createView();
|
$view = $form->get('myfield')->createView();
|
||||||
$html = $this->renderLabel($view);
|
$html = $this->renderLabel($view);
|
||||||
@ -384,7 +384,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testLabelFormatOnButton()
|
public function testLabelFormatOnButton()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('myform')
|
$form = $this->factory->createNamedBuilder('myform')
|
||||||
->add('mybutton', 'button')
|
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('mybutton')->createView();
|
$view = $form->get('mybutton')->createView();
|
||||||
$html = $this->renderWidget($view, array('label_format' => 'form.%name%'));
|
$html = $this->renderWidget($view, array('label_format' => 'form.%name%'));
|
||||||
@ -401,7 +401,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testLabelFormatOnButtonId()
|
public function testLabelFormatOnButtonId()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('myform')
|
$form = $this->factory->createNamedBuilder('myform')
|
||||||
->add('mybutton', 'button')
|
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$view = $form->get('mybutton')->createView();
|
$view = $form->get('mybutton')->createView();
|
||||||
$html = $this->renderWidget($view, array('label_format' => 'form.%id%'));
|
$html = $this->renderWidget($view, array('label_format' => 'form.%id%'));
|
||||||
@ -417,7 +417,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testErrors()
|
public function testErrors()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form->addError(new FormError('[trans]Error 1[/trans]'));
|
$form->addError(new FormError('[trans]Error 1[/trans]'));
|
||||||
$form->addError(new FormError('[trans]Error 2[/trans]'));
|
$form->addError(new FormError('[trans]Error 2[/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -437,7 +437,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testOverrideWidgetBlock()
|
public function testOverrideWidgetBlock()
|
||||||
{
|
{
|
||||||
// see custom_widgets.html.twig
|
// see custom_widgets.html.twig
|
||||||
$form = $this->factory->createNamed('text_id', 'text');
|
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$html = $this->renderWidget($form->createView());
|
$html = $this->renderWidget($form->createView());
|
||||||
|
|
||||||
$this->assertMatchesXpath($html,
|
$this->assertMatchesXpath($html,
|
||||||
@ -454,7 +454,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCheckedCheckbox()
|
public function testCheckedCheckbox()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', true);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -468,7 +468,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testUncheckedCheckbox()
|
public function testUncheckedCheckbox()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', false);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -481,7 +481,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCheckboxWithValue()
|
public function testCheckboxWithValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'checkbox', false, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array(
|
||||||
'value' => 'foo&bar',
|
'value' => 'foo&bar',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoice()
|
public function testSingleChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -551,7 +551,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceAttributes()
|
public function testSingleChoiceAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -575,7 +575,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferred()
|
public function testSingleChoiceWithPreferred()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -598,7 +598,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferredAndNoSeparator()
|
public function testSingleChoiceWithPreferredAndNoSeparator()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -620,7 +620,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&b'),
|
'preferred_choices' => array('&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -643,7 +643,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testChoiceWithOnlyPreferred()
|
public function testChoiceWithOnlyPreferred()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'preferred_choices' => array('&a', '&b'),
|
'preferred_choices' => array('&a', '&b'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -659,7 +659,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequired()
|
public function testSingleChoiceNonRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -682,7 +682,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequiredNoneSelected()
|
public function testSingleChoiceNonRequiredNoneSelected()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -705,7 +705,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceNonRequiredWithPlaceholder()
|
public function testSingleChoiceNonRequiredWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -729,7 +729,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceRequiredWithPlaceholder()
|
public function testSingleChoiceRequiredWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -756,7 +756,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -782,7 +782,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceGrouped()
|
public function testSingleChoiceGrouped()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'Group&2' => array('&c' => 'Choice&C'),
|
'Group&2' => array('&c' => 'Choice&C'),
|
||||||
@ -812,7 +812,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoice()
|
public function testMultipleChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -835,7 +835,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoiceAttributes()
|
public function testMultipleChoiceAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -861,7 +861,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoiceSkipsPlaceholder()
|
public function testMultipleChoiceSkipsPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@ -883,7 +883,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoiceNonRequired()
|
public function testMultipleChoiceNonRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -905,7 +905,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceExpanded()
|
public function testSingleChoiceExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -950,7 +950,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedAttributes()
|
public function testSingleChoiceExpandedAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@ -975,7 +975,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedWithPlaceholder()
|
public function testSingleChoiceExpandedWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -1000,7 +1000,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSingleChoiceExpandedWithBooleanValue()
|
public function testSingleChoiceExpandedWithBooleanValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', true, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array(
|
||||||
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -1022,7 +1022,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoiceExpanded()
|
public function testMultipleChoiceExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
@ -1073,7 +1073,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMultipleChoiceExpandedAttributes()
|
public function testMultipleChoiceExpandedAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@ -1101,7 +1101,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCountry()
|
public function testCountry()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'country', 'AT');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/select
|
'/select
|
||||||
@ -1114,7 +1114,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCountryWithPlaceholder()
|
public function testCountryWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'country', 'AT', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', array(
|
||||||
'placeholder' => 'Select&Country',
|
'placeholder' => 'Select&Country',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -1131,7 +1131,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTime()
|
public function testDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
));
|
));
|
||||||
@ -1170,7 +1170,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTimeWithPlaceholderGlobal()
|
public function testDateTimeWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1212,7 +1212,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
{
|
{
|
||||||
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
||||||
|
|
||||||
$form = $this->factory->createNamed('name', 'datetime', $data, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array(
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -1251,7 +1251,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTimeWithSeconds()
|
public function testDateTimeWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -1293,7 +1293,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTimeSingleText()
|
public function testDateTimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'date_widget' => 'single_text',
|
'date_widget' => 'single_text',
|
||||||
'time_widget' => 'single_text',
|
'time_widget' => 'single_text',
|
||||||
@ -1319,7 +1319,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTimeWithWidgetSingleText()
|
public function testDateTimeWithWidgetSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
@ -1337,7 +1337,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
|
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
@ -1357,7 +1357,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateChoice()
|
public function testDateChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
@ -1382,7 +1382,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateChoiceWithPlaceholderGlobal()
|
public function testDateChoiceWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
@ -1409,7 +1409,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateChoiceWithPlaceholderOnYear()
|
public function testDateChoiceWithPlaceholderOnYear()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1436,7 +1436,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateText()
|
public function testDateText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
@ -1464,7 +1464,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateSingleText()
|
public function testDateSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -1480,8 +1480,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDateErrorBubbling()
|
public function testDateErrorBubbling()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('form', 'form')
|
$form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('date', 'date')
|
->add('date', 'Symfony\Component\Form\Extension\Core\Type\DateType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$form->get('date')->addError(new FormError('[trans]Error![/trans]'));
|
$form->get('date')->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -1492,7 +1492,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testBirthDay()
|
public function testBirthDay()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1516,7 +1516,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testBirthDayWithPlaceholder()
|
public function testBirthDayWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -1545,7 +1545,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testEmail()
|
public function testEmail()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'email', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1559,7 +1559,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testEmailWithMaxLength()
|
public function testEmailWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'email', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1575,7 +1575,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testFile()
|
public function testFile()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'file');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FileType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1586,7 +1586,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testHidden()
|
public function testHidden()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'hidden', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1602,7 +1602,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
*/
|
*/
|
||||||
public function testLegacyReadOnly()
|
public function testLegacyReadOnly()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'read_only' => true,
|
'read_only' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1617,7 +1617,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testDisabled()
|
public function testDisabled()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1632,7 +1632,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testInteger()
|
public function testInteger()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'integer', 123);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1645,7 +1645,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLanguage()
|
public function testLanguage()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'language', 'de');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/select
|
'/select
|
||||||
@ -1658,7 +1658,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testLocale()
|
public function testLocale()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'locale', 'de_AT');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/select
|
'/select
|
||||||
@ -1671,7 +1671,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testMoney()
|
public function testMoney()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'money', 1234.56, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array(
|
||||||
'currency' => 'EUR',
|
'currency' => 'EUR',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1687,7 +1687,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testNumber()
|
public function testNumber()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'number', 1234.56);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1700,7 +1700,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testPassword()
|
public function testPassword()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1712,7 +1712,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testPasswordSubmittedWithNotAlwaysEmpty()
|
public function testPasswordSubmittedWithNotAlwaysEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array(
|
||||||
'always_empty' => false,
|
'always_empty' => false,
|
||||||
));
|
));
|
||||||
$form->submit('foo&bar');
|
$form->submit('foo&bar');
|
||||||
@ -1728,7 +1728,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testPasswordWithMaxLength()
|
public function testPasswordWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'password', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1743,7 +1743,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testPercent()
|
public function testPercent()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'percent', 0.1);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1757,7 +1757,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCheckedRadio()
|
public function testCheckedRadio()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', true);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1771,7 +1771,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testUncheckedRadio()
|
public function testUncheckedRadio()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', false);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1784,7 +1784,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testRadioWithValue()
|
public function testRadioWithValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'radio', false, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array(
|
||||||
'value' => 'foo&bar',
|
'value' => 'foo&bar',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1799,7 +1799,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testRange()
|
public function testRange()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5)));
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5)));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1813,7 +1813,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testRangeWithMinMaxValues()
|
public function testRangeWithMinMaxValues()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5, 'max' => 57)));
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5, 'max' => 57)));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1828,7 +1828,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTextarea()
|
public function testTextarea()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', array(
|
||||||
'attr' => array('pattern' => 'foo'),
|
'attr' => array('pattern' => 'foo'),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1843,7 +1843,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testText()
|
public function testText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1857,7 +1857,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTextWithMaxLength()
|
public function testTextWithMaxLength()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', 'foo&bar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', array(
|
||||||
'attr' => array('maxlength' => 123),
|
'attr' => array('maxlength' => 123),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1873,7 +1873,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testSearch()
|
public function testSearch()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'search', 'foo&bar');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -1887,7 +1887,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTime()
|
public function testTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
));
|
));
|
||||||
@ -1911,7 +1911,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeWithSeconds()
|
public function testTimeWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -1942,7 +1942,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeText()
|
public function testTimeText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
@ -1972,7 +1972,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeSingleText()
|
public function testTimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -1989,7 +1989,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeWithPlaceholderGlobal()
|
public function testTimeWithPlaceholderGlobal()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'placeholder' => 'Change&Me',
|
'placeholder' => 'Change&Me',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -2014,7 +2014,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeWithPlaceholderOnYear()
|
public function testTimeWithPlaceholderOnYear()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'time', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => array('hour' => 'Change&Me'),
|
'placeholder' => array('hour' => 'Change&Me'),
|
||||||
@ -2039,8 +2039,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimeErrorBubbling()
|
public function testTimeErrorBubbling()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('form', 'form')
|
$form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('time', 'time')
|
->add('time', 'Symfony\Component\Form\Extension\Core\Type\TimeType')
|
||||||
->getForm();
|
->getForm();
|
||||||
$form->get('time')->addError(new FormError('[trans]Error![/trans]'));
|
$form->get('time')->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -2051,7 +2051,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimezone()
|
public function testTimezone()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/select
|
'/select
|
||||||
@ -2069,7 +2069,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTimezoneWithPlaceholder()
|
public function testTimezoneWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'timezone', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, array(
|
||||||
'placeholder' => 'Select&Timezone',
|
'placeholder' => 'Select&Timezone',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -2086,7 +2086,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
public function testUrl()
|
public function testUrl()
|
||||||
{
|
{
|
||||||
$url = 'http://www.google.com?foo1=bar1&foo2=bar2';
|
$url = 'http://www.google.com?foo1=bar1&foo2=bar2';
|
||||||
$form = $this->factory->createNamed('name', 'url', $url);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url);
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/input
|
'/input
|
||||||
@ -2099,8 +2099,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testCollectionPrototype()
|
public function testCollectionPrototype()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three')))
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('items' => array('one', 'two', 'three')))
|
||||||
->add('items', 'collection', array('allow_add' => true))
|
->add('items', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('allow_add' => true))
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -2115,8 +2115,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testEmptyRootFormName()
|
public function testEmptyRootFormName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('', 'form')
|
$form = $this->factory->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'text')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertMatchesXpath($this->renderWidget($form->createView()),
|
$this->assertMatchesXpath($this->renderWidget($form->createView()),
|
||||||
@ -2127,7 +2127,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testButton()
|
public function testButton()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'button');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]'
|
'/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]'
|
||||||
@ -2136,14 +2136,14 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testButtonLabelIsEmpty()
|
public function testButtonLabelIsEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'button');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType');
|
||||||
|
|
||||||
$this->assertSame('', $this->renderLabel($form->createView()));
|
$this->assertSame('', $this->renderLabel($form->createView()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmit()
|
public function testSubmit()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'submit');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/button[@type="submit"][@name="name"]'
|
'/button[@type="submit"][@name="name"]'
|
||||||
@ -2152,7 +2152,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testReset()
|
public function testReset()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'reset');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ResetType');
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
'/button[@type="reset"][@name="name"]'
|
'/button[@type="reset"][@name="name"]'
|
||||||
@ -2161,7 +2161,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testStartTag()
|
public function testStartTag()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'method' => 'get',
|
'method' => 'get',
|
||||||
'action' => 'http://example.com/directory',
|
'action' => 'http://example.com/directory',
|
||||||
));
|
));
|
||||||
@ -2173,7 +2173,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testStartTagForPutRequest()
|
public function testStartTagForPutRequest()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'method' => 'put',
|
'method' => 'put',
|
||||||
'action' => 'http://example.com/directory',
|
'action' => 'http://example.com/directory',
|
||||||
));
|
));
|
||||||
@ -2190,7 +2190,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testStartTagWithOverriddenVars()
|
public function testStartTagWithOverriddenVars()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'method' => 'put',
|
'method' => 'put',
|
||||||
'action' => 'http://example.com/directory',
|
'action' => 'http://example.com/directory',
|
||||||
));
|
));
|
||||||
@ -2205,11 +2205,11 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testStartTagForMultipartForm()
|
public function testStartTagForMultipartForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form', null, array(
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'method' => 'get',
|
'method' => 'get',
|
||||||
'action' => 'http://example.com/directory',
|
'action' => 'http://example.com/directory',
|
||||||
))
|
))
|
||||||
->add('file', 'file')
|
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$html = $this->renderStart($form->createView());
|
$html = $this->renderStart($form->createView());
|
||||||
@ -2219,7 +2219,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testStartTagWithExtraAttributes()
|
public function testStartTagWithExtraAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'method' => 'get',
|
'method' => 'get',
|
||||||
'action' => 'http://example.com/directory',
|
'action' => 'http://example.com/directory',
|
||||||
));
|
));
|
||||||
@ -2233,7 +2233,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testWidgetAttributes()
|
public function testWidgetAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
@ -2247,7 +2247,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testWidgetAttributeNameRepeatedIfTrue()
|
public function testWidgetAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2259,7 +2259,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testWidgetAttributeHiddenIfFalse()
|
public function testWidgetAttributeHiddenIfFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array(
|
||||||
'attr' => array('foo' => false),
|
'attr' => array('foo' => false),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2270,7 +2270,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testButtonAttributes()
|
public function testButtonAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('button', 'button', null, array(
|
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
));
|
));
|
||||||
@ -2283,7 +2283,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testButtonAttributeNameRepeatedIfTrue()
|
public function testButtonAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('button', 'button', null, array(
|
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2295,7 +2295,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testButtonAttributeHiddenIfFalse()
|
public function testButtonAttributeHiddenIfFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('button', 'button', null, array(
|
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
|
||||||
'attr' => array('foo' => false),
|
'attr' => array('foo' => false),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2306,7 +2306,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTextareaWithWhitespaceOnlyContentRetainsValue()
|
public function testTextareaWithWhitespaceOnlyContentRetainsValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('textarea', 'textarea', ' ');
|
$form = $this->factory->createNamed('textarea', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', ' ');
|
||||||
|
|
||||||
$html = $this->renderWidget($form->createView());
|
$html = $this->renderWidget($form->createView());
|
||||||
|
|
||||||
@ -2315,8 +2315,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTextareaWithWhitespaceOnlyContentRetainsValueWhenRenderingForm()
|
public function testTextareaWithWhitespaceOnlyContentRetainsValueWhenRenderingForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form', array('textarea' => ' '))
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array('textarea' => ' '))
|
||||||
->add('textarea', 'textarea')
|
->add('textarea', 'Symfony\Component\Form\Extension\Core\Type\TextareaType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$html = $this->renderForm($form->createView());
|
$html = $this->renderForm($form->createView());
|
||||||
@ -2326,7 +2326,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testWidgetContainerAttributeHiddenIfFalse()
|
public function testWidgetContainerAttributeHiddenIfFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('form', 'form', null, array(
|
$form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'attr' => array('foo' => false),
|
'attr' => array('foo' => false),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -2338,9 +2338,9 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
|
|
||||||
public function testTranslatedAttributes()
|
public function testTranslatedAttributes()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('firstName', 'text', array('attr' => array('title' => 'Foo')))
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('title' => 'Foo')))
|
||||||
->add('lastName', 'text', array('attr' => array('placeholder' => 'Bar')))
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('placeholder' => 'Bar')))
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue($iniMax));
|
->will($this->returnValue($iniMax));
|
||||||
|
|
||||||
$options = array('post_max_size_message' => 'Max {{ max }}!');
|
$options = array('post_max_size_message' => 'Max {{ max }}!');
|
||||||
$form = $this->factory->createNamed('name', 'text', null, $options);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);
|
||||||
$this->setRequestData('POST', array(), array());
|
$this->setRequestData('POST', array(), array());
|
||||||
|
|
||||||
$this->requestHandler->handleRequest($form, $this->request);
|
$this->requestHandler->handleRequest($form, $this->request);
|
||||||
|
@ -18,7 +18,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
{
|
{
|
||||||
public function testRow()
|
public function testRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form->addError(new FormError('[trans]Error![/trans]'));
|
$form->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
@ -42,7 +42,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testLabelIsNotRenderedWhenSetToFalse()
|
public function testLabelIsNotRenderedWhenSetToFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'text', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||||
'label' => false,
|
'label' => false,
|
||||||
));
|
));
|
||||||
$html = $this->renderRow($form->createView());
|
$html = $this->renderRow($form->createView());
|
||||||
@ -61,7 +61,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeatedRow()
|
public function testRepeatedRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType');
|
||||||
$html = $this->renderRow($form->createView());
|
$html = $this->renderRow($form->createView());
|
||||||
|
|
||||||
$this->assertMatchesXpath($html,
|
$this->assertMatchesXpath($html,
|
||||||
@ -91,7 +91,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeatedRowWithErrors()
|
public function testRepeatedRowWithErrors()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType');
|
||||||
$form->addError(new FormError('[trans]Error![/trans]'));
|
$form->addError(new FormError('[trans]Error![/trans]'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
@ -128,7 +128,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testButtonRow()
|
public function testButtonRow()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'button');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$html = $this->renderRow($view);
|
$html = $this->renderRow($view);
|
||||||
|
|
||||||
@ -147,11 +147,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRest()
|
public function testRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'repeated')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType')
|
||||||
->add('field3', 'text')
|
->add('field3', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field4', 'text')
|
->add('field4', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -194,8 +194,8 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testCollection()
|
public function testCollection()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array(
|
$form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -212,8 +212,8 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testEmptyCollection()
|
public function testEmptyCollection()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('names', 'collection', array(), array(
|
$form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -226,11 +226,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testForm()
|
public function testForm()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->setMethod('PUT')
|
->setMethod('PUT')
|
||||||
->setAction('http://example.com')
|
->setAction('http://example.com')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('lastName', 'text')
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -278,9 +278,9 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormWidget()
|
public function testFormWidget()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('lastName', 'text')
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -315,10 +315,10 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
// https://github.com/symfony/symfony/issues/2308
|
// https://github.com/symfony/symfony/issues/2308
|
||||||
public function testNestedFormError()
|
public function testNestedFormError()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
->createNamedBuilder('child', 'form', null, array('error_bubbling' => false))
|
->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('error_bubbling' => false))
|
||||||
->add('grandChild', 'form')
|
->add('grandChild', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
)
|
)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
@ -341,11 +341,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
->method('getToken')
|
->method('getToken')
|
||||||
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
|
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
|
||||||
|
|
||||||
$form = $this->factory->createNamedBuilder('name', 'form')
|
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
// No CSRF protection on nested forms
|
// No CSRF protection on nested forms
|
||||||
->createNamedBuilder('child', 'form')
|
->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory->createNamedBuilder('grandchild', 'text'))
|
->add($this->factory->createNamedBuilder('grandchild', 'Symfony\Component\Form\Extension\Core\Type\TextType'))
|
||||||
)
|
)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
@ -365,8 +365,8 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeated()
|
public function testRepeated()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated', 'foobar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -399,8 +399,8 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testRepeatedWithCustomOptions()
|
public function testRepeatedWithCustomOptions()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'repeated', 'foobar', array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array(
|
||||||
'type' => 'password',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\PasswordType',
|
||||||
'first_options' => array('label' => 'Test', 'required' => false),
|
'first_options' => array('label' => 'Test', 'required' => false),
|
||||||
'second_options' => array('label' => 'Test2'),
|
'second_options' => array('label' => 'Test2'),
|
||||||
));
|
));
|
||||||
@ -440,7 +440,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
public function testCollectionRowWithCustomBlock()
|
public function testCollectionRowWithCustomBlock()
|
||||||
{
|
{
|
||||||
$collection = array('one', 'two', 'three');
|
$collection = array('one', 'two', 'three');
|
||||||
$form = $this->factory->createNamedBuilder('names', 'collection', $collection)
|
$form = $this->factory->createNamedBuilder('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $collection)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
@ -456,9 +456,9 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormEndWithRest()
|
public function testFormEndWithRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -494,9 +494,9 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testFormEndWithoutRest()
|
public function testFormEndWithoutRest()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
$view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('field1', 'text')
|
->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('field2', 'text')
|
->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -510,11 +510,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetContainerAttributes()
|
public function testWidgetContainerAttributes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('form', 'form', null, array(
|
$form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('text', 'text');
|
$form->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
|
|
||||||
$html = $this->renderWidget($form->createView());
|
$html = $this->renderWidget($form->createView());
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
|
|
||||||
public function testWidgetContainerAttributeNameRepeatedIfTrue()
|
public function testWidgetContainerAttributeNameRepeatedIfTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('form', 'form', null, array(
|
$form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'attr' => array('foo' => true),
|
'attr' => array('foo' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -26,16 +26,16 @@ class CompoundFormPerformanceTest extends \Symfony\Component\Form\Test\FormPerfo
|
|||||||
$this->setMaxRunningTime(1);
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
for ($i = 0; $i < 40; ++$i) {
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
$form = $this->factory->createBuilder('form')
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('lastName', 'text')
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('gender', 'choice', array(
|
->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
|
||||||
'choices' => array('male' => 'Male', 'female' => 'Female'),
|
'choices' => array('male' => 'Male', 'female' => 'Female'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
))
|
))
|
||||||
->add('age', 'number')
|
->add('age', 'Symfony\Component\Form\Extension\Core\Type\NumberType')
|
||||||
->add('birthDate', 'birthday')
|
->add('birthDate', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType')
|
||||||
->add('city', 'choice', array(
|
->add('city', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
|
||||||
// simulate 300 different cities
|
// simulate 300 different cities
|
||||||
'choices' => range(1, 300),
|
'choices' => range(1, 300),
|
||||||
))
|
))
|
||||||
|
@ -110,7 +110,7 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
$factory = Forms::createFormFactoryBuilder()
|
$factory = Forms::createFormFactoryBuilder()
|
||||||
->getFormFactory();
|
->getFormFactory();
|
||||||
|
|
||||||
$child = $factory->create('file', null, array('auto_initialize' => false));
|
$child = $factory->createNamed('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', null, array('auto_initialize' => false));
|
||||||
|
|
||||||
$this->form->add($child);
|
$this->form->add($child);
|
||||||
$this->form->submit(array('file' => null), false);
|
$this->form->submit(array('file' => null), false);
|
||||||
|
@ -45,7 +45,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassIdAndNameToViewWithParent()
|
public function testPassIdAndNameToViewWithParent()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', $this->getTestedType())
|
->add('child', $this->getTestedType())
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
@ -57,8 +57,8 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassIdAndNameToViewWithGrandParent()
|
public function testPassIdAndNameToViewWithGrandParent()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createNamedBuilder('parent', 'form')
|
$builder = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'form');
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$builder->get('child')->add('grand_child', $this->getTestedType());
|
$builder->get('child')->add('grand_child', $this->getTestedType());
|
||||||
$view = $builder->getForm()->createView();
|
$view = $builder->getForm()->createView();
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testInheritTranslationDomainFromParent()
|
public function testInheritTranslationDomainFromParent()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamedBuilder('parent', 'form', null, array(
|
->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'translation_domain' => 'domain',
|
'translation_domain' => 'domain',
|
||||||
))
|
))
|
||||||
->add('child', $this->getTestedType())
|
->add('child', $this->getTestedType())
|
||||||
@ -93,7 +93,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testPreferOwnTranslationDomain()
|
public function testPreferOwnTranslationDomain()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamedBuilder('parent', 'form', null, array(
|
->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'translation_domain' => 'parent_domain',
|
'translation_domain' => 'parent_domain',
|
||||||
))
|
))
|
||||||
->add('child', $this->getTestedType(), array(
|
->add('child', $this->getTestedType(), array(
|
||||||
@ -107,7 +107,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testDefaultTranslationDomain()
|
public function testDefaultTranslationDomain()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', $this->getTestedType())
|
->add('child', $this->getTestedType())
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
@ -16,18 +16,25 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
*/
|
*/
|
||||||
class BirthdayTypeTest extends BaseTypeTest
|
class BirthdayTypeTest extends BaseTypeTest
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('birthday');
|
||||||
|
|
||||||
|
$this->assertSame('birthday', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
||||||
*/
|
*/
|
||||||
public function testSetInvalidYearsOption()
|
public function testSetInvalidYearsOption()
|
||||||
{
|
{
|
||||||
$this->factory->create('birthday', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\BirthdayType', null, array(
|
||||||
'years' => 'bad value',
|
'years' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTestedType()
|
protected function getTestedType()
|
||||||
{
|
{
|
||||||
return 'birthday';
|
return 'Symfony\Component\Form\Extension\Core\Type\BirthdayType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,20 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
*/
|
*/
|
||||||
class ButtonTypeTest extends BaseTypeTest
|
class ButtonTypeTest extends BaseTypeTest
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('button');
|
||||||
|
|
||||||
|
$this->assertSame('button', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateButtonInstances()
|
public function testCreateButtonInstances()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('button'));
|
$this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ButtonType'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTestedType()
|
protected function getTestedType()
|
||||||
{
|
{
|
||||||
return 'button';
|
return 'Symfony\Component\Form\Extension\Core\Type\ButtonType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,17 @@ use Symfony\Component\Form\CallbackTransformer;
|
|||||||
|
|
||||||
class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testDataIsFalseByDefault()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox');
|
$form = $this->factory->create('checkbox');
|
||||||
|
|
||||||
|
$this->assertSame('checkbox', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDataIsFalseByDefault()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType');
|
||||||
|
|
||||||
$this->assertFalse($form->getData());
|
$this->assertFalse($form->getData());
|
||||||
$this->assertFalse($form->getNormData());
|
$this->assertFalse($form->getNormData());
|
||||||
$this->assertNull($form->getViewData());
|
$this->assertNull($form->getViewData());
|
||||||
@ -26,7 +33,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassValueToView()
|
public function testPassValueToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array('value' => 'foobar'));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array('value' => 'foobar'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
$this->assertEquals('foobar', $view->vars['value']);
|
$this->assertEquals('foobar', $view->vars['value']);
|
||||||
@ -34,7 +41,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testCheckedIfDataTrue()
|
public function testCheckedIfDataTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType');
|
||||||
$form->setData(true);
|
$form->setData(true);
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -43,7 +50,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testCheckedIfDataTrueWithEmptyValue()
|
public function testCheckedIfDataTrueWithEmptyValue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array('value' => ''));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array('value' => ''));
|
||||||
$form->setData(true);
|
$form->setData(true);
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -52,7 +59,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNotCheckedIfDataFalse()
|
public function testNotCheckedIfDataFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType');
|
||||||
$form->setData(false);
|
$form->setData(false);
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -61,7 +68,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithValueChecked()
|
public function testSubmitWithValueChecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => 'foobar',
|
'value' => 'foobar',
|
||||||
));
|
));
|
||||||
$form->submit('foobar');
|
$form->submit('foobar');
|
||||||
@ -72,7 +79,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithRandomValueChecked()
|
public function testSubmitWithRandomValueChecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => 'foobar',
|
'value' => 'foobar',
|
||||||
));
|
));
|
||||||
$form->submit('krixikraxi');
|
$form->submit('krixikraxi');
|
||||||
@ -83,7 +90,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithValueUnchecked()
|
public function testSubmitWithValueUnchecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => 'foobar',
|
'value' => 'foobar',
|
||||||
));
|
));
|
||||||
$form->submit(null);
|
$form->submit(null);
|
||||||
@ -94,7 +101,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithEmptyValueChecked()
|
public function testSubmitWithEmptyValueChecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->submit('');
|
$form->submit('');
|
||||||
@ -105,7 +112,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithEmptyValueUnchecked()
|
public function testSubmitWithEmptyValueUnchecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->submit(null);
|
$form->submit(null);
|
||||||
@ -116,7 +123,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithEmptyValueAndFalseUnchecked()
|
public function testSubmitWithEmptyValueAndFalseUnchecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->submit(false);
|
$form->submit(false);
|
||||||
@ -127,7 +134,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitWithEmptyValueAndTrueChecked()
|
public function testSubmitWithEmptyValueAndTrueChecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->submit(true);
|
$form->submit(true);
|
||||||
@ -151,7 +158,7 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$form = $this->factory->createBuilder('checkbox')
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\CheckboxType')
|
||||||
->addModelTransformer($transformer)
|
->addModelTransformer($transformer)
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class ChoiceTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
$choices = range(1, 300);
|
$choices = range(1, 300);
|
||||||
|
|
||||||
for ($i = 0; $i < 100; ++$i) {
|
for ($i = 0; $i < 100; ++$i) {
|
||||||
$this->factory->create('choice', mt_rand(1, 400), array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', mt_rand(1, 400), array(
|
||||||
'choices' => $choices,
|
'choices' => $choices,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -67,12 +67,19 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$this->objectChoices = null;
|
$this->objectChoices = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('choice');
|
||||||
|
|
||||||
|
$this->assertSame('choice', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
||||||
*/
|
*/
|
||||||
public function testChoicesOptionExpectsArrayOrTraversable()
|
public function testChoicesOptionExpectsArrayOrTraversable()
|
||||||
{
|
{
|
||||||
$this->factory->create('choice', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => new \stdClass(),
|
'choices' => new \stdClass(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -82,7 +89,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testChoiceListOptionExpectsChoiceListInterface()
|
public function testChoiceListOptionExpectsChoiceListInterface()
|
||||||
{
|
{
|
||||||
$this->factory->create('choice', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choice_list' => array('foo' => 'foo'),
|
'choice_list' => array('foo' => 'foo'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -92,19 +99,19 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testChoiceLoaderOptionExpectsChoiceLoaderInterface()
|
public function testChoiceLoaderOptionExpectsChoiceLoaderInterface()
|
||||||
{
|
{
|
||||||
$this->factory->create('choice', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choice_loader' => new \stdClass(),
|
'choice_loader' => new \stdClass(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChoiceListAndChoicesCanBeEmpty()
|
public function testChoiceListAndChoicesCanBeEmpty()
|
||||||
{
|
{
|
||||||
$this->factory->create('choice');
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExpandedChoicesOptionsTurnIntoChildren()
|
public function testExpandedChoicesOptionsTurnIntoChildren()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
@ -114,7 +121,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice()
|
public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -127,7 +134,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderNotPresentIfRequired()
|
public function testPlaceholderNotPresentIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -140,7 +147,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderNotPresentIfMultiple()
|
public function testPlaceholderNotPresentIfMultiple()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -153,7 +160,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderNotPresentIfEmptyChoice()
|
public function testPlaceholderNotPresentIfEmptyChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -169,7 +176,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testExpandedChoicesOptionsAreFlattened()
|
public function testExpandedChoicesOptionsAreFlattened()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->groupedChoices,
|
'choices' => $this->groupedChoices,
|
||||||
));
|
));
|
||||||
@ -194,7 +201,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$obj4 = (object) array('id' => 4, 'name' => 'Jon');
|
$obj4 = (object) array('id' => 4, 'name' => 'Jon');
|
||||||
$obj5 = (object) array('id' => 5, 'name' => 'Roman');
|
$obj5 = (object) array('id' => 5, 'name' => 'Roman');
|
||||||
|
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'Symfony' => array($obj1, $obj2, $obj3),
|
'Symfony' => array($obj1, $obj2, $obj3),
|
||||||
@ -214,7 +221,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testExpandedCheckboxesAreNeverRequired()
|
public function testExpandedCheckboxesAreNeverRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -228,7 +235,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired()
|
public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -242,7 +249,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired()
|
public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -256,7 +263,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpanded()
|
public function testSubmitSingleNonExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -271,7 +278,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedInvalidChoice()
|
public function testSubmitSingleNonExpandedInvalidChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -286,7 +293,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedNull()
|
public function testSubmitSingleNonExpandedNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -304,7 +311,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleNonExpandedNullNoChoices()
|
public function testSubmitSingleNonExpandedNullNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
@ -319,7 +326,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedEmpty()
|
public function testSubmitSingleNonExpandedEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -334,7 +341,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedEmptyExplicitEmptyChoice()
|
public function testSubmitSingleNonExpandedEmptyExplicitEmptyChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
@ -357,7 +364,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleNonExpandedEmptyNoChoices()
|
public function testSubmitSingleNonExpandedEmptyNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
@ -372,7 +379,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedFalse()
|
public function testSubmitSingleNonExpandedFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -390,7 +397,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleNonExpandedFalseNoChoices()
|
public function testSubmitSingleNonExpandedFalseNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
@ -405,7 +412,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleNonExpandedObjectChoices()
|
public function testSubmitSingleNonExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->objectChoices,
|
'choices' => $this->objectChoices,
|
||||||
@ -427,7 +434,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testLegacySubmitSingleNonExpandedObjectChoices()
|
public function testLegacySubmitSingleNonExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choice_list' => new ObjectChoiceList(
|
'choice_list' => new ObjectChoiceList(
|
||||||
@ -451,7 +458,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNonExpanded()
|
public function testSubmitMultipleNonExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -466,7 +473,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNonExpandedEmpty()
|
public function testSubmitMultipleNonExpandedEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -484,7 +491,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitMultipleNonExpandedEmptyNoChoices()
|
public function testSubmitMultipleNonExpandedEmptyNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
@ -499,7 +506,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNonExpandedInvalidScalarChoice()
|
public function testSubmitMultipleNonExpandedInvalidScalarChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -514,7 +521,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNonExpandedInvalidArrayChoice()
|
public function testSubmitMultipleNonExpandedInvalidArrayChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -529,7 +536,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleNonExpandedObjectChoices()
|
public function testSubmitMultipleNonExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->objectChoices,
|
'choices' => $this->objectChoices,
|
||||||
@ -550,7 +557,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testLegacySubmitMultipleNonExpandedObjectChoices()
|
public function testLegacySubmitMultipleNonExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choice_list' => new ObjectChoiceList(
|
'choice_list' => new ObjectChoiceList(
|
||||||
@ -573,7 +580,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedRequired()
|
public function testSubmitSingleExpandedRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -601,7 +608,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedRequiredInvalidChoice()
|
public function testSubmitSingleExpandedRequiredInvalidChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -629,7 +636,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNonRequired()
|
public function testSubmitSingleExpandedNonRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -659,7 +666,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNonRequiredInvalidChoice()
|
public function testSubmitSingleExpandedNonRequiredInvalidChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -687,7 +694,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedRequiredNull()
|
public function testSubmitSingleExpandedRequiredNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -718,7 +725,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedRequiredNullNoChoices()
|
public function testSubmitSingleExpandedRequiredNullNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -735,7 +742,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedRequiredEmpty()
|
public function testSubmitSingleExpandedRequiredEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -766,7 +773,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedRequiredEmptyNoChoices()
|
public function testSubmitSingleExpandedRequiredEmptyNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -783,7 +790,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedRequiredFalse()
|
public function testSubmitSingleExpandedRequiredFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -814,7 +821,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedRequiredFalseNoChoices()
|
public function testSubmitSingleExpandedRequiredFalseNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -831,7 +838,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNonRequiredNull()
|
public function testSubmitSingleExpandedNonRequiredNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -864,7 +871,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedNonRequiredNullNoChoices()
|
public function testSubmitSingleExpandedNonRequiredNullNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -881,7 +888,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNonRequiredEmpty()
|
public function testSubmitSingleExpandedNonRequiredEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -914,7 +921,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedNonRequiredEmptyNoChoices()
|
public function testSubmitSingleExpandedNonRequiredEmptyNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -931,7 +938,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNonRequiredFalse()
|
public function testSubmitSingleExpandedNonRequiredFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -964,7 +971,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitSingleExpandedNonRequiredFalseNoChoices()
|
public function testSubmitSingleExpandedNonRequiredFalseNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -981,7 +988,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedWithEmptyChild()
|
public function testSubmitSingleExpandedWithEmptyChild()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
@ -1003,7 +1010,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedObjectChoices()
|
public function testSubmitSingleExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->objectChoices,
|
'choices' => $this->objectChoices,
|
||||||
@ -1034,7 +1041,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testLegacySubmitSingleExpandedObjectChoices()
|
public function testLegacySubmitSingleExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choice_list' => new ObjectChoiceList(
|
'choice_list' => new ObjectChoiceList(
|
||||||
@ -1067,7 +1074,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitSingleExpandedNumericChoices()
|
public function testSubmitSingleExpandedNumericChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->numericChoices,
|
'choices' => $this->numericChoices,
|
||||||
@ -1092,7 +1099,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpanded()
|
public function testSubmitMultipleExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1119,7 +1126,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedInvalidScalarChoice()
|
public function testSubmitMultipleExpandedInvalidScalarChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1146,7 +1153,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedInvalidArrayChoice()
|
public function testSubmitMultipleExpandedInvalidArrayChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1173,7 +1180,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedEmpty()
|
public function testSubmitMultipleExpandedEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1201,7 +1208,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// choices are available.
|
// choices are available.
|
||||||
public function testSubmitMultipleExpandedEmptyNoChoices()
|
public function testSubmitMultipleExpandedEmptyNoChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
@ -1215,7 +1222,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedWithEmptyChild()
|
public function testSubmitMultipleExpandedWithEmptyChild()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
@ -1240,7 +1247,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedObjectChoices()
|
public function testSubmitMultipleExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->objectChoices,
|
'choices' => $this->objectChoices,
|
||||||
@ -1271,7 +1278,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testLegacySubmitMultipleExpandedObjectChoices()
|
public function testLegacySubmitMultipleExpandedObjectChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choice_list' => new ObjectChoiceList(
|
'choice_list' => new ObjectChoiceList(
|
||||||
@ -1304,7 +1311,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultipleExpandedNumericChoices()
|
public function testSubmitMultipleExpandedNumericChoices()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->numericChoices,
|
'choices' => $this->numericChoices,
|
||||||
@ -1333,7 +1340,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetDataSingleNonExpandedAcceptsBoolean()
|
public function testSetDataSingleNonExpandedAcceptsBoolean()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->numericChoices,
|
'choices' => $this->numericChoices,
|
||||||
@ -1348,7 +1355,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetDataMultipleNonExpandedAcceptsBoolean()
|
public function testSetDataMultipleNonExpandedAcceptsBoolean()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->numericChoices,
|
'choices' => $this->numericChoices,
|
||||||
@ -1363,7 +1370,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassRequiredToView()
|
public function testPassRequiredToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -1373,7 +1380,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassNonRequiredToView()
|
public function testPassNonRequiredToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
@ -1384,7 +1391,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassMultipleToView()
|
public function testPassMultipleToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
@ -1395,7 +1402,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassExpandedToView()
|
public function testPassExpandedToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
@ -1406,7 +1413,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassChoiceTranslationDomainToView()
|
public function testPassChoiceTranslationDomainToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -1416,7 +1423,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testChoiceTranslationDomainWithTrueValueToView()
|
public function testChoiceTranslationDomainWithTrueValueToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
'choice_translation_domain' => true,
|
'choice_translation_domain' => true,
|
||||||
));
|
));
|
||||||
@ -1427,7 +1434,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testDefaultChoiceTranslationDomainIsSameAsTranslationDomainToView()
|
public function testDefaultChoiceTranslationDomainIsSameAsTranslationDomainToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
'translation_domain' => 'foo',
|
'translation_domain' => 'foo',
|
||||||
));
|
));
|
||||||
@ -1439,10 +1446,10 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testInheritChoiceTranslationDomainFromParent()
|
public function testInheritChoiceTranslationDomainFromParent()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamedBuilder('parent', 'form', null, array(
|
->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'translation_domain' => 'domain',
|
'translation_domain' => 'domain',
|
||||||
))
|
))
|
||||||
->add('child', 'choice')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -1451,7 +1458,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderIsNullByDefaultIfRequired()
|
public function testPlaceholderIsNullByDefaultIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1463,7 +1470,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPlaceholderIsEmptyStringByDefaultIfNotRequired()
|
public function testPlaceholderIsEmptyStringByDefaultIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1478,7 +1485,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testPassPlaceholderToView($multiple, $expanded, $required, $placeholder, $viewValue)
|
public function testPassPlaceholderToView($multiple, $expanded, $required, $placeholder, $viewValue)
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => $multiple,
|
'multiple' => $multiple,
|
||||||
'expanded' => $expanded,
|
'expanded' => $expanded,
|
||||||
'required' => $required,
|
'required' => $required,
|
||||||
@ -1496,7 +1503,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue)
|
public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue)
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => $multiple,
|
'multiple' => $multiple,
|
||||||
'expanded' => $expanded,
|
'expanded' => $expanded,
|
||||||
'required' => $required,
|
'required' => $required,
|
||||||
@ -1516,7 +1523,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded, $required, $placeholder, $viewValue)
|
public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded, $required, $placeholder, $viewValue)
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => $multiple,
|
'multiple' => $multiple,
|
||||||
'expanded' => $expanded,
|
'expanded' => $expanded,
|
||||||
'required' => $required,
|
'required' => $required,
|
||||||
@ -1576,7 +1583,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testPassChoicesToView()
|
public function testPassChoicesToView()
|
||||||
{
|
{
|
||||||
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D');
|
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D');
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $choices,
|
'choices' => $choices,
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -1592,7 +1599,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testPassPreferredChoicesToView()
|
public function testPassPreferredChoicesToView()
|
||||||
{
|
{
|
||||||
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D');
|
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D');
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $choices,
|
'choices' => $choices,
|
||||||
'preferred_choices' => array('b', 'd'),
|
'preferred_choices' => array('b', 'd'),
|
||||||
));
|
));
|
||||||
@ -1610,7 +1617,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPassHierarchicalChoicesToView()
|
public function testPassHierarchicalChoicesToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => $this->groupedChoices,
|
'choices' => $this->groupedChoices,
|
||||||
'preferred_choices' => array('b', 'd'),
|
'preferred_choices' => array('b', 'd'),
|
||||||
));
|
));
|
||||||
@ -1641,7 +1648,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$obj2 = (object) array('value' => 'b', 'label' => 'B');
|
$obj2 = (object) array('value' => 'b', 'label' => 'B');
|
||||||
$obj3 = (object) array('value' => 'c', 'label' => 'C');
|
$obj3 = (object) array('value' => 'c', 'label' => 'C');
|
||||||
$obj4 = (object) array('value' => 'd', 'label' => 'D');
|
$obj4 = (object) array('value' => 'd', 'label' => 'D');
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => array($obj1, $obj2, $obj3, $obj4),
|
'choices' => array($obj1, $obj2, $obj3, $obj4),
|
||||||
'choices_as_values' => true,
|
'choices_as_values' => true,
|
||||||
'choice_label' => 'label',
|
'choice_label' => 'label',
|
||||||
@ -1659,7 +1666,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testAdjustFullNameForMultipleNonExpanded()
|
public function testAdjustFullNameForMultipleNonExpanded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'choice', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choices' => $this->choices,
|
'choices' => $this->choices,
|
||||||
@ -1672,7 +1679,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// https://github.com/symfony/symfony/issues/3298
|
// https://github.com/symfony/symfony/issues/3298
|
||||||
public function testInitializeWithEmptyChoices()
|
public function testInitializeWithEmptyChoices()
|
||||||
{
|
{
|
||||||
$this->factory->createNamed('name', 'choice', null, array(
|
$this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => array(),
|
'choices' => array(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -1684,7 +1691,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$obj3 = (object) array('value' => 'c', 'label' => 'C');
|
$obj3 = (object) array('value' => 'c', 'label' => 'C');
|
||||||
$obj4 = (object) array('value' => 'd', 'label' => 'D');
|
$obj4 = (object) array('value' => 'd', 'label' => 'D');
|
||||||
|
|
||||||
$form = $this->factory->create('choice', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||||
'choices' => array($obj1, $obj2, $obj3, $obj4),
|
'choices' => array($obj1, $obj2, $obj3, $obj4),
|
||||||
'choices_as_values' => true,
|
'choices_as_values' => true,
|
||||||
'choice_label' => 'label',
|
'choice_label' => 'label',
|
||||||
|
@ -17,10 +17,19 @@ use Symfony\Component\Form\Tests\Fixtures\AuthorType;
|
|||||||
|
|
||||||
class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('collection', array(
|
||||||
|
'type' => 'text',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertSame('collection', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testContainsNoChildByDefault()
|
public function testContainsNoChildByDefault()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertCount(0, $form);
|
$this->assertCount(0, $form);
|
||||||
@ -28,8 +37,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetDataAdjustsSize()
|
public function testSetDataAdjustsSize()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'attr' => array('maxlength' => 20),
|
'attr' => array('maxlength' => 20),
|
||||||
),
|
),
|
||||||
@ -57,8 +66,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testThrowsExceptionIfObjectIsNotTraversable()
|
public function testThrowsExceptionIfObjectIsNotTraversable()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$form->setData(new \stdClass());
|
$form->setData(new \stdClass());
|
||||||
@ -66,8 +75,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNotResizedIfSubmittedWithMissingData()
|
public function testNotResizedIfSubmittedWithMissingData()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
$form->setData(array('foo@foo.com', 'bar@bar.com'));
|
$form->setData(array('foo@foo.com', 'bar@bar.com'));
|
||||||
$form->submit(array('foo@bar.com'));
|
$form->submit(array('foo@bar.com'));
|
||||||
@ -80,8 +89,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
|
public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_delete' => true,
|
'allow_delete' => true,
|
||||||
));
|
));
|
||||||
$form->setData(array('foo@foo.com', 'bar@bar.com'));
|
$form->setData(array('foo@foo.com', 'bar@bar.com'));
|
||||||
@ -95,8 +104,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
|
public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_delete' => true,
|
'allow_delete' => true,
|
||||||
'delete_empty' => true,
|
'delete_empty' => true,
|
||||||
));
|
));
|
||||||
@ -112,8 +121,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testDontAddEmptyDataIfDeleteEmpty()
|
public function testDontAddEmptyDataIfDeleteEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'delete_empty' => true,
|
'delete_empty' => true,
|
||||||
));
|
));
|
||||||
@ -129,8 +138,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNoDeleteEmptyIfDeleteNotAllowed()
|
public function testNoDeleteEmptyIfDeleteNotAllowed()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_delete' => false,
|
'allow_delete' => false,
|
||||||
'delete_empty' => true,
|
'delete_empty' => true,
|
||||||
));
|
));
|
||||||
@ -144,8 +153,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
|
public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => new AuthorType(),
|
'type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType',
|
||||||
// If the field is not required, no new Author will be created if the
|
// If the field is not required, no new Author will be created if the
|
||||||
// form is completely empty
|
// form is completely empty
|
||||||
'options' => array('required' => false),
|
'options' => array('required' => false),
|
||||||
@ -167,8 +176,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNotResizedIfSubmittedWithExtraData()
|
public function testNotResizedIfSubmittedWithExtraData()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
$form->setData(array('foo@bar.com'));
|
$form->setData(array('foo@bar.com'));
|
||||||
$form->submit(array('foo@foo.com', 'bar@bar.com'));
|
$form->submit(array('foo@foo.com', 'bar@bar.com'));
|
||||||
@ -180,8 +189,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd()
|
public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
));
|
));
|
||||||
$form->setData(array('foo@bar.com'));
|
$form->setData(array('foo@bar.com'));
|
||||||
@ -196,8 +205,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testAllowAddButNoPrototype()
|
public function testAllowAddButNoPrototype()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'form',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype' => false,
|
'prototype' => false,
|
||||||
));
|
));
|
||||||
@ -208,8 +217,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
public function testPrototypeMultipartPropagation()
|
public function testPrototypeMultipartPropagation()
|
||||||
{
|
{
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->create('collection', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'file',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
))
|
))
|
||||||
@ -220,8 +229,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
|
public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', array(), array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'file',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
));
|
));
|
||||||
@ -232,8 +241,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
|
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', array(), array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'file',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
));
|
));
|
||||||
@ -245,16 +254,16 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPrototypeNameOption()
|
public function testPrototypeNameOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'form',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType',
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default');
|
$this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default');
|
||||||
|
|
||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => 'form',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType',
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype_name' => '__test__',
|
'prototype_name' => '__test__',
|
||||||
@ -265,8 +274,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPrototypeDefaultLabel()
|
public function testPrototypeDefaultLabel()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', array(), array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'file',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_name' => '__test__',
|
'prototype_name' => '__test__',
|
||||||
@ -277,8 +286,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testPrototypeData()
|
public function testPrototypeData()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('collection', array(), array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_data' => 'foo',
|
'prototype_data' => 'foo',
|
||||||
|
@ -24,9 +24,16 @@ class CountryTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCountriesAreSelectable()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('country');
|
$form = $this->factory->create('country');
|
||||||
|
|
||||||
|
$this->assertSame('country', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCountriesAreSelectable()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CountryType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
@ -40,7 +47,7 @@ class CountryTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testUnknownCountryIsNotIncluded()
|
public function testUnknownCountryIsNotIncluded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('country', 'country');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CountryType', 'Symfony\Component\Form\Extension\Core\Type\CountryType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
|
@ -24,9 +24,16 @@ class CurrencyTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCurrenciesAreSelectable()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('currency');
|
$form = $this->factory->create('currency');
|
||||||
|
|
||||||
|
$this->assertSame('currency', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCurrenciesAreSelectable()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CurrencyType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
|
@ -24,9 +24,16 @@ class DateTimeTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('datetime');
|
||||||
|
|
||||||
|
$this->assertSame('datetime', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSubmitDateTime()
|
public function testSubmitDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
@ -53,7 +60,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitString()
|
public function testSubmitString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -78,7 +85,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitTimestamp()
|
public function testSubmitTimestamp()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
@ -105,7 +112,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitWithoutMinutes()
|
public function testSubmitWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
@ -134,7 +141,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitWithSeconds()
|
public function testSubmitWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
@ -165,7 +172,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitDifferentTimezones()
|
public function testSubmitDifferentTimezones()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'America/New_York',
|
'model_timezone' => 'America/New_York',
|
||||||
'view_timezone' => 'Pacific/Tahiti',
|
'view_timezone' => 'Pacific/Tahiti',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
@ -196,7 +203,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitDifferentTimezonesDateTime()
|
public function testSubmitDifferentTimezonesDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'America/New_York',
|
'model_timezone' => 'America/New_York',
|
||||||
'view_timezone' => 'Pacific/Tahiti',
|
'view_timezone' => 'Pacific/Tahiti',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
@ -215,7 +222,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitStringSingleText()
|
public function testSubmitStringSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -230,7 +237,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitStringSingleTextWithSeconds()
|
public function testSubmitStringSingleTextWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -246,7 +253,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitDifferentPattern()
|
public function testSubmitDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'date_format' => 'MM*yyyy*dd',
|
'date_format' => 'MM*yyyy*dd',
|
||||||
'date_widget' => 'single_text',
|
'date_widget' => 'single_text',
|
||||||
'time_widget' => 'single_text',
|
'time_widget' => 'single_text',
|
||||||
@ -268,12 +275,12 @@ class DateTimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Throws an exception if "data_class" option is not explicitly set
|
// Throws an exception if "data_class" option is not explicitly set
|
||||||
// to null in the type
|
// to null in the type
|
||||||
$this->factory->create('datetime', new \DateTime());
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', new \DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleTextWidgetShouldUseTheRightInputType()
|
public function testSingleTextWidgetShouldUseTheRightInputType()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -283,7 +290,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -299,7 +306,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassNoPlaceholderToViewIfRequired()
|
public function testPassNoPlaceholderToViewIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -315,7 +322,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsString()
|
public function testPassPlaceholderAsString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'placeholder' => 'Empty',
|
'placeholder' => 'Empty',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -331,7 +338,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassEmptyValueBC()
|
public function testPassEmptyValueBC()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'empty_value' => 'Empty',
|
'empty_value' => 'Empty',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -353,7 +360,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsArray()
|
public function testPassPlaceholderAsArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
'month' => 'Empty month',
|
'month' => 'Empty month',
|
||||||
@ -376,7 +383,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
@ -398,7 +405,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
@ -420,7 +427,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassHtml5TypeIfSingleTextAndHtml5Format()
|
public function testPassHtml5TypeIfSingleTextAndHtml5Format()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -430,7 +437,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'html5' => false,
|
'html5' => false,
|
||||||
));
|
));
|
||||||
@ -441,7 +448,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfNotHtml5Format()
|
public function testDontPassHtml5TypeIfNotHtml5Format()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'format' => 'yyyy-MM-dd HH:mm',
|
'format' => 'yyyy-MM-dd HH:mm',
|
||||||
));
|
));
|
||||||
@ -452,7 +459,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfNotSingleText()
|
public function testDontPassHtml5TypeIfNotSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -463,7 +470,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
public function testDateTypeChoiceErrorsBubbleUp()
|
public function testDateTypeChoiceErrorsBubbleUp()
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('datetime', null);
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null);
|
||||||
|
|
||||||
$form['date']->addError($error);
|
$form['date']->addError($error);
|
||||||
|
|
||||||
@ -474,7 +481,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
public function testDateTypeSingleTextErrorsBubbleUp()
|
public function testDateTypeSingleTextErrorsBubbleUp()
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'date_widget' => 'single_text',
|
'date_widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -487,7 +494,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
public function testTimeTypeChoiceErrorsBubbleUp()
|
public function testTimeTypeChoiceErrorsBubbleUp()
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('datetime', null);
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null);
|
||||||
|
|
||||||
$form['time']->addError($error);
|
$form['time']->addError($error);
|
||||||
|
|
||||||
@ -498,7 +505,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
public function testTimeTypeSingleTextErrorsBubbleUp()
|
public function testTimeTypeSingleTextErrorsBubbleUp()
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('datetime', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array(
|
||||||
'time_widget' => 'single_text',
|
'time_widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -37,12 +37,19 @@ class DateTypeTest extends TestCase
|
|||||||
date_default_timezone_set($this->defaultTimezone);
|
date_default_timezone_set($this->defaultTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('date');
|
||||||
|
|
||||||
|
$this->assertSame('date', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
|
||||||
*/
|
*/
|
||||||
public function testInvalidWidgetOption()
|
public function testInvalidWidgetOption()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'fake_widget',
|
'widget' => 'fake_widget',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -52,14 +59,14 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidInputOption()
|
public function testInvalidInputOption()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'input' => 'fake_input',
|
'input' => 'fake_input',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
@ -74,7 +81,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromSingleTextDateTime()
|
public function testSubmitFromSingleTextDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
@ -90,7 +97,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromSingleTextString()
|
public function testSubmitFromSingleTextString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
@ -106,7 +113,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromSingleTextTimestamp()
|
public function testSubmitFromSingleTextTimestamp()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
@ -124,7 +131,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromSingleTextRaw()
|
public function testSubmitFromSingleTextRaw()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
@ -146,7 +153,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromText()
|
public function testSubmitFromText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
@ -168,7 +175,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromChoice()
|
public function testSubmitFromChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
@ -190,7 +197,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromChoiceEmpty()
|
public function testSubmitFromChoiceEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
@ -211,7 +218,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromInputDateTimeDifferentPattern()
|
public function testSubmitFromInputDateTimeDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
@ -227,7 +234,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromInputStringDifferentPattern()
|
public function testSubmitFromInputStringDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
@ -243,7 +250,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromInputTimestampDifferentPattern()
|
public function testSubmitFromInputTimestampDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
@ -261,7 +268,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitFromInputRawDifferentPattern()
|
public function testSubmitFromInputRawDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
@ -286,7 +293,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDatePatternWithFormatOption($format, $pattern)
|
public function testDatePatternWithFormatOption($format, $pattern)
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => $format,
|
'format' => $format,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -312,7 +319,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfFormatIsNoPattern()
|
public function testThrowExceptionIfFormatIsNoPattern()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => '0',
|
'format' => '0',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -324,7 +331,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay()
|
public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => array(6, 7),
|
'months' => array(6, 7),
|
||||||
'format' => 'yy',
|
'format' => 'yy',
|
||||||
));
|
));
|
||||||
@ -335,7 +342,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfFormatIsNoConstant()
|
public function testThrowExceptionIfFormatIsNoConstant()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => 105,
|
'format' => 105,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -345,7 +352,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfFormatIsInvalid()
|
public function testThrowExceptionIfFormatIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => array(),
|
'format' => array(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -355,7 +362,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfYearsIsInvalid()
|
public function testThrowExceptionIfYearsIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'years' => 'bad value',
|
'years' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -365,7 +372,7 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfMonthsIsInvalid()
|
public function testThrowExceptionIfMonthsIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => 'bad value',
|
'months' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -375,14 +382,14 @@ class DateTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfDaysIsInvalid()
|
public function testThrowExceptionIfDaysIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('date', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'days' => 'bad value',
|
'days' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDataWithNegativeTimezoneOffsetStringInput()
|
public function testSetDataWithNegativeTimezoneOffsetStringInput()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'America/New_York',
|
'view_timezone' => 'America/New_York',
|
||||||
@ -399,7 +406,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
|
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'America/New_York',
|
'view_timezone' => 'America/New_York',
|
||||||
@ -419,7 +426,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testYearsOption()
|
public function testYearsOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'years' => array(2010, 2011),
|
'years' => array(2010, 2011),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -433,7 +440,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testMonthsOption()
|
public function testMonthsOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => array(6, 7),
|
'months' => array(6, 7),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -447,7 +454,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testMonthsOptionShortFormat()
|
public function testMonthsOptionShortFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => array(1, 4),
|
'months' => array(1, 4),
|
||||||
'format' => 'dd.MMM.yy',
|
'format' => 'dd.MMM.yy',
|
||||||
));
|
));
|
||||||
@ -462,7 +469,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testMonthsOptionLongFormat()
|
public function testMonthsOptionLongFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => array(1, 4),
|
'months' => array(1, 4),
|
||||||
'format' => 'dd.MMMM.yy',
|
'format' => 'dd.MMMM.yy',
|
||||||
));
|
));
|
||||||
@ -477,7 +484,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testMonthsOptionLongFormatWithDifferentTimezone()
|
public function testMonthsOptionLongFormatWithDifferentTimezone()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'months' => array(1, 4),
|
'months' => array(1, 4),
|
||||||
'format' => 'dd.MMMM.yy',
|
'format' => 'dd.MMMM.yy',
|
||||||
));
|
));
|
||||||
@ -492,7 +499,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testIsDayWithinRangeReturnsTrueIfWithin()
|
public function testIsDayWithinRangeReturnsTrueIfWithin()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'days' => array(6, 7),
|
'days' => array(6, 7),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -508,7 +515,7 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
@ -523,7 +530,7 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
@ -542,7 +549,7 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
@ -561,7 +568,7 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
@ -578,7 +585,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDatePatternToView()
|
public function testPassDatePatternToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
$this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
|
$this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
|
||||||
@ -586,7 +593,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDatePatternToViewDifferentFormat()
|
public function testPassDatePatternToViewDifferentFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::LONG,
|
'format' => \IntlDateFormatter::LONG,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -597,7 +604,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDatePatternToViewDifferentPattern()
|
public function testPassDatePatternToViewDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => 'MMyyyydd',
|
'format' => 'MMyyyydd',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -608,7 +615,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDatePatternToViewDifferentPatternWithSeparators()
|
public function testPassDatePatternToViewDifferentPatternWithSeparators()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -619,7 +626,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassDatePatternIfText()
|
public function testDontPassDatePatternIfText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -631,7 +638,7 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
\Locale::setDefault('es_ES');
|
\Locale::setDefault('es_ES');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
// EEEE, d 'de' MMMM 'de' y
|
// EEEE, d 'de' MMMM 'de' y
|
||||||
'format' => \IntlDateFormatter::FULL,
|
'format' => \IntlDateFormatter::FULL,
|
||||||
));
|
));
|
||||||
@ -643,7 +650,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassWidgetToView()
|
public function testPassWidgetToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -656,12 +663,12 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Throws an exception if "data_class" option is not explicitly set
|
// Throws an exception if "data_class" option is not explicitly set
|
||||||
// to null in the type
|
// to null in the type
|
||||||
$this->factory->create('date', new \DateTime());
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', new \DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleTextWidgetShouldUseTheRightInputType()
|
public function testSingleTextWidgetShouldUseTheRightInputType()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -671,7 +678,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -683,7 +690,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassNoPlaceholderToViewIfRequired()
|
public function testPassNoPlaceholderToViewIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -695,7 +702,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsString()
|
public function testPassPlaceholderAsString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'placeholder' => 'Empty',
|
'placeholder' => 'Empty',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -707,7 +714,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassEmptyValueBC()
|
public function testPassEmptyValueBC()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'empty_value' => 'Empty',
|
'empty_value' => 'Empty',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -722,7 +729,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsArray()
|
public function testPassPlaceholderAsArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
'month' => 'Empty month',
|
'month' => 'Empty month',
|
||||||
@ -738,7 +745,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
@ -754,7 +761,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'year' => 'Empty year',
|
'year' => 'Empty year',
|
||||||
@ -770,7 +777,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassHtml5TypeIfSingleTextAndHtml5Format()
|
public function testPassHtml5TypeIfSingleTextAndHtml5Format()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -780,7 +787,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'html5' => false,
|
'html5' => false,
|
||||||
));
|
));
|
||||||
@ -791,7 +798,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfNotHtml5Format()
|
public function testDontPassHtml5TypeIfNotHtml5Format()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
));
|
));
|
||||||
@ -802,7 +809,7 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfNotSingleText()
|
public function testDontPassHtml5TypeIfNotSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -824,7 +831,7 @@ class DateTypeTest extends TestCase
|
|||||||
public function testYearErrorsBubbleUp($widget)
|
public function testYearErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
));
|
));
|
||||||
$form['year']->addError($error);
|
$form['year']->addError($error);
|
||||||
@ -839,7 +846,7 @@ class DateTypeTest extends TestCase
|
|||||||
public function testMonthErrorsBubbleUp($widget)
|
public function testMonthErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
));
|
));
|
||||||
$form['month']->addError($error);
|
$form['month']->addError($error);
|
||||||
@ -854,7 +861,7 @@ class DateTypeTest extends TestCase
|
|||||||
public function testDayErrorsBubbleUp($widget)
|
public function testDayErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
));
|
));
|
||||||
$form['day']->addError($error);
|
$form['day']->addError($error);
|
||||||
@ -870,7 +877,7 @@ class DateTypeTest extends TestCase
|
|||||||
'PHP must be compiled in 32 bit mode to run this test');
|
'PHP must be compiled in 32 bit mode to run this test');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'years' => range(1900, 2040),
|
'years' => range(1900, 2040),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -13,10 +13,17 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
|
|
||||||
class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('file');
|
||||||
|
|
||||||
|
$this->assertSame('file', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/symfony/symfony/pull/5028
|
// https://github.com/symfony/symfony/pull/5028
|
||||||
public function testSetData()
|
public function testSetData()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('file')->getForm();
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm();
|
||||||
$data = $this->createUploadedFileMock('abcdef', 'original.jpg', true);
|
$data = $this->createUploadedFileMock('abcdef', 'original.jpg', true);
|
||||||
|
|
||||||
$form->setData($data);
|
$form->setData($data);
|
||||||
@ -26,7 +33,7 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmit()
|
public function testSubmit()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('file')->getForm();
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm();
|
||||||
$data = $this->createUploadedFileMock('abcdef', 'original.jpg', true);
|
$data = $this->createUploadedFileMock('abcdef', 'original.jpg', true);
|
||||||
|
|
||||||
$form->submit($data);
|
$form->submit($data);
|
||||||
@ -37,7 +44,7 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
// https://github.com/symfony/symfony/issues/6134
|
// https://github.com/symfony/symfony/issues/6134
|
||||||
public function testSubmitEmpty()
|
public function testSubmitEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('file')->getForm();
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm();
|
||||||
|
|
||||||
$form->submit(null);
|
$form->submit(null);
|
||||||
|
|
||||||
@ -46,7 +53,7 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSubmitMultiple()
|
public function testSubmitMultiple()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('file', null, array(
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType', null, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
))->getForm();
|
))->getForm();
|
||||||
|
|
||||||
@ -65,9 +72,9 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testDontPassValueToView()
|
public function testDontPassValueToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('file');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FileType');
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
'file' => $this->createUploadedFileMock('abcdef', 'original.jpg', true),
|
'Symfony\Component\Form\Extension\Core\Type\FileType' => $this->createUploadedFileMock('abcdef', 'original.jpg', true),
|
||||||
));
|
));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
|
@ -51,25 +51,32 @@ class FormTest_AuthorWithoutRefSetter
|
|||||||
|
|
||||||
class FormTypeTest extends BaseTypeTest
|
class FormTypeTest extends BaseTypeTest
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('form');
|
||||||
|
|
||||||
|
$this->assertSame('form', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateFormInstances()
|
public function testCreateFormInstances()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('form'));
|
$this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPassRequiredAsOption()
|
public function testPassRequiredAsOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array('required' => false));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('required' => false));
|
||||||
|
|
||||||
$this->assertFalse($form->isRequired());
|
$this->assertFalse($form->isRequired());
|
||||||
|
|
||||||
$form = $this->factory->create('form', null, array('required' => true));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('required' => true));
|
||||||
|
|
||||||
$this->assertTrue($form->isRequired());
|
$this->assertTrue($form->isRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmittedDataIsTrimmedBeforeTransforming()
|
public function testSubmittedDataIsTrimmedBeforeTransforming()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form')
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->addViewTransformer(new FixedDataTransformer(array(
|
->addViewTransformer(new FixedDataTransformer(array(
|
||||||
null => '',
|
null => '',
|
||||||
'reverse[a]' => 'a',
|
'reverse[a]' => 'a',
|
||||||
@ -85,7 +92,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming()
|
public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form', null, array('trim' => false))
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('trim' => false))
|
||||||
->addViewTransformer(new FixedDataTransformer(array(
|
->addViewTransformer(new FixedDataTransformer(array(
|
||||||
null => '',
|
null => '',
|
||||||
'reverse[ a ]' => ' a ',
|
'reverse[ a ]' => ' a ',
|
||||||
@ -104,8 +111,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testLegacyNonReadOnlyFormWithReadOnlyParentIsReadOnly()
|
public function testLegacyNonReadOnlyFormWithReadOnlyParentIsReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form', null, array('read_only' => true))
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('read_only' => true))
|
||||||
->add('child', 'form')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -114,8 +121,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly()
|
public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form', null, array('attr' => array('readonly' => true)))
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => array('readonly' => true)))
|
||||||
->add('child', 'form')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -127,8 +134,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testLegacyReadOnlyFormWithNonReadOnlyParentIsReadOnly()
|
public function testLegacyReadOnlyFormWithNonReadOnlyParentIsReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'form', array('read_only' => true))
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('read_only' => true))
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -137,8 +144,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly()
|
public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'form', array('attr' => array('readonly' => true)))
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('attr' => array('readonly' => true)))
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -150,8 +157,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testLegacyNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly()
|
public function testLegacyNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'form')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -160,8 +167,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly()
|
public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createNamedBuilder('parent', 'form')
|
$view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('child', 'form')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -170,7 +177,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testPassMaxLengthToView()
|
public function testPassMaxLengthToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array('attr' => array('maxlength' => 10)));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => array('maxlength' => 10)));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
$this->assertSame(10, $view->vars['attr']['maxlength']);
|
$this->assertSame(10, $view->vars['attr']['maxlength']);
|
||||||
@ -178,7 +185,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testPassMaxLengthBCToView()
|
public function testPassMaxLengthBCToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array('max_length' => 10));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('max_length' => 10));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
$this->assertSame(10, $view->vars['attr']['maxlength']);
|
$this->assertSame(10, $view->vars['attr']['maxlength']);
|
||||||
@ -186,21 +193,21 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testDataClassMayBeNull()
|
public function testDataClassMayBeNull()
|
||||||
{
|
{
|
||||||
$this->factory->createBuilder('form', null, array(
|
$this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => null,
|
'data_class' => null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDataClassMayBeAbstractClass()
|
public function testDataClassMayBeAbstractClass()
|
||||||
{
|
{
|
||||||
$this->factory->createBuilder('form', null, array(
|
$this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDataClassMayBeInterface()
|
public function testDataClassMayBeInterface()
|
||||||
{
|
{
|
||||||
$this->factory->createBuilder('form', null, array(
|
$this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -210,19 +217,19 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testDataClassMustBeValidClassOrInterface()
|
public function testDataClassMustBeValidClassOrInterface()
|
||||||
{
|
{
|
||||||
$this->factory->createBuilder('form', null, array(
|
$this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'foobar',
|
'data_class' => 'foobar',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable()
|
public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$builder->add('lastName', 'text');
|
$builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -238,13 +245,13 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObject()
|
public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObject()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
// data class is inferred from the passed object
|
// data class is inferred from the passed object
|
||||||
'data' => new Author(),
|
'data' => new Author(),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$builder->add('lastName', 'text');
|
$builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -260,11 +267,11 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull()
|
public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => null,
|
'data_class' => null,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -275,12 +282,12 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired()
|
public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$builder->add('lastName', 'text');
|
$builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -291,12 +298,12 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired()
|
public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$builder->add('lastName', 'text');
|
$builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -310,8 +317,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable()
|
public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form')
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('firstName', 'text')
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$form->setData(null);
|
$form->setData(null);
|
||||||
@ -322,7 +329,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testSubmitWithEmptyDataPassesEmptyStringToTransformerIfNotCompound()
|
public function testSubmitWithEmptyDataPassesEmptyStringToTransformerIfNotCompound()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createBuilder('form')
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->addViewTransformer(new FixedDataTransformer(array(
|
->addViewTransformer(new FixedDataTransformer(array(
|
||||||
// required for the initial, internal setData(null)
|
// required for the initial, internal setData(null)
|
||||||
null => 'null',
|
null => 'null',
|
||||||
@ -341,11 +348,11 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
{
|
{
|
||||||
$author = new Author();
|
$author = new Author();
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'empty_data' => $author,
|
'empty_data' => $author,
|
||||||
));
|
));
|
||||||
$builder->add('firstName', 'text');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->submit(array('firstName' => 'Bernhard'));
|
$form->submit(array('firstName' => 'Bernhard'));
|
||||||
@ -370,7 +377,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testSetDataThroughParamsWithZero($data, $dataAsString)
|
public function testSetDataThroughParamsWithZero($data, $dataAsString)
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
));
|
));
|
||||||
@ -387,12 +394,12 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testAttributesException()
|
public function testAttributesException()
|
||||||
{
|
{
|
||||||
$this->factory->create('form', null, array('attr' => ''));
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNameCanBeEmptyString()
|
public function testNameCanBeEmptyString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('', 'form');
|
$form = $this->factory->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
|
|
||||||
$this->assertEquals('', $form->getName());
|
$this->assertEquals('', $form->getName());
|
||||||
}
|
}
|
||||||
@ -401,11 +408,11 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
{
|
{
|
||||||
$author = new FormTest_AuthorWithoutRefSetter(new Author());
|
$author = new FormTest_AuthorWithoutRefSetter(new Author());
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form', $author);
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author);
|
||||||
$builder->add('reference', 'form', array(
|
$builder->add('reference', 'Symfony\Component\Form\Extension\Core\Type\FormType', array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
));
|
));
|
||||||
$builder->get('reference')->add('firstName', 'text');
|
$builder->get('reference')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -424,11 +431,11 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
$author = new FormTest_AuthorWithoutRefSetter(null);
|
$author = new FormTest_AuthorWithoutRefSetter(null);
|
||||||
$newReference = new Author();
|
$newReference = new Author();
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form', $author);
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author);
|
||||||
$builder->add('referenceCopy', 'form', array(
|
$builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType', array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
));
|
));
|
||||||
$builder->get('referenceCopy')->add('firstName', 'text');
|
$builder->get('referenceCopy')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form['referenceCopy']->setData($newReference); // new author object
|
$form['referenceCopy']->setData($newReference); // new author object
|
||||||
@ -447,12 +454,12 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
{
|
{
|
||||||
$author = new FormTest_AuthorWithoutRefSetter(new Author());
|
$author = new FormTest_AuthorWithoutRefSetter(new Author());
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form', $author);
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author);
|
||||||
$builder->add('referenceCopy', 'form', array(
|
$builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType', array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
));
|
));
|
||||||
$builder->get('referenceCopy')->add('firstName', 'text');
|
$builder->get('referenceCopy')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -470,8 +477,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
{
|
{
|
||||||
$author = new FormTest_AuthorWithoutRefSetter('scalar');
|
$author = new FormTest_AuthorWithoutRefSetter('scalar');
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form', $author);
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author);
|
||||||
$builder->add('referenceCopy', 'form');
|
$builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
||||||
function () {},
|
function () {},
|
||||||
function ($value) { // reverseTransform
|
function ($value) { // reverseTransform
|
||||||
@ -495,9 +502,9 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
$ref2 = new Author();
|
$ref2 = new Author();
|
||||||
$author = array('referenceCopy' => $ref1);
|
$author = array('referenceCopy' => $ref1);
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form');
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$builder->setData($author);
|
$builder->setData($author);
|
||||||
$builder->add('referenceCopy', 'form');
|
$builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
$builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer(
|
||||||
function () {},
|
function () {},
|
||||||
function ($value) use ($ref2) { // reverseTransform
|
function ($value) use ($ref2) { // reverseTransform
|
||||||
@ -518,9 +525,9 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testPassMultipartTrueIfAnyChildIsMultipartToView()
|
public function testPassMultipartTrueIfAnyChildIsMultipartToView()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createBuilder('form')
|
$view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('foo', 'text')
|
->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->add('bar', 'file')
|
->add('bar', 'Symfony\Component\Form\Extension\Core\Type\FileType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -529,8 +536,8 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testViewIsNotRenderedByDefault()
|
public function testViewIsNotRenderedByDefault()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createBuilder('form')
|
$view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add('foo', 'form')
|
->add('foo', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm()
|
->getForm()
|
||||||
->createView();
|
->createView();
|
||||||
|
|
||||||
@ -539,7 +546,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testErrorBubblingIfCompound()
|
public function testErrorBubblingIfCompound()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -548,7 +555,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testNoErrorBubblingIfNotCompound()
|
public function testNoErrorBubblingIfNotCompound()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -557,7 +564,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testOverrideErrorBubbling()
|
public function testOverrideErrorBubbling()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
));
|
));
|
||||||
@ -567,7 +574,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testPropertyPath()
|
public function testPropertyPath()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'property_path' => 'foo',
|
'property_path' => 'foo',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -577,7 +584,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testPropertyPathNullImpliesDefault()
|
public function testPropertyPathNullImpliesDefault()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'form', null, array(
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'property_path' => null,
|
'property_path' => null,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -587,7 +594,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testNotMapped()
|
public function testNotMapped()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'property_path' => 'foo',
|
'property_path' => 'foo',
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
));
|
));
|
||||||
@ -598,14 +605,14 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testViewValidNotSubmitted()
|
public function testViewValidNotSubmitted()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->assertTrue($view->vars['valid']);
|
$this->assertTrue($view->vars['valid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testViewNotValidSubmitted()
|
public function testViewNotValidSubmitted()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$form->submit(array());
|
$form->submit(array());
|
||||||
$form->addError(new FormError('An error'));
|
$form->addError(new FormError('An error'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
@ -614,14 +621,14 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testViewSubmittedNotSubmitted()
|
public function testViewSubmittedNotSubmitted()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->assertFalse($view->vars['submitted']);
|
$this->assertFalse($view->vars['submitted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testViewSubmittedSubmitted()
|
public function testViewSubmittedSubmitted()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$form->submit(array());
|
$form->submit(array());
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->assertTrue($view->vars['submitted']);
|
$this->assertTrue($view->vars['submitted']);
|
||||||
@ -629,7 +636,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testDataOptionSupersedesSetDataCalls()
|
public function testDataOptionSupersedesSetDataCalls()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data' => 'default',
|
'data' => 'default',
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
));
|
));
|
||||||
@ -641,7 +648,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testDataOptionSupersedesSetDataCallsIfNull()
|
public function testDataOptionSupersedesSetDataCallsIfNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data' => null,
|
'data' => null,
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
));
|
));
|
||||||
@ -653,7 +660,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testNormDataIsPassedToView()
|
public function testNormDataIsPassedToView()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createBuilder('form')
|
$view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->addViewTransformer(new FixedDataTransformer(array(
|
->addViewTransformer(new FixedDataTransformer(array(
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
)))
|
)))
|
||||||
@ -668,7 +675,7 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
// https://github.com/symfony/symfony/issues/6862
|
// https://github.com/symfony/symfony/issues/6862
|
||||||
public function testPassZeroLabelToView()
|
public function testPassZeroLabelToView()
|
||||||
{
|
{
|
||||||
$view = $this->factory->create('form', null, array(
|
$view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'label' => '0',
|
'label' => '0',
|
||||||
))
|
))
|
||||||
->createView();
|
->createView();
|
||||||
@ -681,12 +688,12 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
public function testCanGetErrorsWhenButtonInForm()
|
public function testCanGetErrorsWhenButtonInForm()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder('form', null, array(
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$builder->add('foo', 'text');
|
$builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
$builder->add('submit', 'submit');
|
$builder->add('submit', 'Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
//This method should not throw a Fatal Error Exception.
|
//This method should not throw a Fatal Error Exception.
|
||||||
@ -695,6 +702,6 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
protected function getTestedType()
|
protected function getTestedType()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'Symfony\Component\Form\Extension\Core\Type\FormType';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,17 @@ class IntegerTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitCastsToInteger()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('integer');
|
$form = $this->factory->create('integer');
|
||||||
|
|
||||||
|
$this->assertSame('integer', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSubmitCastsToInteger()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\IntegerType');
|
||||||
|
|
||||||
$form->submit('1.678');
|
$form->submit('1.678');
|
||||||
|
|
||||||
$this->assertSame(1, $form->getData());
|
$this->assertSame(1, $form->getData());
|
||||||
|
@ -24,9 +24,16 @@ class LanguageTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCountriesAreSelectable()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('language');
|
$form = $this->factory->create('language');
|
||||||
|
|
||||||
|
$this->assertSame('language', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCountriesAreSelectable()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LanguageType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
@ -39,7 +46,7 @@ class LanguageTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testMultipleLanguagesIsNotIncluded()
|
public function testMultipleLanguagesIsNotIncluded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('language', 'language');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LanguageType', 'Symfony\Component\Form\Extension\Core\Type\LanguageType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
|
@ -24,9 +24,16 @@ class LocaleTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocalesAreSelectable()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('locale');
|
$form = $this->factory->create('locale');
|
||||||
|
|
||||||
|
$this->assertSame('locale', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLocalesAreSelectable()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LocaleType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
|
@ -25,11 +25,18 @@ class MoneyTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('money');
|
||||||
|
|
||||||
|
$this->assertSame('money', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testPassMoneyPatternToView()
|
public function testPassMoneyPatternToView()
|
||||||
{
|
{
|
||||||
\Locale::setDefault('de_DE');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('money');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
$this->assertSame('{{ widget }} €', $view->vars['money_pattern']);
|
$this->assertSame('{{ widget }} €', $view->vars['money_pattern']);
|
||||||
@ -39,7 +46,7 @@ class MoneyTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
\Locale::setDefault('en_US');
|
\Locale::setDefault('en_US');
|
||||||
|
|
||||||
$form = $this->factory->create('money', null, array('currency' => 'JPY'));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'JPY'));
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$this->assertTrue((bool) strstr($view->vars['money_pattern'], '¥'));
|
$this->assertTrue((bool) strstr($view->vars['money_pattern'], '¥'));
|
||||||
}
|
}
|
||||||
@ -49,8 +56,8 @@ class MoneyTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
\Locale::setDefault('de_DE');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form1 = $this->factory->create('money', null, array('currency' => 'GBP'));
|
$form1 = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'GBP'));
|
||||||
$form2 = $this->factory->create('money', null, array('currency' => 'EUR'));
|
$form2 = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'EUR'));
|
||||||
$view1 = $form1->createView();
|
$view1 = $form1->createView();
|
||||||
$view2 = $form2->createView();
|
$view2 = $form2->createView();
|
||||||
|
|
||||||
|
@ -26,9 +26,16 @@ class NumberTypeTest extends TestCase
|
|||||||
\Locale::setDefault('de_DE');
|
\Locale::setDefault('de_DE');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultFormatting()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('number');
|
$form = $this->factory->create('number');
|
||||||
|
|
||||||
|
$this->assertSame('number', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefaultFormatting()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType');
|
||||||
$form->setData('12345.67890');
|
$form->setData('12345.67890');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -37,7 +44,7 @@ class NumberTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDefaultFormattingWithGrouping()
|
public function testDefaultFormattingWithGrouping()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('number', null, array('grouping' => true));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('grouping' => true));
|
||||||
$form->setData('12345.67890');
|
$form->setData('12345.67890');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -46,7 +53,7 @@ class NumberTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDefaultFormattingWithScale()
|
public function testDefaultFormattingWithScale()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('number', null, array('scale' => 2));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('scale' => 2));
|
||||||
$form->setData('12345.67890');
|
$form->setData('12345.67890');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -55,7 +62,7 @@ class NumberTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDefaultFormattingWithRounding()
|
public function testDefaultFormattingWithRounding()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('number', null, array('scale' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('scale' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP));
|
||||||
$form->setData('12345.54321');
|
$form->setData('12345.54321');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
|
@ -13,9 +13,16 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
|
|
||||||
class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testEmptyIfNotSubmitted()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('password');
|
$form = $this->factory->create('password');
|
||||||
|
|
||||||
|
$this->assertSame('password', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEmptyIfNotSubmitted()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType');
|
||||||
$form->setData('pAs5w0rd');
|
$form->setData('pAs5w0rd');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -24,7 +31,7 @@ class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testEmptyIfSubmitted()
|
public function testEmptyIfSubmitted()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('password');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType');
|
||||||
$form->submit('pAs5w0rd');
|
$form->submit('pAs5w0rd');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -33,7 +40,7 @@ class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNotEmptyIfSubmittedAndNotAlwaysEmpty()
|
public function testNotEmptyIfSubmittedAndNotAlwaysEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('password', null, array('always_empty' => false));
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array('always_empty' => false));
|
||||||
$form->submit('pAs5w0rd');
|
$form->submit('pAs5w0rd');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
@ -42,7 +49,7 @@ class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testNotTrimmed()
|
public function testNotTrimmed()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('password', null);
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType', null);
|
||||||
$form->submit(' pAs5w0rd ');
|
$form->submit(' pAs5w0rd ');
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
|
||||||
|
@ -19,12 +19,21 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->form = $this->factory->create('repeated', null, array(
|
$this->form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
$this->form->setData(null);
|
$this->form->setData(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('repeated', array(
|
||||||
|
'type' => 'text',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertSame('repeated', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetData()
|
public function testSetData()
|
||||||
{
|
{
|
||||||
$this->form->setData('foobar');
|
$this->form->setData('foobar');
|
||||||
@ -35,8 +44,8 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetOptions()
|
public function testSetOptions()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'options' => array('label' => 'Global'),
|
'options' => array('label' => 'Global'),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -48,9 +57,9 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetOptionsPerChild()
|
public function testSetOptionsPerChild()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
// the global required value cannot be overridden
|
// the global required value cannot be overridden
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'first_options' => array('label' => 'Test', 'required' => false),
|
'first_options' => array('label' => 'Test', 'required' => false),
|
||||||
'second_options' => array('label' => 'Test2'),
|
'second_options' => array('label' => 'Test2'),
|
||||||
));
|
));
|
||||||
@ -63,9 +72,9 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetRequired()
|
public function testSetRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertFalse($form['first']->isRequired());
|
$this->assertFalse($form['first']->isRequired());
|
||||||
@ -77,8 +86,8 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetInvalidOptions()
|
public function testSetInvalidOptions()
|
||||||
{
|
{
|
||||||
$this->factory->create('repeated', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'options' => 'bad value',
|
'options' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -88,8 +97,8 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetInvalidFirstOptions()
|
public function testSetInvalidFirstOptions()
|
||||||
{
|
{
|
||||||
$this->factory->create('repeated', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'first_options' => 'bad value',
|
'first_options' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -99,15 +108,15 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetInvalidSecondOptions()
|
public function testSetInvalidSecondOptions()
|
||||||
{
|
{
|
||||||
$this->factory->create('repeated', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'second_options' => 'bad value',
|
'second_options' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetErrorBubblingToTrue()
|
public function testSetErrorBubblingToTrue()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -118,7 +127,7 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetErrorBubblingToFalse()
|
public function testSetErrorBubblingToFalse()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -129,7 +138,7 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetErrorBubblingIndividually()
|
public function testSetErrorBubblingIndividually()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
'options' => array('error_bubbling' => false),
|
'options' => array('error_bubbling' => false),
|
||||||
'second_options' => array('error_bubbling' => true),
|
'second_options' => array('error_bubbling' => true),
|
||||||
@ -142,8 +151,8 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
|
|
||||||
public function testSetOptionsPerChildAndOverwrite()
|
public function testSetOptionsPerChildAndOverwrite()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('repeated', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array(
|
||||||
'type' => 'text',
|
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||||
'options' => array('label' => 'Label'),
|
'options' => array('label' => 'Label'),
|
||||||
'second_options' => array('label' => 'Second label'),
|
'second_options' => array('label' => 'Second label'),
|
||||||
));
|
));
|
||||||
|
@ -18,21 +18,28 @@ use Symfony\Component\Form\Test\TypeTestCase as TestCase;
|
|||||||
*/
|
*/
|
||||||
class SubmitTypeTest extends TestCase
|
class SubmitTypeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('submit');
|
||||||
|
|
||||||
|
$this->assertSame('submit', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateSubmitButtonInstances()
|
public function testCreateSubmitButtonInstances()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('submit'));
|
$this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNotClickedByDefault()
|
public function testNotClickedByDefault()
|
||||||
{
|
{
|
||||||
$button = $this->factory->create('submit');
|
$button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
|
|
||||||
$this->assertFalse($button->isClicked());
|
$this->assertFalse($button->isClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNotClickedIfSubmittedWithNull()
|
public function testNotClickedIfSubmittedWithNull()
|
||||||
{
|
{
|
||||||
$button = $this->factory->create('submit');
|
$button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
$button->submit(null);
|
$button->submit(null);
|
||||||
|
|
||||||
$this->assertFalse($button->isClicked());
|
$this->assertFalse($button->isClicked());
|
||||||
@ -40,7 +47,7 @@ class SubmitTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testClickedIfSubmittedWithEmptyString()
|
public function testClickedIfSubmittedWithEmptyString()
|
||||||
{
|
{
|
||||||
$button = $this->factory->create('submit');
|
$button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
$button->submit('');
|
$button->submit('');
|
||||||
|
|
||||||
$this->assertTrue($button->isClicked());
|
$this->assertTrue($button->isClicked());
|
||||||
@ -48,7 +55,7 @@ class SubmitTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testClickedIfSubmittedWithUnemptyString()
|
public function testClickedIfSubmittedWithUnemptyString()
|
||||||
{
|
{
|
||||||
$button = $this->factory->create('submit');
|
$button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType');
|
||||||
$button->submit('foo');
|
$button->submit('foo');
|
||||||
|
|
||||||
$this->assertTrue($button->isClicked());
|
$this->assertTrue($button->isClicked());
|
||||||
@ -57,9 +64,9 @@ class SubmitTypeTest extends TestCase
|
|||||||
public function testSubmitCanBeAddedToForm()
|
public function testSubmitCanBeAddedToForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createBuilder('form')
|
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$this->assertSame($form, $form->add('send', 'submit'));
|
$this->assertSame($form, $form->add('send', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,16 @@ class TimeTypeTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('time');
|
||||||
|
|
||||||
|
$this->assertSame('time', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSubmitDateTime()
|
public function testSubmitDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -48,7 +55,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitString()
|
public function testSubmitString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -67,7 +74,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitTimestamp()
|
public function testSubmitTimestamp()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
@ -88,7 +95,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitArray()
|
public function testSubmitArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -107,7 +114,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitDatetimeSingleText()
|
public function testSubmitDatetimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -122,7 +129,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -138,7 +145,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitArraySingleText()
|
public function testSubmitArraySingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -158,7 +165,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitArraySingleTextWithoutMinutes()
|
public function testSubmitArraySingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -178,7 +185,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitArraySingleTextWithSeconds()
|
public function testSubmitArraySingleTextWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -200,7 +207,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitStringSingleText()
|
public function testSubmitStringSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -215,7 +222,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitStringSingleTextWithoutMinutes()
|
public function testSubmitStringSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -231,7 +238,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataWithoutMinutes()
|
public function testSetDataWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -245,7 +252,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataWithSeconds()
|
public function testSetDataWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -259,7 +266,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataDifferentTimezones()
|
public function testSetDataDifferentTimezones()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'America/New_York',
|
'model_timezone' => 'America/New_York',
|
||||||
'view_timezone' => 'Asia/Hong_Kong',
|
'view_timezone' => 'Asia/Hong_Kong',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -285,7 +292,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataDifferentTimezonesDateTime()
|
public function testSetDataDifferentTimezonesDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'model_timezone' => 'America/New_York',
|
'model_timezone' => 'America/New_York',
|
||||||
'view_timezone' => 'Asia/Hong_Kong',
|
'view_timezone' => 'Asia/Hong_Kong',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -312,7 +319,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testHoursOption()
|
public function testHoursOption()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'hours' => array(6, 7),
|
'hours' => array(6, 7),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -326,7 +333,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testIsMinuteWithinRangeReturnsTrueIfWithin()
|
public function testIsMinuteWithinRangeReturnsTrueIfWithin()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'minutes' => array(6, 7),
|
'minutes' => array(6, 7),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -340,7 +347,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testIsSecondWithinRangeReturnsTrueIfWithin()
|
public function testIsSecondWithinRangeReturnsTrueIfWithin()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'seconds' => array(6, 7),
|
'seconds' => array(6, 7),
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -357,7 +364,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -373,7 +380,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -391,7 +398,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -407,7 +414,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -425,7 +432,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -443,7 +450,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -461,7 +468,7 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -480,12 +487,12 @@ class TimeTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Throws an exception if "data_class" option is not explicitly set
|
// Throws an exception if "data_class" option is not explicitly set
|
||||||
// to null in the type
|
// to null in the type
|
||||||
$this->factory->create('time', new \DateTime());
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', new \DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleTextWidgetShouldUseTheRightInputType()
|
public function testSingleTextWidgetShouldUseTheRightInputType()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -495,7 +502,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute()
|
public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -507,7 +514,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute()
|
public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
'attr' => array(
|
'attr' => array(
|
||||||
@ -522,7 +529,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
public function testDontPassHtml5TypeIfHtml5NotAllowed()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'html5' => false,
|
'html5' => false,
|
||||||
));
|
));
|
||||||
@ -533,7 +540,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
public function testPassDefaultPlaceholderToViewIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -546,7 +553,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassNoPlaceholderToViewIfRequired()
|
public function testPassNoPlaceholderToViewIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -559,7 +566,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsString()
|
public function testPassPlaceholderAsString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'placeholder' => 'Empty',
|
'placeholder' => 'Empty',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -572,7 +579,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassEmptyValueBC()
|
public function testPassEmptyValueBC()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'empty_value' => 'Empty',
|
'empty_value' => 'Empty',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -588,7 +595,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsArray()
|
public function testPassPlaceholderAsArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'hour' => 'Empty hour',
|
'hour' => 'Empty hour',
|
||||||
'minute' => 'Empty minute',
|
'minute' => 'Empty minute',
|
||||||
@ -605,7 +612,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'hour' => 'Empty hour',
|
'hour' => 'Empty hour',
|
||||||
@ -622,7 +629,7 @@ class TimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
public function testPassPlaceholderAsPartialArrayAddNullIfRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'placeholder' => array(
|
'placeholder' => array(
|
||||||
'hour' => 'Empty hour',
|
'hour' => 'Empty hour',
|
||||||
@ -651,7 +658,7 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testHourErrorsBubbleUp($widget)
|
public function testHourErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
));
|
));
|
||||||
$form['hour']->addError($error);
|
$form['hour']->addError($error);
|
||||||
@ -666,7 +673,7 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testMinuteErrorsBubbleUp($widget)
|
public function testMinuteErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
));
|
));
|
||||||
$form['minute']->addError($error);
|
$form['minute']->addError($error);
|
||||||
@ -681,7 +688,7 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSecondErrorsBubbleUp($widget)
|
public function testSecondErrorsBubbleUp($widget)
|
||||||
{
|
{
|
||||||
$error = new FormError('Invalid!');
|
$error = new FormError('Invalid!');
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'widget' => $widget,
|
'widget' => $widget,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -696,7 +703,7 @@ class TimeTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInitializeWithSecondsAndWithoutMinutes()
|
public function testInitializeWithSecondsAndWithoutMinutes()
|
||||||
{
|
{
|
||||||
$this->factory->create('time', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -707,7 +714,7 @@ class TimeTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfHoursIsInvalid()
|
public function testThrowExceptionIfHoursIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('time', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'hours' => 'bad value',
|
'hours' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -717,7 +724,7 @@ class TimeTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfMinutesIsInvalid()
|
public function testThrowExceptionIfMinutesIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('time', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'minutes' => 'bad value',
|
'minutes' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -727,7 +734,7 @@ class TimeTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfSecondsIsInvalid()
|
public function testThrowExceptionIfSecondsIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('time', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array(
|
||||||
'seconds' => 'bad value',
|
'seconds' => 'bad value',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,16 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
|||||||
|
|
||||||
class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testTimezonesAreSelectable()
|
public function testLegacyName()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('timezone');
|
$form = $this->factory->create('timezone');
|
||||||
|
|
||||||
|
$this->assertSame('timezone', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTimezonesAreSelectable()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimezoneType');
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
$choices = $view->vars['choices'];
|
$choices = $view->vars['choices'];
|
||||||
|
|
||||||
|
@ -15,9 +15,16 @@ use Symfony\Component\Form\Test\TypeTestCase as TestCase;
|
|||||||
|
|
||||||
class UrlTypeTest extends TestCase
|
class UrlTypeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public function testLegacyName()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('url');
|
||||||
|
|
||||||
|
$this->assertSame('url', $form->getConfig()->getType()->getName());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
|
public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('url', 'name');
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', 'name');
|
||||||
|
|
||||||
$form->submit('www.domain.com');
|
$form->submit('www.domain.com');
|
||||||
|
|
||||||
@ -27,7 +34,7 @@ class UrlTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded()
|
public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('url', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array(
|
||||||
'default_protocol' => 'http',
|
'default_protocol' => 'http',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -39,7 +46,7 @@ class UrlTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitAddsNoDefaultProtocolIfEmpty()
|
public function testSubmitAddsNoDefaultProtocolIfEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('url', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array(
|
||||||
'default_protocol' => 'http',
|
'default_protocol' => 'http',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -51,7 +58,7 @@ class UrlTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitAddsNoDefaultProtocolIfNull()
|
public function testSubmitAddsNoDefaultProtocolIfNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('url', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array(
|
||||||
'default_protocol' => 'http',
|
'default_protocol' => 'http',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -63,7 +70,7 @@ class UrlTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSubmitAddsNoDefaultProtocolIfSetToNull()
|
public function testSubmitAddsNoDefaultProtocolIfSetToNull()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('url', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array(
|
||||||
'default_protocol' => null,
|
'default_protocol' => null,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -78,7 +85,7 @@ class UrlTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testThrowExceptionIfDefaultProtocolIsInvalid()
|
public function testThrowExceptionIfDefaultProtocolIsInvalid()
|
||||||
{
|
{
|
||||||
$this->factory->create('url', null, array(
|
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array(
|
||||||
'default_protocol' => array(),
|
'default_protocol' => array(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,7 @@ class FormTypeCsrfExtensionTest_ChildType extends AbstractType
|
|||||||
{
|
{
|
||||||
// The form needs a child in order to trigger CSRF protection by
|
// The form needs a child in order to trigger CSRF protection by
|
||||||
// default
|
// default
|
||||||
$builder->add('name', 'text');
|
$builder->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||||
}
|
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'csrf_collection_test';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +66,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
public function testCsrfProtectionByDefaultIfRootAndCompound()
|
public function testCsrfProtectionByDefaultIfRootAndCompound()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->create('form', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
@ -83,9 +78,9 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
|
public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamedBuilder('root', 'form')
|
->createNamedBuilder('root', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
->createNamedBuilder('form', 'form', null, array(
|
->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
@ -100,7 +95,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
|
public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->create('form', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
))
|
))
|
||||||
@ -112,7 +107,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
public function testCsrfProtectionCanBeDisabled()
|
public function testCsrfProtectionCanBeDisabled()
|
||||||
{
|
{
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->create('form', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_protection' => false,
|
'csrf_protection' => false,
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
@ -130,7 +125,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token')));
|
->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token')));
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->create('form', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_token_id' => 'TOKEN_ID',
|
'csrf_token_id' => 'TOKEN_ID',
|
||||||
@ -149,7 +144,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue('token'));
|
->will($this->returnValue('token'));
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('FORM_NAME', 'form', null, array(
|
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
@ -167,7 +162,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue('token'));
|
->will($this->returnValue('token'));
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('', 'form', null, array(
|
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
@ -196,13 +191,13 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue($valid));
|
->will($this->returnValue($valid));
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createBuilder('form', null, array(
|
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_token_id' => 'TOKEN_ID',
|
'csrf_token_id' => 'TOKEN_ID',
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
->add('child', 'text')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -228,12 +223,12 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue($valid));
|
->will($this->returnValue($valid));
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createNamedBuilder('FORM_NAME', 'form', null, array(
|
->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
->add('child', 'text')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -259,12 +254,12 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue($valid));
|
->will($this->returnValue($valid));
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createNamedBuilder('', 'form', null, array(
|
->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
->add('child', 'text')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -285,13 +280,13 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->method('isTokenValid');
|
->method('isTokenValid');
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createBuilder('form', null, array(
|
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_token_id' => 'TOKEN_ID',
|
'csrf_token_id' => 'TOKEN_ID',
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
))
|
))
|
||||||
->add('child', 'text')
|
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
$form->submit(array(
|
$form->submit(array(
|
||||||
@ -312,9 +307,9 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->method('isTokenValid');
|
->method('isTokenValid');
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createNamedBuilder('root', 'form')
|
->createNamedBuilder('root', 'Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->add($this->factory
|
->add($this->factory
|
||||||
->createNamedBuilder('form', 'form', null, array(
|
->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_token_id' => 'TOKEN_ID',
|
'csrf_token_id' => 'TOKEN_ID',
|
||||||
@ -336,7 +331,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->method('isTokenValid');
|
->method('isTokenValid');
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->create('form', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_token_id' => 'TOKEN_ID',
|
'csrf_token_id' => 'TOKEN_ID',
|
||||||
@ -351,8 +346,8 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
public function testNoCsrfProtectionOnPrototype()
|
public function testNoCsrfProtectionOnPrototype()
|
||||||
{
|
{
|
||||||
$prototypeView = $this->factory
|
$prototypeView = $this->factory
|
||||||
->create('collection', null, array(
|
->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
|
||||||
'type' => new FormTypeCsrfExtensionTest_ChildType(),
|
'type' => __CLASS__.'_ChildType',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
),
|
),
|
||||||
@ -379,7 +374,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
->will($this->returnValue('[trans]Foobar[/trans]'));
|
->will($this->returnValue('[trans]Foobar[/trans]'));
|
||||||
|
|
||||||
$form = $this->factory
|
$form = $this->factory
|
||||||
->createBuilder('form', null, array(
|
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||||
'csrf_field_name' => 'csrf',
|
'csrf_field_name' => 'csrf',
|
||||||
'csrf_token_manager' => $this->tokenManager,
|
'csrf_token_manager' => $this->tokenManager,
|
||||||
'csrf_message' => 'Foobar',
|
'csrf_message' => 'Foobar',
|
||||||
|
@ -36,10 +36,10 @@ class FormValidatorPerformanceTest extends FormPerformanceTestCase
|
|||||||
{
|
{
|
||||||
$this->setMaxRunningTime(1);
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
$builder = $this->factory->createBuilder('form');
|
$builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
|
|
||||||
for ($i = 0; $i < 40; ++$i) {
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
$builder->add($i, 'form');
|
$builder->add($i, 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
|
|
||||||
$builder->get($i)
|
$builder->get($i)
|
||||||
->add('a')
|
->add('a')
|
||||||
|
@ -20,13 +20,13 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
|
|||||||
public function testSubmitValidatesData()
|
public function testSubmitValidatesData()
|
||||||
{
|
{
|
||||||
$builder = $this->factory->createBuilder(
|
$builder = $this->factory->createBuilder(
|
||||||
'form',
|
'Symfony\Component\Form\Extension\Core\Type\FormType',
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'validation_groups' => 'group',
|
'validation_groups' => 'group',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$builder->add('firstName', 'form');
|
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
|
||||||
$this->validator->expects($this->once())
|
$this->validator->expects($this->once())
|
||||||
@ -93,6 +93,6 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
|
|||||||
|
|
||||||
protected function createForm(array $options = array())
|
protected function createForm(array $options = array())
|
||||||
{
|
{
|
||||||
return $this->factory->create('form', null, $options);
|
return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest
|
|||||||
{
|
{
|
||||||
protected function createForm(array $options = array())
|
protected function createForm(array $options = array())
|
||||||
{
|
{
|
||||||
return $this->factory->create('submit', null, $options);
|
return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType', null, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,10 @@ class AlternatingRowType extends AbstractType
|
|||||||
|
|
||||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) {
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) {
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
$type = $form->getName() % 2 === 0 ? 'text' : 'textarea';
|
$type = $form->getName() % 2 === 0
|
||||||
|
? 'Symfony\Component\Form\Extension\Core\Type\TextType'
|
||||||
|
: 'Symfony\Component\Form\Extension\Core\Type\TextareaType';
|
||||||
$form->add('title', $type);
|
$form->add('title', $type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'alternating_row';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,6 @@ class AuthorType extends AbstractType
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'author';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
|
18
src/Symfony/Component/Form/Tests/Fixtures/FBooType.php
Normal file
18
src/Symfony/Component/Form/Tests/Fixtures/FBooType.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
|
||||||
|
class FBooType extends AbstractType
|
||||||
|
{
|
||||||
|
}
|
18
src/Symfony/Component/Form/Tests/Fixtures/Foo.php
Normal file
18
src/Symfony/Component/Form/Tests/Fixtures/Foo.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
|
||||||
|
class Foo extends AbstractType
|
||||||
|
{
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user