2011-04-14 02:15:56 +01:00
|
|
|
<?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.
|
|
|
|
*/
|
|
|
|
|
2012-03-28 14:43:52 +01:00
|
|
|
namespace Symfony\Component\Form\Tests;
|
2011-04-14 02:15:56 +01:00
|
|
|
|
|
|
|
use Symfony\Component\Form\FormError;
|
2011-04-14 14:02:51 +01:00
|
|
|
use Symfony\Component\Form\FormView;
|
2011-04-22 16:41:21 +01:00
|
|
|
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2013-04-19 13:16:57 +01:00
|
|
|
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2013-10-04 14:25:38 +01:00
|
|
|
protected $csrfTokenManager;
|
2011-04-15 13:38:46 +01:00
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
protected function setUp()
|
|
|
|
{
|
2011-10-26 13:23:39 +01:00
|
|
|
if (!extension_loaded('intl')) {
|
|
|
|
$this->markTestSkipped('The "intl" extension is not available');
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
\Locale::setDefault('en');
|
|
|
|
|
2013-10-04 14:25:38 +01:00
|
|
|
$this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2012-07-12 18:17:14 +01:00
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getExtensions()
|
|
|
|
{
|
|
|
|
return array(
|
2013-10-04 14:25:38 +01:00
|
|
|
new CsrfExtension($this->csrfTokenManager),
|
2012-07-12 18:17:14 +01:00
|
|
|
);
|
2011-04-14 02:15:56 +01:00
|
|
|
}
|
|
|
|
|
2011-06-14 09:44:38 +01:00
|
|
|
protected function tearDown()
|
|
|
|
{
|
2013-10-04 14:25:38 +01:00
|
|
|
$this->csrfTokenManager = null;
|
2012-12-14 22:16:06 +00:00
|
|
|
|
|
|
|
parent::tearDown();
|
2011-06-14 09:44:38 +01:00
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
protected function assertXpathNodeValue(\DomElement $element, $expression, $nodeValue)
|
|
|
|
{
|
|
|
|
$xpath = new \DOMXPath($element->ownerDocument);
|
|
|
|
$nodeList = $xpath->evaluate($expression);
|
|
|
|
$this->assertEquals(1, $nodeList->length);
|
|
|
|
$this->assertEquals($nodeValue, $nodeList->item(0)->nodeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function assertMatchesXpath($html, $expression, $count = 1)
|
|
|
|
{
|
|
|
|
$dom = new \DomDocument('UTF-8');
|
|
|
|
try {
|
|
|
|
// Wrap in <root> node so we can load HTML with multiple tags at
|
|
|
|
// the top level
|
|
|
|
$dom->loadXml('<root>'.$html.'</root>');
|
|
|
|
} catch (\Exception $e) {
|
2012-07-28 23:02:29 +01:00
|
|
|
$this->fail(sprintf(
|
2011-04-14 02:15:56 +01:00
|
|
|
"Failed loading HTML:\n\n%s\n\nError: %s",
|
|
|
|
$html,
|
|
|
|
$e->getMessage()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
$xpath = new \DOMXPath($dom);
|
|
|
|
$nodeList = $xpath->evaluate('/root'.$expression);
|
|
|
|
|
|
|
|
if ($nodeList->length != $count) {
|
|
|
|
$dom->formatOutput = true;
|
|
|
|
$this->fail(sprintf(
|
|
|
|
"Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
|
|
|
|
$expression,
|
2013-04-02 10:39:57 +01:00
|
|
|
$count == 1 ? 'once' : $count.' times',
|
|
|
|
$nodeList->length == 1 ? 'once' : $nodeList->length.' times',
|
2011-04-14 02:15:56 +01:00
|
|
|
// strip away <root> and </root>
|
|
|
|
substr($dom->saveHTML(), 6, -8)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
protected function assertWidgetMatchesXpath(FormView $view, array $vars, $xpath)
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2011-04-15 13:38:46 +01:00
|
|
|
// include ampersands everywhere to validate escaping
|
2011-04-14 14:02:51 +01:00
|
|
|
$html = $this->renderWidget($view, array_merge(array(
|
2011-04-15 13:38:46 +01:00
|
|
|
'id' => 'my&id',
|
|
|
|
'attr' => array('class' => 'my&class'),
|
2011-04-14 02:15:56 +01:00
|
|
|
), $vars));
|
|
|
|
|
|
|
|
$xpath = trim($xpath).'
|
2011-04-15 13:38:46 +01:00
|
|
|
[@id="my&id"]
|
|
|
|
[@class="my&class"]';
|
2011-04-14 02:15:56 +01:00
|
|
|
|
|
|
|
$this->assertMatchesXpath($html, $xpath);
|
|
|
|
}
|
|
|
|
|
2012-12-30 15:38:36 +00:00
|
|
|
abstract protected function renderForm(FormView $view, array $vars = array());
|
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
abstract protected function renderEnctype(FormView $view);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-06-01 09:08:18 +01:00
|
|
|
abstract protected function renderLabel(FormView $view, $label = null, array $vars = array());
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
abstract protected function renderErrors(FormView $view);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
abstract protected function renderWidget(FormView $view, array $vars = array());
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
abstract protected function renderRow(FormView $view, array $vars = array());
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-14 14:02:51 +01:00
|
|
|
abstract protected function renderRest(FormView $view, array $vars = array());
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2012-12-30 15:38:36 +00:00
|
|
|
abstract protected function renderStart(FormView $view, array $vars = array());
|
|
|
|
|
|
|
|
abstract protected function renderEnd(FormView $view, array $vars = array());
|
|
|
|
|
2011-06-21 16:46:13 +01:00
|
|
|
abstract protected function setTheme(FormView $view, array $themes);
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testEnctype()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('name', 'form')
|
2011-04-14 02:15:56 +01:00
|
|
|
->add('file', 'file')
|
|
|
|
->getForm();
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView()));
|
2011-04-14 02:15:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoEnctype()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('name', 'form')
|
2011-04-14 02:15:56 +01:00
|
|
|
->add('text', 'text')
|
|
|
|
->getForm();
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertEquals('', $this->renderEnctype($form->createView()));
|
2011-04-14 02:15:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testLabel()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2011-05-30 18:25:02 +01:00
|
|
|
$view = $form->createView();
|
|
|
|
$this->renderWidget($view, array('label' => 'foo'));
|
|
|
|
$html = $this->renderLabel($view);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
|
|
|
[.="[trans]Name[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
2011-07-11 17:38:59 +01:00
|
|
|
|
2011-07-11 17:32:40 +01:00
|
|
|
public function testLabelOnForm()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date');
|
2011-07-11 17:32:40 +01:00
|
|
|
$view = $form->createView();
|
|
|
|
$this->renderWidget($view, array('label' => 'foo'));
|
|
|
|
$html = $this->renderLabel($view);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-07-11 17:32:40 +01:00
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-04-20 18:40:14 +01:00
|
|
|
[@class="required"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[.="[trans]Name[/trans]"]
|
2011-07-11 17:32:40 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
2011-07-11 17:38:59 +01:00
|
|
|
|
2011-04-15 14:03:10 +01:00
|
|
|
public function testLabelWithCustomTextPassedAsOption()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', null, array(
|
2011-04-15 14:03:10 +01:00
|
|
|
'label' => 'Custom label',
|
|
|
|
));
|
|
|
|
$html = $this->renderLabel($form->createView());
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
2011-04-15 14:03:10 +01:00
|
|
|
[.="[trans]Custom label[/trans]"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLabelWithCustomTextPassedDirectly()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2011-04-15 12:52:11 +01:00
|
|
|
$html = $this->renderLabel($form->createView(), 'Custom label');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[.="[trans]Custom label[/trans]"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-01 09:08:18 +01:00
|
|
|
public function testLabelWithCustomTextPassedAsOptionAndDirectly()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', null, array(
|
2011-06-01 09:08:18 +01:00
|
|
|
'label' => 'Custom label',
|
|
|
|
));
|
|
|
|
$html = $this->renderLabel($form->createView(), 'Overridden label');
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
2011-06-01 09:08:18 +01:00
|
|
|
[.="[trans]Overridden label[/trans]"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-04-20 18:40:14 +01:00
|
|
|
public function testLabelDoesNotRenderFieldAttributes()
|
2011-06-01 09:08:18 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2011-06-01 09:08:18 +01:00
|
|
|
$html = $this->renderLabel($form->createView(), null, array(
|
|
|
|
'attr' => array(
|
|
|
|
'class' => 'my&class'
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-04-20 18:40:14 +01:00
|
|
|
[@for="name"]
|
|
|
|
[@class="required"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-25 12:20:23 +01:00
|
|
|
public function testLabelWithCustomAttributesPassedDirectly()
|
2012-04-20 18:40:14 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2012-04-20 18:40:14 +01:00
|
|
|
$html = $this->renderLabel($form->createView(), null, array(
|
|
|
|
'label_attr' => array(
|
|
|
|
'class' => 'my&class'
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
2011-07-04 19:04:44 +01:00
|
|
|
[@class="my&class required"]
|
2011-06-01 09:08:18 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-25 12:20:23 +01:00
|
|
|
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
2011-06-01 09:08:18 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2011-06-01 09:08:18 +01:00
|
|
|
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
2012-04-20 18:40:14 +01:00
|
|
|
'label_attr' => array(
|
2011-06-01 09:08:18 +01:00
|
|
|
'class' => 'my&class'
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
2012-01-16 23:02:58 +00:00
|
|
|
[@for="name"]
|
2011-07-04 19:04:44 +01:00
|
|
|
[@class="my&class required"]
|
2011-06-01 09:08:18 +01:00
|
|
|
[.="[trans]Custom label[/trans]"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-25 12:20:23 +01:00
|
|
|
// https://github.com/symfony/symfony/issues/5029
|
|
|
|
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('name', 'text', null, array(
|
|
|
|
'label' => 'Custom label',
|
|
|
|
));
|
|
|
|
$html = $this->renderLabel($form->createView(), null, array(
|
|
|
|
'label_attr' => array(
|
|
|
|
'class' => 'my&class'
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/label
|
|
|
|
[@for="name"]
|
|
|
|
[@class="my&class required"]
|
|
|
|
[.="[trans]Custom label[/trans]"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testErrors()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text');
|
2012-11-27 22:17:30 +00:00
|
|
|
$form->addError(new FormError('[trans]Error 1[/trans]'));
|
|
|
|
$form->addError(new FormError('[trans]Error 2[/trans]'));
|
2011-04-15 12:52:11 +01:00
|
|
|
$view = $form->createView();
|
2011-04-14 14:02:51 +01:00
|
|
|
$html = $this->renderErrors($view);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/ul
|
|
|
|
[
|
|
|
|
./li[.="[trans]Error 1[/trans]"]
|
|
|
|
/following-sibling::li[.="[trans]Error 2[/trans]"]
|
|
|
|
]
|
|
|
|
[count(./li)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-09-30 13:07:24 +01:00
|
|
|
public function testOverrideWidgetBlock()
|
2011-05-04 14:33:17 +01:00
|
|
|
{
|
2013-09-30 13:07:24 +01:00
|
|
|
// see custom_widgets.html.twig
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('text_id', 'text');
|
2011-05-04 14:33:17 +01:00
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./input
|
|
|
|
[@type="text"]
|
|
|
|
[@id="text_id"]
|
|
|
|
]
|
|
|
|
[@id="container"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testCheckedCheckbox()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'checkbox', true);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="checkbox"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@checked="checked"]
|
|
|
|
[@value="1"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-16 23:46:26 +00:00
|
|
|
public function testUncheckedCheckbox()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'checkbox', false);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="checkbox"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-01-16 23:46:26 +00:00
|
|
|
[not(@checked)]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-16 23:46:26 +00:00
|
|
|
public function testCheckboxWithValue()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'checkbox', false, array(
|
2012-01-16 23:46:26 +00:00
|
|
|
'value' => 'foo&bar',
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="checkbox"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-01-16 23:46:26 +00:00
|
|
|
[@value="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testSingleChoice()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2013-09-13 15:55:54 +01:00
|
|
|
// If the field is collapsed, has no "multiple" attribute, is required but
|
|
|
|
// has *no* empty value, the "required" must not be added, otherwise
|
|
|
|
// the resulting HTML is invalid.
|
|
|
|
// https://github.com/symfony/symfony/issues/8942
|
|
|
|
|
|
|
|
// HTML 5 spec
|
|
|
|
// http://www.w3.org/html/wg/drafts/html/master/forms.html#placeholder-label-option
|
|
|
|
|
|
|
|
// "If a select element has a required attribute specified, does not
|
|
|
|
// have a multiple attribute specified, and has a display size of 1,
|
|
|
|
// then the select element must have a placeholder label option."
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-09-13 15:55:54 +01:00
|
|
|
[not(@required)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testSingleChoiceWithPreferred()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'preferred_choices' => array('&b'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array('separator' => '-- sep --'),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-09-13 15:55:54 +01:00
|
|
|
[not(@required)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
/following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./option)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-29 09:14:34 +01:00
|
|
|
public function testSingleChoiceWithPreferredAndNoSeparator()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-09-29 09:14:34 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'preferred_choices' => array('&b'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array('separator' => null),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-09-13 15:55:54 +01:00
|
|
|
[not(@required)]
|
2011-09-29 09:14:34 +01:00
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
2011-09-29 09:14:34 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-09-29 09:14:34 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'preferred_choices' => array('&b'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array('separator' => ''),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-09-13 15:55:54 +01:00
|
|
|
[not(@required)]
|
2011-09-29 09:14:34 +01:00
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-09-29 09:14:34 +01:00
|
|
|
/following-sibling::option[@disabled="disabled"][not(@selected)][.=""]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
2011-09-29 09:14:34 +01:00
|
|
|
]
|
|
|
|
[count(./option)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-07-27 07:00:56 +01:00
|
|
|
public function testChoiceWithOnlyPreferred()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-07-27 07:00:56 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'preferred_choices' => array('&a', '&b'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testSingleChoiceNonRequired()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
2011-04-14 02:15:56 +01:00
|
|
|
'required' => false,
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-06-14 07:27:19 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[not(@required)]
|
2011-06-14 07:27:19 +01:00
|
|
|
[
|
2011-06-23 06:56:13 +01:00
|
|
|
./option[@value=""][.="[trans][/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-06-14 07:27:19 +01:00
|
|
|
]
|
2011-06-23 06:56:13 +01:00
|
|
|
[count(./option)=3]
|
2011-06-14 07:27:19 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-16 15:57:32 +01:00
|
|
|
public function testSingleChoiceNonRequiredNoneSelected()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', null, array(
|
2011-06-16 15:57:32 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'required' => false,
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[not(@required)]
|
2011-06-16 15:57:32 +01:00
|
|
|
[
|
2011-06-23 06:56:13 +01:00
|
|
|
./option[@value=""][.="[trans][/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-06-16 15:57:32 +01:00
|
|
|
]
|
2011-06-23 06:56:13 +01:00
|
|
|
[count(./option)=3]
|
2011-06-16 15:57:32 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSingleChoiceWithNonRequiredEmptyValue()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-06-16 15:57:32 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
'required' => false,
|
|
|
|
'empty_value' => 'Select&Anything&Not&Me',
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[not(@required)]
|
2011-06-16 15:57:32 +01:00
|
|
|
[
|
2013-01-12 04:40:12 +00:00
|
|
|
./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-06-14 07:27:19 +01:00
|
|
|
]
|
|
|
|
[count(./option)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSingleChoiceRequiredWithEmptyValue()
|
2011-06-17 12:29:02 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-06-17 12:29:02 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'required' => true,
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
'empty_value' => 'Test&Me'
|
|
|
|
));
|
|
|
|
|
2013-08-01 09:40:05 +01:00
|
|
|
// The "disabled" attribute was removed again due to a bug in the
|
|
|
|
// BlackBerry 10 browser.
|
|
|
|
// See https://github.com/symfony/symfony/pull/7678
|
2011-06-17 12:29:02 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[@required="required"]
|
|
|
|
[
|
2013-08-01 09:40:05 +01:00
|
|
|
./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Test&Me[/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-06-17 12:29:02 +01:00
|
|
|
]
|
|
|
|
[count(./option)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-16 15:57:32 +01:00
|
|
|
public function testSingleChoiceRequiredWithEmptyValueViaView()
|
2011-06-14 07:27:19 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-06-14 07:27:19 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'required' => true,
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
2013-08-01 09:40:05 +01:00
|
|
|
// The "disabled" attribute was removed again due to a bug in the
|
|
|
|
// BlackBerry 10 browser.
|
|
|
|
// See https://github.com/symfony/symfony/pull/7678
|
2011-06-14 07:27:19 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array('empty_value' => ''),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[@required="required"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
2013-08-01 09:40:05 +01:00
|
|
|
./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./option)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testSingleChoiceGrouped()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'choices' => array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'Group&2' => array('&c' => 'Choice&C'),
|
2011-04-14 02:15:56 +01:00
|
|
|
),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => false,
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./optgroup[@label="[trans]Group&1[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./optgroup[@label="[trans]Group&2[/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
[./option[@value="&c"][not(@selected)][.="[trans]Choice&C[/trans]"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
[count(./option)=1]
|
|
|
|
]
|
|
|
|
[count(./optgroup)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testMultipleChoice()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => true,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 13:18:25 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name[]"]
|
2011-04-14 13:18:25 +01:00
|
|
|
[@multiple="multiple"]
|
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 13:18:25 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-05-05 19:21:56 +01:00
|
|
|
public function testMultipleChoiceSkipsEmptyValue()
|
2011-06-17 12:29:02 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
2011-06-17 12:29:02 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'multiple' => true,
|
|
|
|
'expanded' => false,
|
|
|
|
'empty_value' => 'Test&Me'
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name[]"]
|
2011-06-17 12:29:02 +01:00
|
|
|
[@multiple="multiple"]
|
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-06-17 12:29:02 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 13:18:25 +01:00
|
|
|
public function testMultipleChoiceNonRequired()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'required' => false,
|
|
|
|
'multiple' => true,
|
|
|
|
'expanded' => false,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 13:18:25 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name[]"]
|
2011-04-14 13:18:25 +01:00
|
|
|
[@multiple="multiple"]
|
|
|
|
[
|
2012-04-10 10:51:28 +01:00
|
|
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
2011-04-14 13:18:25 +01:00
|
|
|
]
|
|
|
|
[count(./option)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSingleChoiceExpanded()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => true,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 13:18:25 +01:00
|
|
|
'/div
|
|
|
|
[
|
2012-04-19 09:37:16 +01:00
|
|
|
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
2012-04-10 10:51:28 +01:00
|
|
|
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
2012-04-19 09:37:16 +01:00
|
|
|
/following-sibling::input[@type="hidden"][@id="name__token"]
|
2011-05-30 17:14:53 +01:00
|
|
|
]
|
2012-04-13 13:11:09 +01:00
|
|
|
[count(./input)=3]
|
2011-05-30 17:14:53 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-05-05 19:21:56 +01:00
|
|
|
public function testSingleChoiceExpandedWithEmptyValue()
|
2011-06-17 12:29:02 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', '&a', array(
|
2011-06-17 12:29:02 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => true,
|
|
|
|
'empty_value' => 'Test&Me'
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
2013-05-05 19:21:56 +01:00
|
|
|
./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)]
|
|
|
|
/following-sibling::label[@for="name_placeholder"][.="[trans]Test&Me[/trans]"]
|
|
|
|
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
|
|
|
|
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
2012-04-19 09:37:16 +01:00
|
|
|
/following-sibling::input[@type="hidden"][@id="name__token"]
|
2011-05-30 17:14:53 +01:00
|
|
|
]
|
2013-05-05 19:21:56 +01:00
|
|
|
[count(./input)=4]
|
2011-05-30 17:14:53 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSingleChoiceExpandedWithBooleanValue()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', true, array(
|
2011-05-30 17:14:53 +01:00
|
|
|
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
|
|
|
'multiple' => false,
|
|
|
|
'expanded' => true,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
2012-04-19 09:37:16 +01:00
|
|
|
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
|
|
|
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
|
|
|
|
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
2012-04-19 09:37:16 +01:00
|
|
|
/following-sibling::input[@type="hidden"][@id="name__token"]
|
2011-04-14 13:18:25 +01:00
|
|
|
]
|
2012-04-13 13:11:09 +01:00
|
|
|
[count(./input)=3]
|
2011-04-14 13:18:25 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMultipleChoiceExpanded()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
|
2011-04-15 14:27:15 +01:00
|
|
|
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
2011-04-14 13:18:25 +01:00
|
|
|
'multiple' => true,
|
|
|
|
'expanded' => true,
|
2011-04-15 15:10:04 +01:00
|
|
|
'required' => true,
|
2011-04-14 13:18:25 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 13:18:25 +01:00
|
|
|
'/div
|
|
|
|
[
|
2012-04-19 09:37:16 +01:00
|
|
|
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
|
2012-04-10 16:47:40 +01:00
|
|
|
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
|
2012-04-10 16:47:40 +01:00
|
|
|
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
|
2012-01-16 23:02:58 +00:00
|
|
|
/following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]
|
2012-04-19 09:37:16 +01:00
|
|
|
/following-sibling::input[@type="hidden"][@id="name__token"]
|
2011-04-14 13:18:25 +01:00
|
|
|
]
|
2012-04-13 13:11:09 +01:00
|
|
|
[count(./input)=4]
|
2011-04-14 13:18:25 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testCountry()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'country', 'AT');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
[count(./option)>200]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-20 17:45:30 +01:00
|
|
|
public function testCountryWithEmptyValue()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'country', 'AT', array(
|
2011-06-20 17:45:30 +01:00
|
|
|
'empty_value' => 'Select&Country',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>201]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testDateTime()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'with_seconds' => false,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_month"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="2"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_day"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="3"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_date_year"]
|
|
|
|
[./option[@value="2011"][@selected="selected"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
/following-sibling::div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_hour"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="4"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_minute"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="5"][@selected="selected"]]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[count(.//select)=5]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-20 11:56:16 +01:00
|
|
|
public function testDateTimeWithEmptyValueGlobal()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', null, array(
|
2011-06-20 11:56:16 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'empty_value' => 'Change&Me',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-07-10 16:15:14 +01:00
|
|
|
[@id="name_date_month"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
/following-sibling::select
|
2012-07-10 16:15:14 +01:00
|
|
|
[@id="name_date_day"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_date_year"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
/following-sibling::div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_hour"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_minute"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[count(.//select)=5]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
2011-06-15 08:37:06 +01:00
|
|
|
|
2013-11-04 20:38:50 +00:00
|
|
|
public function testDateTimeWithHourAndMinute()
|
2011-06-20 11:56:16 +01:00
|
|
|
{
|
2013-11-04 20:38:50 +00:00
|
|
|
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
2012-12-15 17:04:13 +00:00
|
|
|
|
|
|
|
$form = $this->factory->createNamed('name', 'datetime', $data, array(
|
|
|
|
'input' => 'array',
|
2011-06-20 11:56:16 +01:00
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_month"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value="2"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_day"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value="3"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_date_year"]
|
|
|
|
[./option[@value="2011"][@selected="selected"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
/following-sibling::div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_hour"]
|
2013-11-04 20:38:50 +00:00
|
|
|
[./option[@value="4"][@selected="selected"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_minute"]
|
2013-11-04 20:38:50 +00:00
|
|
|
[./option[@value="5"][@selected="selected"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
]
|
|
|
|
[count(.//select)=5]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testDateTimeWithSeconds()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'with_seconds' => true,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_month"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="2"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date_day"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="3"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_date_year"]
|
|
|
|
[./option[@value="2011"][@selected="selected"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
/following-sibling::div
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_hour"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="4"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_minute"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="5"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time_second"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="6"][@selected="selected"]]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[count(.//select)=6]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-14 14:55:06 +01:00
|
|
|
public function testDateTimeSingleText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
2011-06-14 14:55:06 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'date_widget' => 'single_text',
|
|
|
|
'time_widget' => 'single_text',
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="date"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_date"]
|
|
|
|
[@name="name[date]"]
|
2012-07-10 16:15:14 +01:00
|
|
|
[@value="2011-02-03"]
|
2011-06-14 14:55:06 +01:00
|
|
|
/following-sibling::input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="time"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_time"]
|
|
|
|
[@name="name[time]"]
|
2012-04-10 17:14:13 +01:00
|
|
|
[@value="04:05"]
|
2011-06-14 14:55:06 +01:00
|
|
|
]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-15 08:37:06 +01:00
|
|
|
public function testDateTimeWithWidgetSingleText()
|
2011-06-14 14:55:06 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
2011-06-14 14:55:06 +01:00
|
|
|
'input' => 'string',
|
2011-06-15 08:37:06 +01:00
|
|
|
'widget' => 'single_text',
|
2012-07-11 08:44:09 +01:00
|
|
|
'model_timezone' => 'UTC',
|
|
|
|
'view_timezone' => 'UTC',
|
2011-06-14 14:55:06 +01:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-06-15 08:37:06 +01:00
|
|
|
'/input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="datetime"]
|
2011-06-15 08:37:06 +01:00
|
|
|
[@name="name"]
|
2012-07-11 08:34:01 +01:00
|
|
|
[@value="2011-02-03T04:05:06Z"]
|
2011-06-15 08:37:06 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array(
|
2011-06-15 08:37:06 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'date_widget' => 'choice',
|
|
|
|
'time_widget' => 'choice',
|
|
|
|
'widget' => 'single_text',
|
2012-07-11 08:44:09 +01:00
|
|
|
'model_timezone' => 'UTC',
|
|
|
|
'view_timezone' => 'UTC',
|
2011-06-15 08:37:06 +01:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="datetime"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-07-11 08:34:01 +01:00
|
|
|
[@value="2011-02-03T04:05:06Z"]
|
2011-06-14 14:55:06 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testDateChoice()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'choice',
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/div
|
2011-04-14 12:37:27 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_month"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="2"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_day"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="3"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_year"]
|
|
|
|
[./option[@value="2011"][@selected="selected"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-20 11:56:16 +01:00
|
|
|
public function testDateChoiceWithEmptyValueGlobal()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date', null, array(
|
2011-06-20 11:56:16 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'choice',
|
|
|
|
'empty_value' => 'Change&Me',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-07-10 16:15:14 +01:00
|
|
|
[@id="name_month"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
/following-sibling::select
|
2012-07-10 16:15:14 +01:00
|
|
|
[@id="name_day"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_year"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDateChoiceWithEmptyValueOnYear()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date', null, array(
|
2011-06-20 11:56:16 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'choice',
|
|
|
|
'required' => false,
|
|
|
|
'empty_value' => array('year' => 'Change&Me'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_month"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value="1"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_day"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value="1"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_year"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testDateText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'text',
|
|
|
|
));
|
|
|
|
|
2011-05-13 18:17:28 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./input
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_month"]
|
2011-05-13 18:17:28 +01:00
|
|
|
[@type="text"]
|
|
|
|
[@value="2"]
|
|
|
|
/following-sibling::input
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_day"]
|
2011-05-13 18:17:28 +01:00
|
|
|
[@type="text"]
|
|
|
|
[@value="3"]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::input
|
|
|
|
[@id="name_year"]
|
|
|
|
[@type="text"]
|
|
|
|
[@value="2011"]
|
2011-05-13 18:17:28 +01:00
|
|
|
]
|
|
|
|
[count(./input)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDateSingleText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'date', '2011-02-03', array(
|
2011-05-13 18:17:28 +01:00
|
|
|
'input' => 'string',
|
2011-05-27 15:23:59 +01:00
|
|
|
'widget' => 'single_text',
|
2011-05-13 18:17:28 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="date"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-07-10 16:15:14 +01:00
|
|
|
[@value="2011-02-03"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-14 07:23:48 +01:00
|
|
|
public function testDateErrorBubbling()
|
|
|
|
{
|
2013-04-29 16:31:30 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('form', 'form')
|
|
|
|
->add('date', 'date')
|
|
|
|
->getForm();
|
|
|
|
$form->get('date')->addError(new FormError('[trans]Error![/trans]'));
|
2011-09-14 07:23:48 +01:00
|
|
|
$view = $form->createView();
|
|
|
|
|
|
|
|
$this->assertEmpty($this->renderErrors($view));
|
|
|
|
$this->assertNotEmpty($this->renderErrors($view['date']));
|
|
|
|
}
|
|
|
|
|
2011-06-20 17:45:30 +01:00
|
|
|
public function testBirthDay()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array(
|
2011-06-20 17:45:30 +01:00
|
|
|
'input' => 'string',
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_month"]
|
2011-06-20 17:45:30 +01:00
|
|
|
[./option[@value="2"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_day"]
|
2011-06-20 17:45:30 +01:00
|
|
|
[./option[@value="3"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_year"]
|
|
|
|
[./option[@value="2000"][@selected="selected"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBirthDayWithEmptyValue()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array(
|
2011-06-20 17:45:30 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'empty_value' => '',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_month"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[./option[@value="1"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_day"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[./option[@value="1"][@selected="selected"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
/following-sibling::select
|
|
|
|
[@id="name_year"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
2012-12-06 18:50:36 +00:00
|
|
|
[./option[@value="1950"][@selected="selected"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-18 12:04:18 +01:00
|
|
|
public function testEmail()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'email', 'foo&bar');
|
2011-04-18 12:04:18 +01:00
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="email"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-18 12:04:18 +01:00
|
|
|
[@value="foo&bar"]
|
|
|
|
[not(@maxlength)]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testEmailWithMaxLength()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'email', 'foo&bar', array(
|
2011-04-18 12:04:18 +01:00
|
|
|
'max_length' => 123,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="email"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-18 12:04:18 +01:00
|
|
|
[@value="foo&bar"]
|
|
|
|
[@maxlength="123"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testFile()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'file');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-06-13 07:14:41 +01:00
|
|
|
'/input
|
|
|
|
[@type="file"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testHidden()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'hidden', 'foo&bar');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="hidden"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-15 13:38:46 +01:00
|
|
|
[@value="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-26 15:54:42 +00:00
|
|
|
public function testReadOnly()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', null, array(
|
2012-01-26 15:54:42 +00:00
|
|
|
'read_only' => true,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="text"]
|
|
|
|
[@name="name"]
|
|
|
|
[@readonly="readonly"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDisabled()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', null, array(
|
2012-01-26 15:54:42 +00:00
|
|
|
'disabled' => true,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="text"]
|
|
|
|
[@name="name"]
|
|
|
|
[@disabled="disabled"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testInteger()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'integer', 123);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="number"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@value="123"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLanguage()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'language', 'de');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
[count(./option)>200]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLocale()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'locale', 'de_AT');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-06-29 18:26:59 +01:00
|
|
|
[./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
[count(./option)>200]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMoney()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'money', 1234.56, array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'currency' => 'EUR',
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@value="1234.56"]
|
|
|
|
[contains(.., "€")]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNumber()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'number', 1234.56);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@value="1234.56"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPassword()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'password', 'foo&bar');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="password"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 12:37:27 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-04-20 16:32:55 +01:00
|
|
|
public function testPasswordSubmittedWithNotAlwaysEmpty()
|
2011-04-15 13:38:46 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'password', null, array(
|
2011-04-15 13:38:46 +01:00
|
|
|
'always_empty' => false,
|
|
|
|
));
|
2013-04-20 16:32:55 +01:00
|
|
|
$form->submit('foo&bar');
|
2011-04-15 13:38:46 +01:00
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="password"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-15 13:38:46 +01:00
|
|
|
[@value="foo&bar"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 12:37:27 +01:00
|
|
|
public function testPasswordWithMaxLength()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'password', 'foo&bar', array(
|
2011-04-14 12:37:27 +01:00
|
|
|
'max_length' => 123,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 12:37:27 +01:00
|
|
|
'/input
|
|
|
|
[@type="password"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 12:37:27 +01:00
|
|
|
[@maxlength="123"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPercent()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'percent', 0.1);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@value="10"]
|
|
|
|
[contains(.., "%")]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCheckedRadio()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'radio', true);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="radio"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@checked="checked"]
|
2012-01-16 23:46:26 +00:00
|
|
|
[@value="1"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-16 23:46:26 +00:00
|
|
|
public function testUncheckedRadio()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'radio', false);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="radio"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-01-16 23:46:26 +00:00
|
|
|
[not(@checked)]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-16 23:46:26 +00:00
|
|
|
public function testRadioWithValue()
|
2011-04-14 02:15:56 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'radio', false, array(
|
2012-01-16 23:46:26 +00:00
|
|
|
'value' => 'foo&bar',
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="radio"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-01-16 23:46:26 +00:00
|
|
|
[@value="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTextarea()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array(
|
2011-11-22 09:31:25 +00:00
|
|
|
'pattern' => 'foo',
|
2011-04-14 02:15:56 +01:00
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/textarea
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-11-22 09:31:25 +00:00
|
|
|
[not(@pattern)]
|
2011-04-15 13:38:46 +01:00
|
|
|
[.="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', 'foo&bar');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-15 13:38:46 +01:00
|
|
|
[@value="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[not(@maxlength)]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTextWithMaxLength()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'text', 'foo&bar', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'max_length' => 123,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-15 13:38:46 +01:00
|
|
|
[@value="foo&bar"]
|
2011-04-14 02:15:56 +01:00
|
|
|
[@maxlength="123"]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-05-19 00:43:47 +01:00
|
|
|
public function testSearch()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'search', 'foo&bar');
|
2011-05-19 00:43:47 +01:00
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
|
|
|
[@type="search"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-05-19 00:43:47 +01:00
|
|
|
[@value="foo&bar"]
|
|
|
|
[not(@maxlength)]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testTime()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'with_seconds' => false,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/div
|
2011-04-14 12:37:27 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_hour"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="4"][@selected="selected"]]
|
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_minute"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="5"][@selected="selected"]]
|
|
|
|
]
|
|
|
|
[count(./select)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTimeWithSeconds()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
2011-04-14 02:15:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'with_seconds' => true,
|
|
|
|
));
|
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/div
|
2011-04-14 12:37:27 +01:00
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_hour"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="4"][@selected="selected"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>23]
|
2011-04-14 02:15:56 +01:00
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_minute"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="5"][@selected="selected"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>59]
|
2011-04-14 02:15:56 +01:00
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_second"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./option[@value="6"][@selected="selected"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>59]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./select)=3]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-30 13:48:56 +01:00
|
|
|
public function testTimeText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
2011-06-30 13:48:56 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'text',
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_hour"]
|
|
|
|
[@name="name[hour]"]
|
2011-06-30 13:48:56 +01:00
|
|
|
[@value="04"]
|
|
|
|
[@size="1"]
|
|
|
|
[@required="required"]
|
|
|
|
/following-sibling::input
|
|
|
|
[@type="text"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_minute"]
|
|
|
|
[@name="name[minute]"]
|
2011-06-30 13:48:56 +01:00
|
|
|
[@value="05"]
|
|
|
|
[@size="1"]
|
|
|
|
[@required="required"]
|
|
|
|
]
|
|
|
|
[count(./input)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-23 13:01:11 +01:00
|
|
|
public function testTimeSingleText()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', '04:05:06', array(
|
2011-06-23 13:01:11 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'widget' => 'single_text',
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/input
|
2012-05-12 18:09:49 +01:00
|
|
|
[@type="time"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2012-04-10 17:14:13 +01:00
|
|
|
[@value="04:05"]
|
2013-02-22 12:48:44 +00:00
|
|
|
[not(@size)]
|
2011-06-23 13:01:11 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTimeWithEmptyValueGlobal()
|
2011-06-20 11:56:16 +01:00
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', null, array(
|
2011-06-20 11:56:16 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'empty_value' => 'Change&Me',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_hour"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>24]
|
2011-06-20 11:56:16 +01:00
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_minute"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>60]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
[count(./select)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTimeWithEmptyValueOnYear()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'time', null, array(
|
2011-06-20 11:56:16 +01:00
|
|
|
'input' => 'string',
|
|
|
|
'required' => false,
|
|
|
|
'empty_value' => array('hour' => 'Change&Me'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/div
|
|
|
|
[
|
|
|
|
./select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_hour"]
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>24]
|
2011-06-20 11:56:16 +01:00
|
|
|
/following-sibling::select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@id="name_minute"]
|
2011-06-20 11:56:16 +01:00
|
|
|
[./option[@value="1"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./option)>59]
|
2011-06-20 11:56:16 +01:00
|
|
|
]
|
|
|
|
[count(./select)=2]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-14 07:23:48 +01:00
|
|
|
public function testTimeErrorBubbling()
|
|
|
|
{
|
2013-04-29 16:31:30 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('form', 'form')
|
|
|
|
->add('time', 'time')
|
|
|
|
->getForm();
|
|
|
|
$form->get('time')->addError(new FormError('[trans]Error![/trans]'));
|
2011-09-14 07:23:48 +01:00
|
|
|
$view = $form->createView();
|
|
|
|
|
|
|
|
$this->assertEmpty($this->renderErrors($view));
|
|
|
|
$this->assertNotEmpty($this->renderErrors($view['time']));
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testTimezone()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna');
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/select
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2013-09-13 15:55:54 +01:00
|
|
|
[not(@required)]
|
2011-04-14 02:15:56 +01:00
|
|
|
[./optgroup
|
2011-06-29 18:26:59 +01:00
|
|
|
[@label="[trans]Europe[/trans]"]
|
|
|
|
[./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]]
|
2011-04-14 02:15:56 +01:00
|
|
|
]
|
|
|
|
[count(./optgroup)>10]
|
|
|
|
[count(.//option)>200]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-20 17:45:30 +01:00
|
|
|
public function testTimezoneWithEmptyValue()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'timezone', null, array(
|
2011-06-20 17:45:30 +01:00
|
|
|
'empty_value' => 'Select&Timezone',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/select
|
2013-01-12 04:40:12 +00:00
|
|
|
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]]
|
2011-06-20 17:45:30 +01:00
|
|
|
[count(./optgroup)>10]
|
|
|
|
[count(.//option)>201]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-14 02:15:56 +01:00
|
|
|
public function testUrl()
|
|
|
|
{
|
2011-04-22 09:42:21 +01:00
|
|
|
$url = 'http://www.google.com?foo1=bar1&foo2=bar2';
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamed('name', 'url', $url);
|
2011-04-14 02:15:56 +01:00
|
|
|
|
2011-04-15 12:52:11 +01:00
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2011-04-14 02:15:56 +01:00
|
|
|
'/input
|
|
|
|
[@type="url"]
|
2012-01-16 23:02:58 +00:00
|
|
|
[@name="name"]
|
2011-04-15 13:38:46 +01:00
|
|
|
[@value="http://www.google.com?foo1=bar1&foo2=bar2"]
|
2011-06-08 14:03:42 +01:00
|
|
|
'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCollectionPrototype()
|
|
|
|
{
|
2012-05-23 20:50:13 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three')))
|
2011-06-08 14:03:42 +01:00
|
|
|
->add('items', 'collection', array('allow_add' => true))
|
|
|
|
->getForm()
|
|
|
|
->createView();
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form);
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html,
|
2012-01-16 23:02:58 +00:00
|
|
|
'//div[@id="name_items"][@data-prototype]
|
2011-07-18 13:25:17 +01:00
|
|
|
|
|
2012-12-30 15:38:36 +00:00
|
|
|
//table[@id="name_items"][@data-prototype]'
|
2011-04-14 02:15:56 +01:00
|
|
|
);
|
|
|
|
}
|
2012-01-07 14:14:50 +00:00
|
|
|
|
|
|
|
public function testEmptyRootFormName()
|
|
|
|
{
|
2012-07-08 15:56:41 +01:00
|
|
|
$form = $this->factory->createNamedBuilder('', 'form')
|
2012-01-07 14:14:50 +00:00
|
|
|
->add('child', 'text')
|
|
|
|
->getForm();
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($this->renderWidget($form->createView()),
|
|
|
|
'//input[@type="hidden"][@id="_token"][@name="_token"]
|
|
|
|
|
|
|
|
|
//input[@type="text"][@id="child"][@name="child"]'
|
|
|
|
, 2);
|
|
|
|
}
|
2012-12-31 14:29:36 +00:00
|
|
|
|
|
|
|
public function testButton()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('name', 'button');
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
2013-04-22 15:22:02 +01:00
|
|
|
'/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]'
|
2012-12-31 14:29:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testButtonLabelIsEmpty()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('name', 'button');
|
|
|
|
|
|
|
|
$this->assertSame('', $this->renderLabel($form->createView()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSubmit()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('name', 'submit');
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/button[@type="submit"][@name="name"]'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testReset()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('name', 'reset');
|
|
|
|
|
|
|
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
|
|
|
'/button[@type="reset"][@name="name"]'
|
|
|
|
);
|
|
|
|
}
|
2012-12-30 15:38:36 +00:00
|
|
|
|
|
|
|
public function testStartTag()
|
|
|
|
{
|
|
|
|
$form = $this->factory->create('form', null, array(
|
|
|
|
'method' => 'get',
|
|
|
|
'action' => 'http://example.com/directory'
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderStart($form->createView());
|
|
|
|
|
2013-07-27 05:44:48 +01:00
|
|
|
$this->assertSame('<form name="form" method="get" action="http://example.com/directory">', $html);
|
2012-12-30 15:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testStartTagForPutRequest()
|
|
|
|
{
|
|
|
|
$form = $this->factory->create('form', null, array(
|
|
|
|
'method' => 'put',
|
|
|
|
'action' => 'http://example.com/directory'
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderStart($form->createView());
|
|
|
|
|
|
|
|
$this->assertMatchesXpath($html . '</form>',
|
|
|
|
'/form
|
|
|
|
[./input[@type="hidden"][@name="_method"][@value="PUT"]]
|
|
|
|
[@method="post"]
|
|
|
|
[@action="http://example.com/directory"]'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testStartTagWithOverriddenVars()
|
|
|
|
{
|
|
|
|
$form = $this->factory->create('form', null, array(
|
|
|
|
'method' => 'put',
|
|
|
|
'action' => 'http://example.com/directory',
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderStart($form->createView(), array(
|
|
|
|
'method' => 'post',
|
|
|
|
'action' => 'http://foo.com/directory'
|
|
|
|
));
|
|
|
|
|
2013-07-27 05:44:48 +01:00
|
|
|
$this->assertSame('<form name="form" method="post" action="http://foo.com/directory">', $html);
|
2012-12-30 15:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testStartTagForMultipartForm()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createBuilder('form', null, array(
|
|
|
|
'method' => 'get',
|
|
|
|
'action' => 'http://example.com/directory'
|
|
|
|
))
|
|
|
|
->add('file', 'file')
|
|
|
|
->getForm();
|
|
|
|
|
|
|
|
$html = $this->renderStart($form->createView());
|
|
|
|
|
2013-07-27 05:44:48 +01:00
|
|
|
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" enctype="multipart/form-data">', $html);
|
2012-12-30 15:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testStartTagWithExtraAttributes()
|
|
|
|
{
|
|
|
|
$form = $this->factory->create('form', null, array(
|
|
|
|
'method' => 'get',
|
|
|
|
'action' => 'http://example.com/directory'
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderStart($form->createView(), array(
|
|
|
|
'attr' => array('class' => 'foobar'),
|
|
|
|
));
|
|
|
|
|
2013-07-27 05:44:48 +01:00
|
|
|
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar">', $html);
|
2012-12-30 15:38:36 +00:00
|
|
|
}
|
2013-09-30 13:07:24 +01:00
|
|
|
|
|
|
|
public function testWidgetAttributes()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
|
|
|
'required' => true,
|
|
|
|
'disabled' => true,
|
|
|
|
'read_only' => true,
|
|
|
|
'max_length' => 10,
|
|
|
|
'pattern' => '\d+',
|
|
|
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// compare plain HTML to check the whitespace
|
|
|
|
$this->assertSame('<input type="text" id="text" name="text" readonly="readonly" disabled="disabled" required="required" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWidgetAttributeNameRepeatedIfTrue()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
|
|
|
'attr' => array('foo' => true),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// foo="foo"
|
|
|
|
$this->assertSame('<input type="text" id="text" name="text" required="required" foo="foo" value="value" />', $html);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWidgetAttributeHiddenIfFalse()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('text', 'text', 'value', array(
|
|
|
|
'attr' => array('foo' => false),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// no foo
|
|
|
|
$this->assertSame('<input type="text" id="text" name="text" required="required" value="value" />', $html);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testButtonAttributes()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('button', 'button', null, array(
|
|
|
|
'disabled' => true,
|
|
|
|
'attr' => array('class' => 'foobar', 'data-foo' => 'bar'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// compare plain HTML to check the whitespace
|
|
|
|
$this->assertSame('<button type="button" id="button" name="button" disabled="disabled" class="foobar" data-foo="bar">[trans]Button[/trans]</button>', $html);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testButtonAttributeNameRepeatedIfTrue()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('button', 'button', null, array(
|
|
|
|
'attr' => array('foo' => true),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// foo="foo"
|
|
|
|
$this->assertSame('<button type="button" id="button" name="button" foo="foo">[trans]Button[/trans]</button>', $html);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testButtonAttributeHiddenIfFalse()
|
|
|
|
{
|
|
|
|
$form = $this->factory->createNamed('button', 'button', null, array(
|
|
|
|
'attr' => array('foo' => false),
|
|
|
|
));
|
|
|
|
|
|
|
|
$html = $this->renderWidget($form->createView());
|
|
|
|
|
|
|
|
// no foo
|
|
|
|
$this->assertSame('<button type="button" id="button" name="button">[trans]Button[/trans]</button>', $html);
|
|
|
|
}
|
2011-04-14 02:15:56 +01:00
|
|
|
}
|