merged branch WouterJ/form_test_namespace (PR #7659)
This PR was merged into the master branch. Discussion ---------- [Form] Moved TypeTestCase to the Test namespace | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #7175 | License | MIT | Doc PR | symfony/symfony-docs#2500 Todo: - [x] Make a Doc PR - [x] Update the changelog and UPGRADE-3.md files As discussed in #7175, since this class is documented as a practise to test your form types, it's good to move it to the `Test` namespace. I am not sure about the deprecation, I thought things deprecated in 2.3 are removed in 3.0. Also, I think we shouldn't trigger a E_USER_DEPRECATED message. Please correct me if I'm wrong, it's my first PR for the core code. Commits -------8da6129
Moved FormIntegrationTestCase and FormPerformanceTestCase to the Test namespacee46f841
Moved TypeTestCase to it's own namespace
This commit is contained in:
commit
56c13f9a07
@ -135,6 +135,34 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
* `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException`
|
* `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException`
|
||||||
* `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException`
|
* `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException`
|
||||||
|
|
||||||
|
### Form
|
||||||
|
|
||||||
|
* The `TypeTestCase` class was moved from the `Symfony\Component\Form\Tests\Extension\Core\Type` namespace to the `Symfony\Component\Form\Test` namespace.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```
|
||||||
|
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase
|
||||||
|
|
||||||
|
class MyTypeTest extends TypeTestCase
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
|
||||||
|
class MyTypeTest extends TypeTestCase
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* The `FormItegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace.
|
||||||
|
|
||||||
### Routing
|
### Routing
|
||||||
|
|
||||||
* Some route settings have been renamed:
|
* Some route settings have been renamed:
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\Tests\FormPerformanceTestCase;
|
use Symfony\Component\Form\Test\FormPerformanceTestCase;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity;
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
|
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
|
||||||
|
@ -5,6 +5,8 @@ CHANGELOG
|
|||||||
2.3.0
|
2.3.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
* deprecated FormPerformanceTestCase and FormIntegrationTestCase in the Symfony\Component\Form\Tests namespace and moved them to the Symfony\Component\Form\Test namespace
|
||||||
|
* deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace
|
||||||
* changed FormRenderer::humanize() to humanize also camel cased field name
|
* changed FormRenderer::humanize() to humanize also camel cased field name
|
||||||
* added FormProcessorInterface and FormInterface::process()
|
* added FormProcessorInterface and FormInterface::process()
|
||||||
* deprecated passing a Request instance to FormInterface::bind()
|
* deprecated passing a Request instance to FormInterface::bind()
|
||||||
|
41
src/Symfony/Component/Form/Test/FormIntegrationTestCase.php
Normal file
41
src/Symfony/Component/Form/Test/FormIntegrationTestCase.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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\Test;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Forms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Symfony\Component\Form\FormFactoryInterface
|
||||||
|
*/
|
||||||
|
protected $factory;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
|
||||||
|
$this->markTestSkipped('The "EventDispatcher" component is not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->factory = Forms::createFormFactoryBuilder()
|
||||||
|
->addExtensions($this->getExtensions())
|
||||||
|
->getFormFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getExtensions()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
}
|
70
src/Symfony/Component/Form/Test/FormPerformanceTestCase.php
Normal file
70
src/Symfony/Component/Form/Test/FormPerformanceTestCase.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?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\Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for performance tests.
|
||||||
|
*
|
||||||
|
* Copied from Doctrine 2's OrmPerformanceTestCase.
|
||||||
|
*
|
||||||
|
* @author robo
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $maxRunningTime = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected function runTest()
|
||||||
|
{
|
||||||
|
$s = microtime(true);
|
||||||
|
parent::runTest();
|
||||||
|
$time = microtime(true) - $s;
|
||||||
|
|
||||||
|
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
|
||||||
|
$this->fail(
|
||||||
|
sprintf(
|
||||||
|
'expected running time: <= %s but was: %s',
|
||||||
|
|
||||||
|
$this->maxRunningTime,
|
||||||
|
$time
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $maxRunningTime
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function setMaxRunningTime($maxRunningTime)
|
||||||
|
{
|
||||||
|
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
|
||||||
|
$this->maxRunningTime = $maxRunningTime;
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return integer
|
||||||
|
* @since Method available since Release 2.3.0
|
||||||
|
*/
|
||||||
|
public function getMaxRunningTime()
|
||||||
|
{
|
||||||
|
return $this->maxRunningTime;
|
||||||
|
}
|
||||||
|
}
|
41
src/Symfony/Component/Form/Test/TypeTestCase.php
Normal file
41
src/Symfony/Component/Form/Test/TypeTestCase.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Form\Test;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\FormBuilder;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
|
abstract class TypeTestCase extends FormIntegrationTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FormBuilder
|
||||||
|
*/
|
||||||
|
protected $builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EventDispatcher
|
||||||
|
*/
|
||||||
|
protected $dispatcher;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||||
|
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
|
||||||
|
{
|
||||||
|
self::assertEquals($expected->format('c'), $actual->format('c'));
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ use Symfony\Component\Form\FormError;
|
|||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
||||||
|
|
||||||
abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
|
||||||
{
|
{
|
||||||
protected $csrfProvider;
|
protected $csrfProvider;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Tests;
|
|||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class CompoundFormPerformanceTest extends FormPerformanceTestCase
|
class CompoundFormPerformanceTest extends \Symfony\Component\Form\Tests\FormPerformanceTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a compound form multiple times, as happens in a collection form
|
* Create a compound form multiple times, as happens in a collection form
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
abstract class BaseTypeTest extends TypeTestCase
|
abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testPassDisabledAsOption()
|
public function testPassDisabledAsOption()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
|
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
|
|
||||||
class CheckboxTypeTest extends TypeTestCase
|
class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testPassValueToView()
|
public function testPassValueToView()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\Tests\FormPerformanceTestCase;
|
use Symfony\Component\Form\Test\FormPerformanceTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
|
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
|
||||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||||
|
|
||||||
class ChoiceTypeTest extends TypeTestCase
|
class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
private $choices = array(
|
private $choices = array(
|
||||||
'a' => 'Bernhard',
|
'a' => 'Bernhard',
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
|
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
|
|
||||||
class CollectionTypeTest extends TypeTestCase
|
class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testContainsNoChildByDefault()
|
public function testContainsNoChildByDefault()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
class FileTypeTest extends TypeTestCase
|
class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
// https://github.com/symfony/symfony/pull/5028
|
// https://github.com/symfony/symfony/pull/5028
|
||||||
public function testSetData()
|
public function testSetData()
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
class PasswordTypeTest extends TypeTestCase
|
class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testEmptyIfNotBound()
|
public function testEmptyIfNotBound()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
class RepeatedTypeTest extends TypeTestCase
|
class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
protected $form;
|
protected $form;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
|||||||
|
|
||||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||||
|
|
||||||
class TimezoneTypeTest extends TypeTestCase
|
class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||||
{
|
{
|
||||||
public function testTimezonesAreSelectable()
|
public function testTimezonesAreSelectable()
|
||||||
{
|
{
|
||||||
|
@ -11,32 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase;
|
||||||
use Symfony\Component\Form\Tests\FormIntegrationTestCase;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
||||||
|
|
||||||
abstract class TypeTestCase extends FormIntegrationTestCase
|
/**
|
||||||
|
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\TypeTestCase instead.
|
||||||
|
*/
|
||||||
|
abstract class TypeTestCase extends BaseTypeTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var FormBuilder
|
|
||||||
*/
|
|
||||||
protected $builder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EventDispatcher
|
|
||||||
*/
|
|
||||||
protected $dispatcher;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
|
||||||
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
|
|
||||||
{
|
|
||||||
self::assertEquals($expected->format('c'), $actual->format('c'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ namespace Symfony\Component\Form\Tests\Extension\Csrf\Type;
|
|||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
||||||
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
|
|
||||||
|
|
||||||
class FormTypeCsrfExtensionTest_ChildType extends AbstractType
|
class FormTypeCsrfExtensionTest_ChildType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase as BaseTestCase;
|
use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase;
|
||||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||||
|
|
||||||
abstract class TypeTestCase extends BaseTestCase
|
abstract class TypeTestCase extends BaseTypeTestCase
|
||||||
{
|
{
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
|
@ -11,31 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests;
|
namespace Symfony\Component\Form\Tests;
|
||||||
|
|
||||||
use Symfony\Component\Form\Forms;
|
use Symfony\Component\Form\Test\FormIntegrationTestCase as BaseFormIntegrationTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormIntegrationTestCase instead.
|
||||||
*/
|
*/
|
||||||
abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
|
abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \Symfony\Component\Form\FormFactoryInterface
|
|
||||||
*/
|
|
||||||
protected $factory;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
|
|
||||||
$this->markTestSkipped('The "EventDispatcher" component is not available');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->factory = Forms::createFormFactoryBuilder()
|
|
||||||
->addExtensions($this->getExtensions())
|
|
||||||
->getFormFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getExtensions()
|
|
||||||
{
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,60 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests;
|
namespace Symfony\Component\Form\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Test\FormPerformanceTestCase as BaseFormPerformanceTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for performance tests.
|
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormPerformanceTestCase instead.
|
||||||
*
|
|
||||||
* Copied from Doctrine 2's OrmPerformanceTestCase.
|
|
||||||
*
|
|
||||||
* @author robo
|
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
|
abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
protected $maxRunningTime = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
protected function runTest()
|
|
||||||
{
|
|
||||||
$s = microtime(true);
|
|
||||||
parent::runTest();
|
|
||||||
$time = microtime(true) - $s;
|
|
||||||
|
|
||||||
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
|
|
||||||
$this->fail(
|
|
||||||
sprintf(
|
|
||||||
'expected running time: <= %s but was: %s',
|
|
||||||
|
|
||||||
$this->maxRunningTime,
|
|
||||||
$time
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param integer $maxRunningTime
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function setMaxRunningTime($maxRunningTime)
|
|
||||||
{
|
|
||||||
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
|
|
||||||
$this->maxRunningTime = $maxRunningTime;
|
|
||||||
} else {
|
|
||||||
throw new \InvalidArgumentException;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return integer
|
|
||||||
* @since Method available since Release 2.3.0
|
|
||||||
*/
|
|
||||||
public function getMaxRunningTime()
|
|
||||||
{
|
|
||||||
return $this->maxRunningTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user