Skip to content

Commit 36a0ae1

Browse files
committed
Moved FormIntegrationTestCase and FormPerformanceTestCase to the Test namespace
1 parent e7bdc62 commit 36a0ae1

9 files changed

+123
-81
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ CHANGELOG
55
2.3.0
66
------
77

8-
* deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace.
8+
* deprecated FormPerformanceTestCase and FormIntegrationTestCase in the Symfony\Component\Form\Tests namespace and moved them to the Symfony\Component\Form\Test namespace
9+
* deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace
910
* changed FormRenderer::humanize() to humanize also camel cased field name
1011
* added FormProcessorInterface and FormInterface::process()
1112
* deprecated passing a Request instance to FormInterface::bind()

Test/FormIntegrationTestCase.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Test;
13+
14+
use Symfony\Component\Form\Forms;
15+
16+
/**
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
20+
{
21+
/**
22+
* @var \Symfony\Component\Form\FormFactoryInterface
23+
*/
24+
protected $factory;
25+
26+
protected function setUp()
27+
{
28+
if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
29+
$this->markTestSkipped('The "EventDispatcher" component is not available');
30+
}
31+
32+
$this->factory = Forms::createFormFactoryBuilder()
33+
->addExtensions($this->getExtensions())
34+
->getFormFactory();
35+
}
36+
37+
protected function getExtensions()
38+
{
39+
return array();
40+
}
41+
}

Test/FormPerformanceTestCase.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Test;
13+
14+
/**
15+
* Base class for performance tests.
16+
*
17+
* Copied from Doctrine 2's OrmPerformanceTestCase.
18+
*
19+
* @author robo
20+
* @author Bernhard Schussek <bschussek@gmail.com>
21+
*/
22+
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
23+
{
24+
/**
25+
* @var integer
26+
*/
27+
protected $maxRunningTime = 0;
28+
29+
/**
30+
*/
31+
protected function runTest()
32+
{
33+
$s = microtime(true);
34+
parent::runTest();
35+
$time = microtime(true) - $s;
36+
37+
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
38+
$this->fail(
39+
sprintf(
40+
'expected running time: <= %s but was: %s',
41+
42+
$this->maxRunningTime,
43+
$time
44+
)
45+
);
46+
}
47+
}
48+
49+
/**
50+
* @param integer $maxRunningTime
51+
* @throws \InvalidArgumentException
52+
*/
53+
public function setMaxRunningTime($maxRunningTime)
54+
{
55+
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
56+
$this->maxRunningTime = $maxRunningTime;
57+
} else {
58+
throw new \InvalidArgumentException;
59+
}
60+
}
61+
62+
/**
63+
* @return integer
64+
* @since Method available since Release 2.3.0
65+
*/
66+
public function getMaxRunningTime()
67+
{
68+
return $this->maxRunningTime;
69+
}
70+
}

Test/TypeTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Test;
1313

1414
use Symfony\Component\Form\FormBuilder;
15-
use Symfony\Component\Form\Tests\FormIntegrationTestCase;
1615
use Symfony\Component\EventDispatcher\EventDispatcher;
1716

1817
abstract class TypeTestCase extends FormIntegrationTestCase

Tests/AbstractLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Form\FormView;
1616
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
1717

18-
abstract class AbstractLayoutTest extends FormIntegrationTestCase
18+
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
1919
{
2020
protected $csrfProvider;
2121

Tests/CompoundFormPerformanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
1616
*/
17-
class CompoundFormPerformanceTest extends FormPerformanceTestCase
17+
class CompoundFormPerformanceTest extends \Symfony\Component\Form\Tests\FormPerformanceTestCase
1818
{
1919
/**
2020
* Create a compound form multiple times, as happens in a collection form

Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14-
use Symfony\Component\Form\Tests\FormPerformanceTestCase;
14+
use Symfony\Component\Form\Test\FormPerformanceTestCase;
1515

1616
/**
1717
* @author Bernhard Schussek <bschussek@gmail.com>

Tests/FormIntegrationTestCase.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,11 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14-
use Symfony\Component\Form\Forms;
14+
use Symfony\Component\Form\Test\FormIntegrationTestCase as BaseFormIntegrationTestCase;
1515

1616
/**
17-
* @author Bernhard Schussek <bschussek@gmail.com>
17+
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormIntegrationTestCase instead.
1818
*/
19-
abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
19+
abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase
2020
{
21-
/**
22-
* @var \Symfony\Component\Form\FormFactoryInterface
23-
*/
24-
protected $factory;
25-
26-
protected function setUp()
27-
{
28-
if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
29-
$this->markTestSkipped('The "EventDispatcher" component is not available');
30-
}
31-
32-
$this->factory = Forms::createFormFactoryBuilder()
33-
->addExtensions($this->getExtensions())
34-
->getFormFactory();
35-
}
36-
37-
protected function getExtensions()
38-
{
39-
return array();
40-
}
4121
}

Tests/FormPerformanceTestCase.php

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,11 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use Symfony\Component\Form\Test\FormPerformanceTestCase as BaseFormPerformanceTestCase;
15+
1416
/**
15-
* Base class for performance tests.
16-
*
17-
* Copied from Doctrine 2's OrmPerformanceTestCase.
18-
*
19-
* @author robo
20-
* @author Bernhard Schussek <bschussek@gmail.com>
17+
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormPerformanceTestCase instead.
2118
*/
22-
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
19+
abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase
2320
{
24-
/**
25-
* @var integer
26-
*/
27-
protected $maxRunningTime = 0;
28-
29-
/**
30-
*/
31-
protected function runTest()
32-
{
33-
$s = microtime(true);
34-
parent::runTest();
35-
$time = microtime(true) - $s;
36-
37-
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
38-
$this->fail(
39-
sprintf(
40-
'expected running time: <= %s but was: %s',
41-
42-
$this->maxRunningTime,
43-
$time
44-
)
45-
);
46-
}
47-
}
48-
49-
/**
50-
* @param integer $maxRunningTime
51-
* @throws \InvalidArgumentException
52-
*/
53-
public function setMaxRunningTime($maxRunningTime)
54-
{
55-
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
56-
$this->maxRunningTime = $maxRunningTime;
57-
} else {
58-
throw new \InvalidArgumentException;
59-
}
60-
}
61-
62-
/**
63-
* @return integer
64-
* @since Method available since Release 2.3.0
65-
*/
66-
public function getMaxRunningTime()
67-
{
68-
return $this->maxRunningTime;
69-
}
7021
}

0 commit comments

Comments
 (0)