Additional test coverage for changes in RepeatedType
This commit is contained in:
parent
b23d47d274
commit
0679220b45
@ -369,6 +369,32 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testRepeatedWithCustomOptions()
|
||||
{
|
||||
$form = $this->factory->createNamed('repeated', 'name', null, array(
|
||||
'first_options' => array('label' => 'Test', 'required' => false),
|
||||
'second_options' => array('label' => 'Test2')
|
||||
));
|
||||
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/div
|
||||
[
|
||||
./div
|
||||
[
|
||||
./label[@for="name_first"][.="[trans]Test[/trans]"]
|
||||
/following-sibling::input[@type="text"][@id="name_first"][not(@required)]
|
||||
]
|
||||
/following-sibling::div
|
||||
[
|
||||
./label[@for="name_second"][.="[trans]Test2[/trans]"]
|
||||
/following-sibling::input[@type="text"][@id="name_second"][@required="required"]
|
||||
]
|
||||
]
|
||||
[count(.//input)=2]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSearchInputName()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('form', 'full')
|
||||
|
@ -210,14 +210,44 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
./td
|
||||
[./label[@for="name_first"]]
|
||||
/following-sibling::td
|
||||
[./input[@id="name_first"]]
|
||||
[./input[@type="text"][@id="name_first"]]
|
||||
]
|
||||
/following-sibling::tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_second"]]
|
||||
/following-sibling::td
|
||||
[./input[@id="name_second"]]
|
||||
[./input[@type="text"][@id="name_second"]]
|
||||
]
|
||||
]
|
||||
[count(.//input)=2]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testRepeatedWithCustomOptions()
|
||||
{
|
||||
$form = $this->factory->createNamed('repeated', 'name', 'foobar', array(
|
||||
'first_options' => array('label' => 'Test', 'required' => false),
|
||||
'second_options' => array('label' => 'Test2')
|
||||
));
|
||||
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/table
|
||||
[
|
||||
./tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_first"][.="[trans]Test[/trans]"]]
|
||||
/following-sibling::td
|
||||
[./input[@type="text"][@id="name_first"][not(@required)]]
|
||||
]
|
||||
/following-sibling::tr
|
||||
[
|
||||
./td
|
||||
[./label[@for="name_second"][.="[trans]Test2[/trans]"]]
|
||||
/following-sibling::td
|
||||
[./input[@type="text"][@id="name_second"][@required="required"]]
|
||||
]
|
||||
]
|
||||
[count(.//input)=2]
|
||||
|
@ -37,12 +37,24 @@ class RepeatedTypeTest extends TypeTestCase
|
||||
}
|
||||
|
||||
public function testSetOptions()
|
||||
{
|
||||
$form = $this->factory->create('repeated', null, array(
|
||||
'type' => 'field',
|
||||
'options' => array('label' => 'Global'),
|
||||
));
|
||||
|
||||
$this->assertEquals('Global', $form['first']->getAttribute('label'));
|
||||
$this->assertEquals('Global', $form['second']->getAttribute('label'));
|
||||
$this->assertTrue($form['first']->isRequired());
|
||||
$this->assertTrue($form['second']->isRequired());
|
||||
}
|
||||
|
||||
public function testSetOptionsPerField()
|
||||
{
|
||||
$form = $this->factory->create('repeated', null, array(
|
||||
'type' => 'field',
|
||||
'options' => array('label' => 'Test'),
|
||||
'first_options' => array('required' => false),
|
||||
'second_options' => array('label' => 'Test2'),
|
||||
'first_options' => array('label' => 'Test', 'required' => false),
|
||||
'second_options' => array('label' => 'Test2')
|
||||
));
|
||||
|
||||
$this->assertEquals('Test', $form['first']->getAttribute('label'));
|
||||
@ -51,6 +63,21 @@ class RepeatedTypeTest extends TypeTestCase
|
||||
$this->assertTrue($form['second']->isRequired());
|
||||
}
|
||||
|
||||
public function testSetOptionsPerFieldAndOverwrite()
|
||||
{
|
||||
$form = $this->factory->create('repeated', null, array(
|
||||
'type' => 'field',
|
||||
'options' => array('label' => 'Label'),
|
||||
'first_options' => array('required' => false),
|
||||
'second_options' => array('label' => 'Second label')
|
||||
));
|
||||
|
||||
$this->assertEquals('Label', $form['first']->getAttribute('label'));
|
||||
$this->assertEquals('Second label', $form['second']->getAttribute('label'));
|
||||
$this->assertFalse($form['first']->isRequired());
|
||||
$this->assertTrue($form['second']->isRequired());
|
||||
}
|
||||
|
||||
public function testSubmitUnequal()
|
||||
{
|
||||
$input = array('first' => 'foo', 'second' => 'bar');
|
||||
|
Reference in New Issue
Block a user