-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename CollectionType options for entries
- Loading branch information
Showing
4 changed files
with
81 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | |
public function testLegacyName() | ||
{ | ||
$form = $this->factory->create('collection', array( | ||
'type' => 'text', | ||
'entry_type' => 'text', | ||
)); | ||
|
||
$this->assertSame('collection', $form->getConfig()->getType()->getName()); | ||
|
@@ -40,8 +40,8 @@ public function testContainsNoChildByDefault() | |
public function testSetDataAdjustsSize() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'options' => array( | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_options' => array( | ||
'attr' => array('maxlength' => 20), | ||
), | ||
)); | ||
|
@@ -69,7 +69,7 @@ public function testSetDataAdjustsSize() | |
public function testThrowsExceptionIfObjectIsNotTraversable() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
)); | ||
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); | ||
$form->setData(new \stdClass()); | ||
|
@@ -78,7 +78,7 @@ public function testThrowsExceptionIfObjectIsNotTraversable() | |
public function testNotResizedIfSubmittedWithMissingData() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
)); | ||
$form->setData(array('[email protected]', '[email protected]')); | ||
$form->submit(array('[email protected]')); | ||
|
@@ -92,7 +92,7 @@ public function testNotResizedIfSubmittedWithMissingData() | |
public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'allow_delete' => true, | ||
)); | ||
$form->setData(array('[email protected]', '[email protected]')); | ||
|
@@ -107,7 +107,7 @@ public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() | |
public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'allow_delete' => true, | ||
'delete_empty' => true, | ||
)); | ||
|
@@ -124,7 +124,7 @@ public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() | |
public function testDontAddEmptyDataIfDeleteEmpty() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'allow_add' => true, | ||
'delete_empty' => true, | ||
)); | ||
|
@@ -141,7 +141,7 @@ public function testDontAddEmptyDataIfDeleteEmpty() | |
public function testNoDeleteEmptyIfDeleteNotAllowed() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'allow_delete' => false, | ||
'delete_empty' => true, | ||
)); | ||
|
@@ -156,10 +156,10 @@ public function testNoDeleteEmptyIfDeleteNotAllowed() | |
public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType', | ||
'entry_type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType', | ||
// If the field is not required, no new Author will be created if the | ||
// form is completely empty | ||
'options' => array('required' => false), | ||
'entry_options' => array('required' => false), | ||
'allow_add' => true, | ||
'delete_empty' => true, | ||
)); | ||
|
@@ -179,7 +179,7 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() | |
public function testNotResizedIfSubmittedWithExtraData() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
)); | ||
$form->setData(array('[email protected]')); | ||
$form->submit(array('[email protected]', '[email protected]')); | ||
|
@@ -192,7 +192,7 @@ public function testNotResizedIfSubmittedWithExtraData() | |
public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', | ||
'allow_add' => true, | ||
)); | ||
$form->setData(array('[email protected]')); | ||
|
@@ -208,7 +208,7 @@ public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() | |
public function testAllowAddButNoPrototype() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'allow_add' => true, | ||
'prototype' => false, | ||
)); | ||
|
@@ -220,7 +220,7 @@ public function testPrototypeMultipartPropagation() | |
{ | ||
$form = $this->factory | ||
->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'allow_add' => true, | ||
'prototype' => true, | ||
)) | ||
|
@@ -232,7 +232,7 @@ public function testPrototypeMultipartPropagation() | |
public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'prototype' => true, | ||
'allow_add' => true, | ||
)); | ||
|
@@ -244,7 +244,7 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() | |
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'allow_add' => true, | ||
'prototype' => true, | ||
)); | ||
|
@@ -257,15 +257,15 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() | |
public function testPrototypeNameOption() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'prototype' => true, | ||
'allow_add' => true, | ||
)); | ||
|
||
$this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default'); | ||
|
||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', | ||
'prototype' => true, | ||
'allow_add' => true, | ||
'prototype_name' => '__test__', | ||
|
@@ -274,10 +274,26 @@ public function testPrototypeNameOption() | |
$this->assertSame('__test__', $form->getConfig()->getAttribute('prototype')->getName()); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testLegacyEntryOptions() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\NumberType', | ||
'options' => array('attr' => array('maxlength' => '10')), | ||
)); | ||
|
||
$resolvedOptions = $form->getConfig()->getOptions(); | ||
|
||
$this->assertEquals('Symfony\Component\Form\Extension\Core\Type\NumberType', $resolvedOptions['entry_type']); | ||
$this->assertEquals(array('attr' => array('maxlength' => '10'), 'block_name' => 'entry'), $resolvedOptions['entry_options']); | ||
} | ||
|
||
public function testPrototypeDefaultLabel() | ||
{ | ||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( | ||
'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', | ||
'allow_add' => true, | ||
'prototype' => true, | ||
'prototype_name' => '__test__', | ||
|
@@ -293,7 +309,7 @@ public function testPrototypeData() | |
'allow_add' => true, | ||
'prototype' => true, | ||
'prototype_data' => 'foo', | ||
'options' => array( | ||
'entry_options' => array( | ||
'data' => 'bar', | ||
), | ||
)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters