10000 minor #30241 allow to skip tests based on the supported version (xabbuh) · symfony/symfony@37b0eeb · GitHub
[go: up one dir, main page]

Skip to content

Commit 37b0eeb

Browse files
committed
minor #30241 allow to skip tests based on the supported version (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- allow to skip tests based on the supported version | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Writing tests for Form related features in the Doctrine and Twig bridges as well as the FrameworkBundle is a pain as soon as these tests are run with more recent versions of the Form component. This is due to the fact that our tests in the bridges and bundle extend test cases from the component. The tests in the component are expanded with every feature that gets added there. However, these new features are not present in the other packages in older version and we thus need to be able to skip them somehow. Commits ------- be23926 allow to skip tests based on the supported version
2 parents 2f5b16f + be23926 commit 37b0eeb

File tree

11 files changed

+50
-0
lines changed

11 files changed

+50
-0
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
3030
*/
3131
private $em;
3232

33+
protected static $supportedFeatureSetVersion = 304;
34+
3335
protected function getExtensions()
3436
{
3537
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class EntityTypeTest extends BaseTypeTest
5757
*/
5858
private $emRegistry;
5959

60+
protected static $supportedFeatureSetVersion = 304;
61+
6062
protected function setUp()
6163
{
6264
$this->em = DoctrineTestHelper::createTestEntityManager();

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
1818
{
19+
protected static $supportedFeatureSetVersion = 304;
20+
1921
public function testLabelOnForm()
2022
{
2123
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
3131
*/
3232
private $renderer;
3333

34+
protected static $supportedFeatureSetVersion = 304;
35+
3436
protected function setUp()
3537
{
3638
parent::setUp();

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
3030
*/
3131
private $renderer;
3232

33+
protected static $supportedFeatureSetVersion = 304;
34+
3335
protected function setUp()
3436
{
3537
parent::setUp();

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
2727
*/
2828
protected $engine;
2929

30+
protected static $supportedFeatureSetVersion = 304;
31+
3032
protected function getExtensions()
3133
{
3234
// should be moved to the Form component once absolute file paths are supported

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
2727
*/
2828
protected $engine;
2929

30+
protected static $supportedFeatureSetVersion = 304;
31+
3032
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
3133
{
3234
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [

src/Symfony/Component/Form/Test/FormPerformanceTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Test;
1313

14+
use Symfony\Component\Form\Tests\VersionAwareTest;
15+
1416
/**
1517
* Base class for performance tests.
1618
*
@@ -21,6 +23,8 @@
2123
*/
2224
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
2325
{
26+
use VersionAwareTest;
27+
2428
/**
2529
* @var int
2630
*/

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
abstract class AbstractLayoutTest extends FormIntegrationTestCase
2020
{
21+
use VersionAwareTest;
22+
2123
protected $csrfTokenManager;
2224
protected $testableFeatures = [];
2325

src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\Test\TypeTestCase;
15+
use Symfony\Component\Form\Tests\VersionAwareTest;
1516

1617
/**
1718
* @author Bernhard Schussek <bschussek@gmail.com>
1819
*/
1920
abstract class BaseTypeTest extends TypeTestCase
2021
{
22+
use VersionAwareTest;
23+
2124
const TESTED_TYPE = '';
2225

2326
public function testPassDisabledAsOption()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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\Tests;
13+
14+
trait VersionAwareTest
15+
{
16+
protected static $supportedFeatureSetVersion = 304;
17+
18+
/**
19+
* @param int $requiredFeatureSetVersion
20+
*/
21+
protected function requiresFeatureSet($requiredFeatureSetVersion)
22+
{
23+
if ($requiredFeatureSetVersion > static::$supportedFeatureSetVersion) {
24+
$this->markTestSkipped(sprintf('Test requires features from symfony/form %.2f but only version %.2f is supported.', $requiredFeatureSetVersion / 100, static::$supportedFeatureSetVersion / 100));
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)
0