mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix test error due to the removing of deprecated getName method
This commit is contained in:
parent
00bbbd32d6
commit
11bd3c66e1
@ -37,37 +37,37 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
* @var CustomFieldNumber
|
||||
*/
|
||||
private $customFieldNumber;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var FormBuilderInterface
|
||||
*/
|
||||
private $formBuilder;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
|
||||
$this->customFieldNumber = self::$kernel->getContainer()
|
||||
->get('chill.custom_field.number');
|
||||
|
||||
|
||||
$this->formBuilder = self::$kernel->getContainer()
|
||||
->get('form.factory')
|
||||
->createBuilder('form', null, array(
|
||||
'csrf_protection' => false,
|
||||
'csrf_field_name' => '_token'
|
||||
));
|
||||
|
||||
|
||||
$request = new \Symfony\Component\HttpFoundation\Request();
|
||||
$request->setLocale('fr');
|
||||
|
||||
|
||||
self::$kernel->getContainer()
|
||||
->get('request_stack')
|
||||
->push($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param mixed[] $options
|
||||
* @return CustomField
|
||||
*/
|
||||
@ -81,7 +81,7 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
->setName(array('fr' => 'default'))
|
||||
->setOptions($options);
|
||||
}
|
||||
|
||||
|
||||
public function testCreateValidForm()
|
||||
{
|
||||
$cf = $this->createCustomFieldNumber(array(
|
||||
@ -90,17 +90,17 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
'scale' => null,
|
||||
'post_text' => null
|
||||
));
|
||||
|
||||
|
||||
$this->customFieldNumber->buildForm($this->formBuilder, $cf);
|
||||
|
||||
|
||||
$form = $this->formBuilder->getForm();
|
||||
|
||||
|
||||
$form->submit(array('default' => 10));
|
||||
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals(10, $form['default']->getData());
|
||||
$this->assertEquals(10, $form['default']->getData());
|
||||
}
|
||||
|
||||
|
||||
public function testCreateInvalidFormValueGreaterThanMaximum()
|
||||
{
|
||||
$cf = $this->createCustomFieldNumber(array(
|
||||
@ -109,18 +109,18 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
'scale' => null,
|
||||
'post_text' => null
|
||||
));
|
||||
|
||||
|
||||
$this->customFieldNumber->buildForm($this->formBuilder, $cf);
|
||||
|
||||
|
||||
$form = $this->formBuilder->getForm();
|
||||
|
||||
|
||||
$form->submit(array('default' => 100));
|
||||
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertEquals(1, count($form['default']->getErrors()));
|
||||
}
|
||||
|
||||
|
||||
public function testCreateInvalidFormValueLowerThanMinimum()
|
||||
{
|
||||
$cf = $this->createCustomFieldNumber(array(
|
||||
@ -129,18 +129,18 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
'scale' => null,
|
||||
'post_text' => null
|
||||
));
|
||||
|
||||
|
||||
$this->customFieldNumber->buildForm($this->formBuilder, $cf);
|
||||
|
||||
|
||||
$form = $this->formBuilder->getForm();
|
||||
|
||||
|
||||
$form->submit(array('default' => 100));
|
||||
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertEquals(1, count($form['default']->getErrors()));
|
||||
}
|
||||
|
||||
|
||||
public function testRequiredFieldIsFalse()
|
||||
{
|
||||
$cf = $this->createCustomFieldNumber(array(
|
||||
@ -150,20 +150,20 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
'post_text' => null
|
||||
));
|
||||
$cf->setRequired(false);
|
||||
|
||||
|
||||
$cfGroup = (new \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup())
|
||||
->addCustomField($cf);
|
||||
|
||||
|
||||
$form = static::$kernel->getContainer()->get('form.factory')
|
||||
->createBuilder('custom_field', array(), array(
|
||||
->createBuilder(\Chill\CustomFieldsBundle\Form\Type\CustomFieldType::class, array(), array(
|
||||
'group' => $cfGroup
|
||||
))
|
||||
->getForm();
|
||||
|
||||
|
||||
$this->assertFalse($form['default']->isRequired(),
|
||||
"The field should not be required");
|
||||
}
|
||||
|
||||
|
||||
public function testRequiredFieldIsTrue()
|
||||
{
|
||||
$cf = $this->createCustomFieldNumber(array(
|
||||
@ -173,19 +173,19 @@ class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTes
|
||||
'post_text' => null
|
||||
));
|
||||
$cf->setRequired(true);
|
||||
|
||||
|
||||
$cfGroup = (new \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup())
|
||||
->addCustomField($cf);
|
||||
|
||||
|
||||
$form = static::$kernel->getContainer()->get('form.factory')
|
||||
->createBuilder('custom_field', array(), array(
|
||||
'group' => $cfGroup
|
||||
))
|
||||
->getForm();
|
||||
|
||||
|
||||
$this->assertTrue($form['default']->isRequired(),
|
||||
"The field should be required");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user