Skip to content

Commit 4f8606b

Browse files
committed
allow to skip tests based on the supported version
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.
1 parent 78b2567 commit 4f8606b

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

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
*/

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

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 <[email protected]>
1819
*/
1920
abstract class BaseTypeTest extends TypeTestCase
2021
{
22+
use VersionAwareTest;
23+
2124
const TESTED_TYPE = '';
2225

2326
public function testPassDisabledAsOption()

Tests/VersionAwareTest.php

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 <[email protected]>
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)