2012-07-12 18:17:14 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Component\Form\Tests;
|
|
|
|
|
2017-03-01 15:03:05 +00:00
|
|
|
use Symfony\Component\Form\Test\FormPerformanceTestCase;
|
|
|
|
|
2012-07-12 18:17:14 +01:00
|
|
|
/**
|
|
|
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
|
|
|
*/
|
2017-03-01 15:03:05 +00:00
|
|
|
class CompoundFormPerformanceTest extends FormPerformanceTestCase
|
2012-07-12 18:17:14 +01:00
|
|
|
{
|
|
|
|
/**
|
2014-12-21 17:00:50 +00:00
|
|
|
* Create a compound form multiple times, as happens in a collection form.
|
2012-07-14 15:20:31 +01:00
|
|
|
*
|
|
|
|
* @group benchmark
|
2012-07-12 18:17:14 +01:00
|
|
|
*/
|
|
|
|
public function testArrayBasedForm()
|
|
|
|
{
|
|
|
|
$this->setMaxRunningTime(1);
|
|
|
|
|
|
|
|
for ($i = 0; $i < 40; ++$i) {
|
2015-06-23 17:42:21 +01:00
|
|
|
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
|
|
|
|
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
|
|
|
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
|
|
|
->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
|
2012-07-12 18:17:14 +01:00
|
|
|
'choices' => array('male' => 'Male', 'female' => 'Female'),
|
|
|
|
'required' => false,
|
|
|
|
))
|
2015-06-23 17:42:21 +01:00
|
|
|
->add('age', 'Symfony\Component\Form\Extension\Core\Type\NumberType')
|
|
|
|
->add('birthDate', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType')
|
|
|
|
->add('city', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
|
2012-07-12 18:17:14 +01:00
|
|
|
// simulate 300 different cities
|
|
|
|
'choices' => range(1, 300),
|
|
|
|
))
|
|
|
|
->getForm();
|
|
|
|
|
|
|
|
// load the form into a view
|
|
|
|
$form->createView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|