10000 [Form] Allow choices with duplicated content by ewgRa · Pull Request #16436 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Allow choices with duplicated content #16436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add test
  • Loading branch information
ewgRa committed Nov 1, 2015
commit 66a2676159d5cb1851282c3e2dc6ad47f3bbb3ec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Factory;

use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
Expand Down Expand Up @@ -574,6 +575,55 @@ public function testCreateViewFlatGroupByOriginalStructure()
$this->assertGroupedView($view);
}

public function testCreateViewDuplicateArrayKeyChoiceListValues()
{
$list = new ArrayKeyChoiceList(
array(
'A' => 'a',
'AA' => 'a',
'Group 1' => array(
'E' => 'e',
'EE' => 'e',
'A' => 'abc'
),
'Group 2' => array(
'B' => 'b',
'E' => 'e'
),
'AAA' => 'a'
)
);

$view = $this->factory->createView($list);

$this->assertEquals(
new ChoiceListView(
array(
0 => new ChoiceView('A', 'A', 'a'),
1 => new ChoiceView('AA', 'AA', 'a'),
'Group 1' => new ChoiceGroupView(
'Group 1',
array(
2 => new ChoiceView('E', 'E', 'e'),
3 => new ChoiceView('EE', 'EE', 'e'),
4 => new ChoiceView('A', 'A', 'abc')
)
),
'Group 2' => new ChoiceGroupView(
'Group 2',
array(
5 => new ChoiceView('B', 'B', 'b'),
6 => new ChoiceView('E', 'E', 'e')
)
),
7 => new ChoiceView('AAA', 'AAA', 'a')
),
array()
),
$view
);
}

public function testCreateViewFlatGroupByEmpty()
{
$view = $this->factory->createView(
Expand Down
0