[Form] Consolidated FormInterface, FormBuilderInterface and FormViewInterface

This commit is contained in:
Bernhard Schussek 2012-05-24 14:24:28 +02:00
parent 8e128fc644
commit 98a7c0cf5f
41 changed files with 361 additions and 264 deletions

View File

@ -468,9 +468,8 @@
* `getAttribute`
* `hasAttribute`
* `getClientData`
The method `getClientData` has a new equivalent that is named `getViewData`.
You can access all other methods on the `FormConfigInterface` object instead.
* `getChildren`
* `hasChildren`
Before:
@ -484,6 +483,24 @@
$form->getConfig()->getErrorBubbling();
```
The method `getClientData` has a new equivalent that is named `getViewData`.
You can access all other methods on the `FormConfigInterface` object instead.
Instead of `getChildren` and `hasChildren`, you should now use `all` and
`count` instead.
Before:
```
if ($form->hasChildren()) {
```
After:
```
if (count($form) > 0) {
```
* The option "validation_constraint" is deprecated and will be removed
in Symfony 2.3. You should use the option "constraints" instead,
where you can pass one or more constraints for a form.
@ -717,6 +734,34 @@
$form = $factory->createNamed('firstName', 'text');
```
* The methods in class `FormView` were renamed to match the naming used in
`Form` and `FormBuilder`. The following list shows the old names on the
left and the new names on the right:
* `set`: `setVar`
* `has`: `hasVar`
* `get`: `getVar`
* `all`: `getVars`
* `addChild`: `add`
* `getChild`: `get`
* `getChildren`: `all`
* `removeChild`: `remove`
* `hasChild`: `has`
The method `hasChildren` was deprecated. You should use `count` instead.
Before:
```
$view->set('help', 'A text longer than six characters');
```
After:
```
$view->setVar('help', 'A text longer than six characters');
```
### Validator
* The methods `setMessage()`, `getMessageTemplate()` and

View File

@ -115,7 +115,7 @@ class EntityTypeTest extends TypeTestCase
'property' => 'name'
));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->get('choices'));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->getVar('choices'));
}
public function testSetDataToUninitializedEntityWithNonRequiredToString()
@ -131,7 +131,7 @@ class EntityTypeTest extends TypeTestCase
'required' => false,
));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->get('choices'));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->getVar('choices'));
}
public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder()
@ -150,7 +150,7 @@ class EntityTypeTest extends TypeTestCase
'query_builder' => $qb
));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->get('choices'));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->getVar('choices'));
}
/**
@ -494,7 +494,7 @@ class EntityTypeTest extends TypeTestCase
$field->bind('2');
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->get('choices'));
$this->assertEquals(array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')), $field->createView()->getVar('choices'));
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
$this->assertSame('2', $field->getClientData());
@ -524,7 +524,7 @@ class EntityTypeTest extends TypeTestCase
'Group1' => array(1 => new ChoiceView('1', 'Foo'), 2 => new ChoiceView('2', 'Bar')),
'Group2' => array(3 => new ChoiceView('3', 'Baz')),
'4' => new ChoiceView('4', 'Boo!')
), $field->createView()->get('choices'));
), $field->createView()->getVar('choices'));
}
public function testDisallowChoicesThatAreNotIncluded_choicesSingleIdentifier()

View File

@ -98,7 +98,7 @@ class FormExtension extends \Twig_Extension
public function isChoiceSelected(FormView $view, ChoiceView $choice)
{
return FormUtil::isChoiceSelected($choice->getValue(), $view->get('value'));
return FormUtil::isChoiceSelected($choice->getValue(), $view->getVar('value'));
}
/**
@ -228,7 +228,7 @@ class FormExtension extends \Twig_Extension
}
}
$custom = '_'.$view->get('id');
$custom = '_'.$view->getVar('id');
$rendering = $custom.$section;
$blocks = $this->getBlocks($view);
@ -237,11 +237,11 @@ class FormExtension extends \Twig_Extension
$types = $this->varStack[$rendering]['types'];
$this->varStack[$rendering]['variables'] = array_replace_recursive($this->varStack[$rendering]['variables'], $variables);
} else {
$types = $view->get('types');
$types = $view->getVar('types');
$types[] = $custom;
$typeIndex = count($types) - 1;
$this->varStack[$rendering] = array(
'variables' => array_replace_recursive($view->all(), $variables),
'variables' => array_replace_recursive($view->getVars(), $variables),
'types' => $types,
);
}

View File

@ -1 +1 @@
<?php if ($form->get('multipart')): ?>enctype="multipart/form-data"<?php endif ?>
<?php if ($form->getVar('multipart')): ?>enctype="multipart/form-data"<?php endif ?>

View File

@ -66,7 +66,7 @@ class FormHelper extends Helper
public function isChoiceSelected(FormView $view, ChoiceView $choice)
{
return FormUtil::isChoiceSelected($choice->getValue(), $view->get('value'));
return FormUtil::isChoiceSelected($choice->getValue(), $view->getVar('value'));
}
/**
@ -79,7 +79,7 @@ class FormHelper extends Helper
*/
public function setTheme(FormView $view, $themes)
{
$this->themes[$view->get('id')] = (array) $themes;
$this->themes[$view->getVar('id')] = (array) $themes;
$this->templates = array();
}
@ -237,7 +237,7 @@ class FormHelper extends Helper
$template = null;
$custom = '_'.$view->get('id');
$custom = '_'.$view->getVar('id');
$rendering = $custom.$section;
if (isset($this->varStack[$rendering])) {
@ -245,10 +245,10 @@ class FormHelper extends Helper
$types = $this->varStack[$rendering]['types'];
$variables = array_replace_recursive($this->varStack[$rendering]['variables'], $variables);
} else {
$types = $view->get('types');
$types = $view->getVar('types');
$types[] = $custom;
$typeIndex = count($types) - 1;
$variables = array_replace_recursive($view->all(), $variables);
$variables = array_replace_recursive($view->getVars(), $variables);
$this->varStack[$rendering]['types'] = $types;
}
@ -330,7 +330,7 @@ class FormHelper extends Helper
protected function lookupTemplate(FormView $view, $block)
{
$file = $block.'.html.php';
$id = $view->get('id');
$id = $view->getVar('id');
if (!isset($this->templates[$id][$block])) {
$template = false;

View File

@ -133,3 +133,8 @@ CHANGELOG
FormEvents::BIND_NORM_DATA
* [BC BREAK] reversed the order of the first two arguments to `createNamed`
and `createNamedBuilder` in `FormFactoryInterface`
* [BC BREAK] adapted methods of FormView to match the naming used in
FormInterface and FormBuilder
* deprecated `getChildren` in Form and FormBuilder in favor of `all`
* deprecated `hasChildren` in Form and FormBuilder in favor of `count`
* FormBuilder now implements \IteratorAggregate

View File

@ -35,10 +35,10 @@ class CheckboxType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('value', $options['value'])
->set('checked', null !== $form->getViewData())
;
$view->setVars(array(
'value' => $options['value'],
'checked' => null !== $form->getViewData(),
));
}
/**

View File

@ -75,20 +75,20 @@ class ChoiceType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('multiple', $options['multiple'])
->set('expanded', $options['expanded'])
->set('preferred_choices', $options['choice_list']->getPreferredViews())
->set('choices', $options['choice_list']->getRemainingViews())
->set('separator', '-------------------')
->set('empty_value', $options['empty_value'])
;
$view->setVars(array(
'multiple' => $options['multiple'],
'expanded' => $options['expanded'],
'preferred_choices' => $options['choice_list']->getPreferredViews(),
'choices' => $options['choice_list']->getRemainingViews(),
'separator' => '-------------------',
'empty_value' => $options['empty_value'],
));
if ($options['multiple'] && !$options['expanded']) {
// Add "[]" to the name in case a select tag with multiple options is
// displayed. Otherwise only one of the selected options is sent in the
// POST request.
$view->set('full_name', $view->get('full_name').'[]');
$view->setVar('full_name', $view->getVar('full_name').'[]');
}
}
@ -99,15 +99,15 @@ class ChoiceType extends AbstractType
{
if ($options['expanded']) {
// Radio buttons should have the same name as the parent
$childName = $view->get('full_name');
$childName = $view->getVar('full_name');
// Checkboxes should append "[]" to allow multiple selection
if ($options['multiple']) {
$childName .= '[]';
}
foreach ($view->getChildren() as $childView) {
$childView->set('full_name', $childName);
foreach ($view as $childView) {
$childView->setVar('full_name', $childName);
}
}
}

View File

@ -48,13 +48,13 @@ class CollectionType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('allow_add', $options['allow_add'])
->set('allow_delete', $options['allow_delete'])
;
$view->setVars(array(
'allow_add' => $options['allow_add'],
'allow_delete' => $options['allow_delete'],
));
if ($form->getConfig()->hasAttribute('prototype')) {
$view->set('prototype', $form->getConfig()->getAttribute('prototype')->createView($view));
$view->setVar('prototype', $form->getConfig()->getAttribute('prototype')->createView($view));
}
}
@ -63,8 +63,8 @@ class CollectionType extends AbstractType
*/
public function finishView(FormViewInterface $view, FormInterface $form, array $options)
{
if ($form->getConfig()->hasAttribute('prototype') && $view->get('prototype')->get('multipart')) {
$view->set('multipart', true);
if ($form->getConfig()->hasAttribute('prototype') && $view->getVar('prototype')->getVar('multipart')) {
$view->setVar('multipart', true);
}
}

View File

@ -118,10 +118,10 @@ class DateTimeType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view->set('widget', $options['widget']);
$view->setVar('widget', $options['widget']);
if ('single_text' === $options['widget']) {
$view->set('type', 'datetime');
$view->setVar('type', 'datetime');
}
}

View File

@ -138,10 +138,10 @@ class DateType extends AbstractType
*/
public function finishView(FormViewInterface $view, FormInterface $form, array $options)
{
$view->set('widget', $options['widget']);
$view->setVar('widget', $options['widget']);
if ('single_text' === $options['widget']) {
$view->set('type', 'date');
$view->setVar('type', 'date');
}
if ($view->hasChildren()) {
@ -156,7 +156,7 @@ class DateType extends AbstractType
$pattern = '{{ year }}-{{ month }}-{{ day }}';
}
$view->set('date_pattern', $pattern);
$view->setVar('date_pattern', $pattern);
}
}

View File

@ -23,10 +23,10 @@ class FileType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('type', 'file')
->set('value', '')
;
$view->setVars(array(
'type' => 'file',
'value' => '',
));
}
/**
@ -35,7 +35,7 @@ class FileType extends AbstractType
public function finishView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('multipart', true)
->setVar('multipart', true)
;
}

View File

@ -64,8 +64,8 @@ class FormType extends AbstractType
throw new FormException('Form node with empty name can be used only as root form node.');
}
if ('' !== ($parentFullName = $view->getParent()->get('full_name'))) {
$id = sprintf('%s_%s', $view->getParent()->get('id'), $name);
if ('' !== ($parentFullName = $view->getParent()->getVar('full_name'))) {
$id = sprintf('%s_%s', $view->getParent()->getVar('id'), $name);
$fullName = sprintf('%s[%s]', $parentFullName, $name);
} else {
$id = $name;
@ -73,7 +73,7 @@ class FormType extends AbstractType
}
// Complex fields are read-only if themselves or their parent is.
$readOnly = $readOnly || $view->getParent()->get('read_only');
$readOnly = $readOnly || $view->getParent()->getVar('read_only');
} else {
$id = $name;
$fullName = $name;
@ -89,28 +89,28 @@ class FormType extends AbstractType
$types[] = $type->getName();
}
$view
->set('form', $view)
->set('id', $id)
->set('name', $name)
->set('full_name', $fullName)
->set('read_only', $readOnly)
->set('errors', $form->getErrors())
->set('valid', $form->isBound() ? $form->isValid() : true)
->set('value', $form->getViewData())
->set('disabled', $form->isDisabled())
->set('required', $form->isRequired())
->set('max_length', $options['max_length'])
->set('pattern', $options['pattern'])
->set('size', null)
->set('label', $options['label'] ?: $this->humanize($form->getName()))
->set('multipart', false)
->set('attr', $options['attr'])
->set('label_attr', $options['label_attr'])
->set('single_control', $options['single_control'])
->set('types', $types)
->set('translation_domain', $options['translation_domain'])
;
$view->setVars(array(
'form' => $view,
'id' => $id,
'name' => $name,
'full_name' => $fullName,
'read_only' => $readOnly,
'errors' => $form->getErrors(),
'valid' => $form->isBound() ? $form->isValid() : true,
'value' => $form->getViewData(),
'disabled' => $form->isDisabled(),
'required' => $form->isRequired(),
'max_length' => $options['max_length'],
'pattern' => $options['pattern'],
'size' => null,
'label' => $options['label'] ?: $this->humanize($form->getName()),
'multipart' => false,
'attr' => $options['attr'],
'label_attr' => $options['label_attr'],
'single_control' => $options['single_control'],
'types' => $types,
'translation_domain' => $options['translation_domain'],
));
}
/**
@ -120,14 +120,14 @@ class FormType extends AbstractType
{
$multipart = false;
foreach ($view->getChildren() as $child) {
if ($child->get('multipart')) {
foreach ($view as $child) {
if ($child->getVar('multipart')) {
$multipart = true;
break;
}
}
$view->set('multipart', $multipart);
$view->setVar('multipart', $multipart);
}
/**

View File

@ -42,7 +42,7 @@ class MoneyType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view->set('money_pattern', self::getPattern($options['currency']));
$view->setVar('money_pattern', self::getPattern($options['currency']));
}
/**

View File

@ -25,7 +25,7 @@ class PasswordType extends AbstractType
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
if ($options['always_empty'] || !$form->isBound()) {
$view->set('value', '');
$view->setVar('value', '');
}
}

View File

@ -22,7 +22,7 @@ class TextareaType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view->set('pattern', null);
$view->setVar('pattern', null);
}
/**

View File

@ -115,13 +115,13 @@ class TimeType extends AbstractType
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$view
->set('widget', $options['widget'])
->set('with_seconds', $options['with_seconds'])
;
$view->setVars(array(
'widget' => $options['widget'],
'with_seconds' => $options['with_seconds'],
));
if ('single_text' === $options['widget']) {
$view->set('type', 'time');
$view->setVar('type', 'time');
}
}

View File

@ -69,7 +69,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
'property_path' => false,
));
$view->addChild($csrfForm->createView($view));
$view->add($csrfForm->createView($view));
}
}

View File

@ -279,7 +279,7 @@ class ViolationMapper implements ViolationMapperInterface
{
$this->scope = $form;
$this->children = new \RecursiveIteratorIterator(
new VirtualFormAwareIterator($form->getChildren())
new VirtualFormAwareIterator($form->all())
);
foreach ($form->getConfig()->getAttribute('error_mapping') as $propertyPath => $targetPath) {
// Dot rules are considered at the very end

View File

@ -797,20 +797,34 @@ class Form implements \IteratorAggregate, FormInterface
return $this->config->getViewTransformers();
}
/**
* {@inheritdoc}
*/
public function all()
{
return $this->children;
}
/**
* Returns all children in this group.
*
* @return array
*
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
* {@link all()} instead.
*/
public function getChildren()
{
return $this->children;
return $this->all();
}
/**
* Returns whether the form has children.
*
* @return Boolean
*
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
* {@link count()} instead.
*/
public function hasChildren()
{
@ -969,7 +983,7 @@ class Form implements \IteratorAggregate, FormInterface
}
foreach ($this->children as $child) {
$view->addChild($child->createView($view));
$view->add($child->createView($view));
}
foreach ($types as $type) {

View File

@ -22,7 +22,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormBuilder extends FormConfig implements FormBuilderInterface
class FormBuilder extends FormConfig implements \IteratorAggregate, FormBuilderInterface
{
/**
* The form factory.
@ -186,6 +186,14 @@ class FormBuilder extends FormConfig implements FormBuilderInterface
return $this->children;
}
/**
* {@inheritdoc}
*/
public function count()
{
return count($this->children);
}
/**
* {@inheritdoc}
*/
@ -225,6 +233,14 @@ class FormBuilder extends FormConfig implements FormBuilderInterface
return $this;
}
/**
* {@inheritdoc}
*/
public function hasParent()
{
return null !== $this->parent;
}
/**
* Converts an unresolved child into a {@link FormBuilder} instance.
*
@ -253,4 +269,12 @@ class FormBuilder extends FormConfig implements FormBuilderInterface
$this->unresolvedChildren = array();
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new \ArrayIterator($this->children);
}
}

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Form;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface FormBuilderInterface extends FormConfigEditorInterface
interface FormBuilderInterface extends FormConfigEditorInterface, \Traversable, \Countable
{
/**
* Adds a new field to this group. A field must have a unique name within
@ -91,13 +91,6 @@ interface FormBuilderInterface extends FormConfigEditorInterface
*/
function getForm();
/**
* Returns the parent builder.
*
* @return FormBuilderInterface The parent builder
*/
function getParent();
/**
* Sets the parent builder.
*
@ -106,4 +99,18 @@ interface FormBuilderInterface extends FormConfigEditorInterface
* @return FormBuilderInterface The builder object.
*/
function setParent(FormBuilderInterface $parent = null);
/**
* Returns the parent builder.
*
* @return FormBuilderInterface The parent builder
*/
function getParent();
/**
* Returns whether the builder has a parent.
*
* @return Boolean
*/
function hasParent();
}

View File

@ -82,14 +82,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return array An array of FormInterface instances
*/
function getChildren();
/**
* Return whether the form has children.
*
* @return Boolean
*/
function hasChildren();
function all();
/**
* Returns all errors.

View File

@ -54,7 +54,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function set($name, $value)
public function setVar($name, $value)
{
$this->vars[$name] = $value;
@ -64,7 +64,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function has($name)
public function hasVar($name)
{
return array_key_exists($name, $this->vars);
}
@ -72,9 +72,9 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function get($name, $default = null)
public function getVar($name, $default = null)
{
if (false === $this->has($name)) {
if (false === $this->hasVar($name)) {
return $default;
}
@ -84,19 +84,19 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function all()
public function setVars(array $vars)
{
return $this->vars;
$this->vars = array_replace($this->vars, $vars);
return $this;
}
/**
* Alias of all so it is possible to do `form.vars.foo`
*
* @return array
* {@inheritdoc}
*/
public function getVars()
{
return $this->all();
return $this->vars;
}
/**
@ -177,7 +177,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function addChild(FormViewInterface $child)
public function add(FormViewInterface $child)
{
$this->children[$child->getName()] = $child;
@ -187,7 +187,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function removeChild($name)
public function remove($name)
{
unset($this->children[$name]);
@ -197,7 +197,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function getChildren()
public function all()
{
return $this->children;
}
@ -205,13 +205,22 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function getChild($name)
public function get($name)
{
if (!isset($this->children[$name])) {
throw new \InvalidArgumentException(sprintf('Child "%s" does not exist.', $name));
}
return $this->children[$name];
}
/**
* {@inheritdoc}
* Returns whether this view has any children.
*
* @return Boolean Whether the view has children.
*
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
* {@link count()} instead.
*/
public function hasChildren()
{
@ -221,7 +230,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
/**
* {@inheritdoc}
*/
public function hasChild($name)
public function has($name)
{
return isset($this->children[$name]);
}
@ -235,7 +244,7 @@ class FormView implements \IteratorAggregate, FormViewInterface
*/
public function offsetGet($name)
{
return $this->getChild($name);
return $this->get($name);
}
/**

View File

@ -23,42 +23,6 @@ interface FormViewInterface extends \ArrayAccess, \Traversable, \Countable
*/
function getName();
/**
* Sets a view variable.
*
* @param string $name The variable name.
* @param string $value The variable value.
*
* @return FormViewInterface The view object.
*/
function set($name, $value);
/**
* Returns whether a view variable exists.
*
* @param string $name The variable name.
*
* @return Boolean Whether the variable exists.
*/
function has($name);
/**
* Returns the value of a view variable.
*
* @param string $name The variable name.
* @param mixed $default The value to return if the variable is not set.
*
* @return mixed The variable value.
*/
function get($name, $default = null);
/**
* Returns the values of all view variables.
*
* @return array The values of all variables.
*/
function all();
/**
* Returns whether the view was already rendered.
*
@ -103,7 +67,7 @@ interface FormViewInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return FormViewInterface The view object.
*/
function addChild(FormViewInterface $child);
function add(FormViewInterface $child);
/**
* Removes a child view.
@ -112,14 +76,14 @@ interface FormViewInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return FormViewInterface The view object.
*/
function removeChild($name);
function remove($name);
/**
* Returns the children.
*
* @return array The children as instances of FormView
*/
function getChildren();
function all();
/**
* Returns a given child.
@ -128,14 +92,7 @@ interface FormViewInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return FormViewInterface The child view
*/
function getChild($name);
/**
* Returns whether this view has children.
*
* @return Boolean Whether this view has children
*/
function hasChildren();
function get($name);
/**
* Returns whether this view has a given child.
@ -144,5 +101,50 @@ interface FormViewInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return Boolean Whether the child with the given name exists
*/
function hasChild($name);
function has($name);
/**
* Sets a view variable.
*
* @param string $name The variable name.
* @param string $value The variable value.
*
* @return FormViewInterface The view object.
*/
function setVar($name, $value);
/**
* Sets a list of view variables.
*
* @param array $values An array of variable names and values.
*
* @return FormViewInterface The view object.
*/
function setVars(array $values);
/**
* Returns whether a view variable exists.
*
* @param string $name The variable name.
*
* @return Boolean Whether the variable exists.
*/
function hasVar($name);
/**
* Returns the value of a view variable.
*
* @param string $name The variable name.
* @param mixed $default The value to return if the variable is not set.
*
* @return mixed The variable value.
*/
function getVar($name, $default = null);
/**
* Returns the values of all view variables.
*
* @return array The values of all variables.
*/
function getVars();
}

View File

@ -20,7 +20,7 @@ class CheckboxTypeTest extends TypeTestCase
$form = $this->factory->create('checkbox', null, array('value' => 'foobar'));
$view = $form->createView();
$this->assertEquals('foobar', $view->get('value'));
$this->assertEquals('foobar', $view->getVar('value'));
}
public function testCheckedIfDataTrue()
@ -29,7 +29,7 @@ class CheckboxTypeTest extends TypeTestCase
$form->setData(true);
$view = $form->createView();
$this->assertTrue($view->get('checked'));
$this->assertTrue($view->getVar('checked'));
}
public function testCheckedIfDataTrueWithEmptyValue()
@ -38,7 +38,7 @@ class CheckboxTypeTest extends TypeTestCase
$form->setData(true);
$view = $form->createView();
$this->assertTrue($view->get('checked'));
$this->assertTrue($view->getVar('checked'));
}
public function testNotCheckedIfDataFalse()
@ -47,7 +47,7 @@ class CheckboxTypeTest extends TypeTestCase
$form->setData(false);
$view = $form->createView();
$this->assertFalse($view->get('checked'));
$this->assertFalse($view->getVar('checked'));
}
public function testBindWithValueChecked()
@ -127,7 +127,7 @@ class CheckboxTypeTest extends TypeTestCase
$form->setData($data);
$view = $form->createView();
$this->assertEquals($expected, $view->get('checked'));
$this->assertEquals($expected, $view->getVar('checked'));
}
public function provideTransformedData()

View File

@ -538,7 +538,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertTrue($view->get('required'));
$this->assertTrue($view->getVar('required'));
}
public function testPassNonRequiredToView()
@ -549,7 +549,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertFalse($view->get('required'));
$this->assertFalse($view->getVar('required'));
}
public function testPassMultipleToView()
@ -560,7 +560,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertTrue($view->get('multiple'));
$this->assertTrue($view->getVar('multiple'));
}
public function testPassExpandedToView()
@ -571,7 +571,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertTrue($view->get('expanded'));
$this->assertTrue($view->getVar('expanded'));
}
public function testNotPassedEmptyValueToViewIsNull()
@ -582,7 +582,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertNull($view->get('empty_value'));
$this->assertNull($view->getVar('empty_value'));
}
public function testPassEmptyValueToViewIsEmpty()
@ -594,7 +594,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertEmpty($view->get('empty_value'));
$this->assertEmpty($view->getVar('empty_value'));
}
/**
@ -611,7 +611,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertEquals($viewValue, $view->get('empty_value'));
$this->assertEquals($viewValue, $view->getVar('empty_value'));
}
public function getOptionsWithEmptyValue()
@ -642,7 +642,7 @@ class ChoiceTypeTest extends TypeTestCase
new ChoiceView('b', 'B'),
new ChoiceView('c', 'C'),
new ChoiceView('d', 'D'),
), $view->get('choices'));
), $view->getVar('choices'));
}
public function testPassPreferredChoicesToView()
@ -657,11 +657,11 @@ class ChoiceTypeTest extends TypeTestCase
$this->assertEquals(array(
0 => new ChoiceView('a', 'A'),
2 => new ChoiceView('c', 'C'),
), $view->get('choices'));
), $view->getVar('choices'));
$this->assertEquals(array(
1 => new ChoiceView('b', 'B'),
3 => new ChoiceView('d', 'D'),
), $view->get('preferred_choices'));
), $view->getVar('preferred_choices'));
}
public function testPassHierarchicalChoicesToView()
@ -680,7 +680,7 @@ class ChoiceTypeTest extends TypeTestCase
'Doctrine' => array(
4 => new ChoiceView('e', 'Roman'),
),
), $view->get('choices'));
), $view->getVar('choices'));
$this->assertEquals(array(
'Symfony' => array(
1 => new ChoiceView('b', 'Fabien'),
@ -688,7 +688,7 @@ class ChoiceTypeTest extends TypeTestCase
'Doctrine' => array(
3 => new ChoiceView('d', 'Jon'),
),
), $view->get('preferred_choices'));
), $view->getVar('preferred_choices'));
}
public function testAdjustFullNameForMultipleNonExpanded()
@ -700,7 +700,7 @@ class ChoiceTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertSame('name[]', $view->get('full_name'));
$this->assertSame('name[]', $view->getVar('full_name'));
}
// https://github.com/symfony/symfony/issues/3298

View File

@ -138,7 +138,7 @@ class CollectionTypeTest extends TypeTestCase
))
;
$this->assertTrue($form->createView()->get('multipart'));
$this->assertTrue($form->createView()->getVar('multipart'));
}
public function testGetDataDoesNotContainsProtypeNameBeforeDataAreSet()
@ -195,6 +195,6 @@ class CollectionTypeTest extends TypeTestCase
'prototype_name' => '__test__',
));
$this->assertSame('__test__label__', $form->createView()->get('prototype')->get('label'));
$this->assertSame('__test__label__', $form->createView()->getVar('prototype')->getVar('label'));
}
}

View File

@ -21,7 +21,7 @@ class CountryTypeTest extends LocalizedTestCase
$form = $this->factory->create('country');
$view = $form->createView();
$choices = $view->get('choices');
$choices = $view->getVar('choices');
// Don't check objects for identity
$this->assertContains(new ChoiceView('DE', 'Deutschland'), $choices, '', false, false);
@ -35,7 +35,7 @@ class CountryTypeTest extends LocalizedTestCase
{
$form = $this->factory->create('country', 'country');
$view = $form->createView();
$choices = $view->get('choices');
$choices = $view->getVar('choices');
foreach ($choices as $choice) {
if ('ZZ' === $choice->getValue()) {

View File

@ -241,6 +241,6 @@ class DateTimeTypeTest extends LocalizedTestCase
));
$view = $form->createView();
$this->assertEquals('datetime', $view->get('type'));
$this->assertEquals('datetime', $view->getVar('type'));
}
}

View File

@ -327,7 +327,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('2010', '2010'),
new ChoiceView('2011', '2011'),
), $view->getChild('year')->get('choices'));
), $view->get('year')->getVar('choices'));
}
public function testMonthsOption()
@ -341,7 +341,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('month')->get('choices'));
), $view->get('month')->getVar('choices'));
}
public function testMonthsOptionNumericIfFormatContainsNoMonth()
@ -356,7 +356,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('month')->get('choices'));
), $view->get('month')->getVar('choices'));
}
public function testMonthsOptionShortFormat()
@ -371,7 +371,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('1', 'Jän'),
new ChoiceView('4', 'Apr')
), $view->getChild('month')->get('choices'));
), $view->get('month')->getVar('choices'));
}
public function testMonthsOptionLongFormat()
@ -386,7 +386,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('1', 'Jänner'),
new ChoiceView('4', 'April'),
), $view->getChild('month')->get('choices'));
), $view->get('month')->getVar('choices'));
}
public function testMonthsOptionLongFormatWithDifferentTimezone()
@ -401,7 +401,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('1', 'Jänner'),
new ChoiceView('4', 'April'),
), $view->getChild('month')->get('choices'));
), $view->get('month')->getVar('choices'));
}
public function testIsDayWithinRangeReturnsTrueIfWithin()
@ -415,7 +415,7 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('day')->get('choices'));
), $view->get('day')->getVar('choices'));
}
public function testIsPartiallyFilledReturnsFalseIfSingleText()
@ -495,7 +495,7 @@ class DateTypeTest extends LocalizedTestCase
$form = $this->factory->create('date');
$view = $form->createView();
$this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->get('date_pattern'));
$this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->getVar('date_pattern'));
}
public function testPassDatePatternToViewDifferentPattern()
@ -506,7 +506,7 @@ class DateTypeTest extends LocalizedTestCase
$view = $form->createView();
$this->assertSame('{{ month }}*{{ year }}*{{ day }}', $view->get('date_pattern'));
$this->assertSame('{{ month }}*{{ year }}*{{ day }}', $view->getVar('date_pattern'));
}
public function testDontPassDatePatternIfText()
@ -516,7 +516,7 @@ class DateTypeTest extends LocalizedTestCase
));
$view = $form->createView();
$this->assertNull($view->get('date_pattern'));
$this->assertNull($view->getVar('date_pattern'));
}
public function testPassWidgetToView()
@ -526,7 +526,7 @@ class DateTypeTest extends LocalizedTestCase
));
$view = $form->createView();
$this->assertSame('single_text', $view->get('widget'));
$this->assertSame('single_text', $view->getVar('widget'));
}
// Bug fix
@ -544,6 +544,6 @@ class DateTypeTest extends LocalizedTestCase
));
$view = $form->createView();
$this->assertEquals('date', $view->get('type'));
$this->assertEquals('date', $view->getVar('type'));
}
}

View File

@ -23,7 +23,7 @@ class FileTypeTest extends TypeTestCase
));
$view = $form->createView();
$this->assertEquals('', $view->get('value'));
$this->assertEquals('', $view->getVar('value'));
}
private function createUploadedFileMock($name, $originalName, $valid)

View File

@ -105,9 +105,9 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->createNamed('name', 'form');
$view = $form->createView();
$this->assertEquals('name', $view->get('id'));
$this->assertEquals('name', $view->get('name'));
$this->assertEquals('name', $view->get('full_name'));
$this->assertEquals('name', $view->getVar('id'));
$this->assertEquals('name', $view->getVar('name'));
$this->assertEquals('name', $view->getVar('full_name'));
}
public function testStripLeadingUnderscoresAndDigitsFromId()
@ -115,9 +115,9 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->createNamed('_09name', 'form');
$view = $form->createView();
$this->assertEquals('name', $view->get('id'));
$this->assertEquals('_09name', $view->get('name'));
$this->assertEquals('_09name', $view->get('full_name'));
$this->assertEquals('name', $view->getVar('id'));
$this->assertEquals('_09name', $view->getVar('name'));
$this->assertEquals('_09name', $view->getVar('full_name'));
}
public function testPassIdAndNameToViewWithParent()
@ -126,9 +126,9 @@ class FormTypeTest extends TypeTestCase
$parent->add($this->factory->createNamed('child', 'form'));
$view = $parent->createView();
$this->assertEquals('parent_child', $view['child']->get('id'));
$this->assertEquals('child', $view['child']->get('name'));
$this->assertEquals('parent[child]', $view['child']->get('full_name'));
$this->assertEquals('parent_child', $view['child']->getVar('id'));
$this->assertEquals('child', $view['child']->getVar('name'));
$this->assertEquals('parent[child]', $view['child']->getVar('full_name'));
}
public function testPassIdAndNameToViewWithGrandParent()
@ -138,9 +138,9 @@ class FormTypeTest extends TypeTestCase
$parent['child']->add($this->factory->createNamed('grand_child', 'form'));
$view = $parent->createView();
$this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->get('id'));
$this->assertEquals('grand_child', $view['child']['grand_child']->get('name'));
$this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->get('full_name'));
$this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->getVar('id'));
$this->assertEquals('grand_child', $view['child']['grand_child']->getVar('name'));
$this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->getVar('full_name'));
}
public function testNonReadOnlyFormWithReadOnlyParentBeingReadOnly()
@ -149,7 +149,7 @@ class FormTypeTest extends TypeTestCase
$child = $this->factory->createNamed('child', 'form');
$view = $parent->add($child)->createView();
$this->assertTrue($view['child']->get('read_only'));
$this->assertTrue($view['child']->getVar('read_only'));
}
public function testReadOnlyFormWithNonReadOnlyParentBeingReadOnly()
@ -158,7 +158,7 @@ class FormTypeTest extends TypeTestCase
$child = $this->factory->createNamed('child', 'form', null, array('read_only' => true));
$view = $parent->add($child)->createView();
$this->assertTrue($view['child']->get('read_only'));
$this->assertTrue($view['child']->getVar('read_only'));
}
public function testNonReadOnlyFormWithNonReadOnlyParentBeingNonReadOnly()
@ -167,7 +167,7 @@ class FormTypeTest extends TypeTestCase
$child = $this->factory->createNamed('child', 'form');
$view = $parent->add($child)->createView();
$this->assertFalse($view['child']->get('read_only'));
$this->assertFalse($view['child']->getVar('read_only'));
}
public function testPassMaxLengthToView()
@ -175,7 +175,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->create('form', null, array('max_length' => 10));
$view = $form->createView();
$this->assertSame(10, $view->get('max_length'));
$this->assertSame(10, $view->getVar('max_length'));
}
public function testPassTranslationDomainToView()
@ -183,7 +183,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->create('form', null, array('translation_domain' => 'test'));
$view = $form->createView();
$this->assertSame('test', $view->get('translation_domain'));
$this->assertSame('test', $view->getVar('translation_domain'));
}
public function testPassDefaultLabelToView()
@ -191,7 +191,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->createNamed('__test___field', 'form');
$view = $form->createView();
$this->assertSame('Test field', $view->get('label'));
$this->assertSame('Test field', $view->getVar('label'));
}
public function testPassLabelToView()
@ -199,7 +199,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->createNamed('__test___field', 'form', null, array('label' => 'My label'));
$view = $form->createView();
$this->assertSame('My label', $view->get('label'));
$this->assertSame('My label', $view->getVar('label'));
}
public function testDefaultTranslationDomain()
@ -207,7 +207,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->create('form');
$view = $form->createView();
$this->assertSame('messages', $view->get('translation_domain'));
$this->assertSame('messages', $view->getVar('translation_domain'));
}
public function testBindWithEmptyDataCreatesObjectIfClassAvailable()
@ -351,7 +351,7 @@ class FormTypeTest extends TypeTestCase
$this->assertFalse($form->isEmpty());
$this->assertSame('0', $view->get('value'));
$this->assertSame('0', $view->getVar('value'));
$this->assertSame('0', $form->getData());
$form = $this->factory->create('form', null, array('data' => '0'));
@ -359,7 +359,7 @@ class FormTypeTest extends TypeTestCase
$this->assertFalse($form->isEmpty());
$this->assertSame('0', $view->get('value'));
$this->assertSame('0', $view->getVar('value'));
$this->assertSame('0', $form->getData());
$form = $this->factory->create('form', null, array('data' => '00000'));
@ -367,7 +367,7 @@ class FormTypeTest extends TypeTestCase
$this->assertFalse($form->isEmpty());
$this->assertSame('00000', $view->get('value'));
$this->assertSame('00000', $view->getVar('value'));
$this->assertSame('00000', $form->getData());
}
@ -507,7 +507,7 @@ class FormTypeTest extends TypeTestCase
$form = $this->factory->create('form');
$view = $form->createView();
$this->assertFalse($view->get('multipart'));
$this->assertFalse($view->getVar('multipart'));
}
public function testPassMultipartTrueIfAnyChildIsMultipartToView()
@ -517,7 +517,7 @@ class FormTypeTest extends TypeTestCase
$form->add($this->factory->create('file'));
$view = $form->createView();
$this->assertTrue($view->get('multipart'));
$this->assertTrue($view->getVar('multipart'));
}
public function testCreateViewDoNoMarkItAsRendered()
@ -603,7 +603,7 @@ class FormTypeTest extends TypeTestCase
{
$form = $this->factory->create('form');
$view = $form->createView();
$this->assertTrue($view->get('valid'));
$this->assertTrue($view->getVar('valid'));
}
public function testViewNotValidBound()
@ -612,6 +612,6 @@ class FormTypeTest extends TypeTestCase
$form->bind(array());
$form->addError(new FormError('An error'));
$view = $form->createView();
$this->assertFalse($view->get('valid'));
$this->assertFalse($view->getVar('valid'));
}
}

View File

@ -21,8 +21,7 @@ class LanguageTypeTest extends LocalizedTestCase
$form = $this->factory->create('language');
$view = $form->createView();
$choices = $view->get('choices');
$labels = $view->get('choice_labels');
$choices = $view->getVar('choices');
$this->assertContains(new ChoiceView('en', 'Englisch'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_GB', 'Britisches Englisch'), $choices, '', false, false);
@ -35,7 +34,7 @@ class LanguageTypeTest extends LocalizedTestCase
{
$form = $this->factory->create('language', 'language');
$view = $form->createView();
$choices = $view->get('choices');
$choices = $view->getVar('choices');
$this->assertNotContains(new ChoiceView('mul', 'Mehrsprachig'), $choices, '', false, false);
}

View File

@ -21,7 +21,7 @@ class LocaleTypeTest extends LocalizedTestCase
$form = $this->factory->create('locale');
$view = $form->createView();
$choices = $view->get('choices');
$choices = $view->getVar('choices');
$this->assertContains(new ChoiceView('en', 'Englisch'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_GB', 'Englisch (Vereinigtes Königreich)'), $choices, '', false, false);

View File

@ -20,7 +20,7 @@ class MoneyTypeTest extends LocalizedTestCase
$form = $this->factory->create('money');
$view = $form->createView();
$this->assertSame('{{ widget }} €', $view->get('money_pattern'));
$this->assertSame('{{ widget }} €', $view->getVar('money_pattern'));
}
public function testMoneyPatternWorksForYen()
@ -29,6 +29,6 @@ class MoneyTypeTest extends LocalizedTestCase
$form = $this->factory->create('money', null, array('currency' => 'JPY'));
$view = $form->createView();
$this->assertTrue((Boolean) strstr($view->get('money_pattern'), '¥'));
$this->assertTrue((Boolean) strstr($view->getVar('money_pattern'), '¥'));
}
}

View File

@ -26,7 +26,7 @@ class NumberTypeTest extends LocalizedTestCase
$form->setData('12345.67890');
$view = $form->createView();
$this->assertSame('12345,679', $view->get('value'));
$this->assertSame('12345,679', $view->getVar('value'));
}
public function testDefaultFormattingWithGrouping()
@ -35,7 +35,7 @@ class NumberTypeTest extends LocalizedTestCase
$form->setData('12345.67890');
$view = $form->createView();
$this->assertSame('12.345,679', $view->get('value'));
$this->assertSame('12.345,679', $view->getVar('value'));
}
public function testDefaultFormattingWithPrecision()
@ -44,7 +44,7 @@ class NumberTypeTest extends LocalizedTestCase
$form->setData('12345.67890');
$view = $form->createView();
$this->assertSame('12345,68', $view->get('value'));
$this->assertSame('12345,68', $view->getVar('value'));
}
public function testDefaultFormattingWithRounding()
@ -53,6 +53,6 @@ class NumberTypeTest extends LocalizedTestCase
$form->setData('12345.54321');
$view = $form->createView();
$this->assertSame('12346', $view->get('value'));
$this->assertSame('12346', $view->getVar('value'));
}
}

View File

@ -20,7 +20,7 @@ class PasswordTypeTest extends TypeTestCase
$form->setData('pAs5w0rd');
$view = $form->createView();
$this->assertSame('', $view->get('value'));
$this->assertSame('', $view->getVar('value'));
}
public function testEmptyIfBound()
@ -29,7 +29,7 @@ class PasswordTypeTest extends TypeTestCase
$form->bind('pAs5w0rd');
$view = $form->createView();
$this->assertSame('', $view->get('value'));
$this->assertSame('', $view->getVar('value'));
}
public function testNotEmptyIfBoundAndNotAlwaysEmpty()
@ -38,6 +38,6 @@ class PasswordTypeTest extends TypeTestCase
$form->bind('pAs5w0rd');
$view = $form->createView();
$this->assertSame('pAs5w0rd', $view->get('value'));
$this->assertSame('pAs5w0rd', $view->getVar('value'));
}
}

View File

@ -245,7 +245,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('hour')->get('choices'));
), $view->get('hour')->getVar('choices'));
}
public function testIsMinuteWithinRange_returnsTrueIfWithin()
@ -259,7 +259,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('minute')->get('choices'));
), $view->get('minute')->getVar('choices'));
}
public function testIsSecondWithinRange_returnsTrueIfWithin()
@ -274,7 +274,7 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals(array(
new ChoiceView('6', '06'),
new ChoiceView('7', '07'),
), $view->getChild('second')->get('choices'));
), $view->get('second')->getVar('choices'));
}
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty()
@ -414,6 +414,6 @@ class TimeTypeTest extends LocalizedTestCase
));
$view = $form->createView();
$this->assertEquals('time', $view->get('type'));
$this->assertEquals('time', $view->getVar('type'));
}
}

View File

@ -19,8 +19,7 @@ class TimezoneTypeTest extends TypeTestCase
{
$form = $this->factory->create('timezone');
$view = $form->createView();
$choices = $view->get('choices');
$labels = $view->get('choice_labels');
$choices = $view->getVar('choices');
$this->assertArrayHasKey('Africa', $choices);
$this->assertContains(new ChoiceView('Africa/Kinshasa', 'Kinshasa'), $choices['Africa'], '', false, false);

View File

@ -65,7 +65,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
))
->createView();
$this->assertTrue($view->hasChild('csrf'));
$this->assertTrue($view->has('csrf'));
}
public function testNoCsrfProtectionByDefaultIfNotSingleControlButNotRoot()
@ -80,9 +80,9 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
)
->getForm()
->createView()
->getChild('form');
->get('form');
$this->assertFalse($view->hasChild('csrf'));
$this->assertFalse($view->has('csrf'));
}
public function testNoCsrfProtectionByDefaultIfRootButSingleControl()
@ -94,7 +94,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
))
->createView();
$this->assertFalse($view->hasChild('csrf'));
$this->assertFalse($view->has('csrf'));
}
public function testCsrfProtectionCanBeDisabled()
@ -107,7 +107,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
))
->createView();
$this->assertFalse($view->hasChild('csrf'));
$this->assertFalse($view->has('csrf'));
}
public function testGenerateCsrfToken()
@ -126,7 +126,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
))
->createView();
$this->assertEquals('token', $view->getChild('csrf')->get('value'));
$this->assertEquals('token', $view->get('csrf')->getVar('value'));
}
public function provideBoolean()
@ -246,9 +246,9 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
'allow_add' => true,
))
->createView()
->get('prototype');
->getVar('prototype');
$this->assertFalse($prototypeView->hasChild('csrf'));
$this->assertFalse($prototypeView->has('csrf'));
$this->assertCount(1, $prototypeView);
}
}