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.
This commit is contained in:
parent
320c05f9f1
commit
be23926bf8
@ -30,6 +30,8 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
protected function getExtensions()
|
protected function getExtensions()
|
||||||
{
|
{
|
||||||
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||||
|
@ -57,6 +57,8 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
*/
|
*/
|
||||||
private $emRegistry;
|
private $emRegistry;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Form\Tests\AbstractLayoutTest;
|
|||||||
|
|
||||||
abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||||
{
|
{
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
public function testLabelOnForm()
|
public function testLabelOnForm()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
|
||||||
|
@ -31,6 +31,8 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
*/
|
*/
|
||||||
private $renderer;
|
private $renderer;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -30,6 +30,8 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
*/
|
*/
|
||||||
private $renderer;
|
private $renderer;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -27,6 +27,8 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
*/
|
*/
|
||||||
protected $engine;
|
protected $engine;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
protected function getExtensions()
|
protected function getExtensions()
|
||||||
{
|
{
|
||||||
// should be moved to the Form component once absolute file paths are supported
|
// should be moved to the Form component once absolute file paths are supported
|
||||||
|
@ -27,6 +27,8 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
*/
|
*/
|
||||||
protected $engine;
|
protected $engine;
|
||||||
|
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Test;
|
namespace Symfony\Component\Form\Test;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Tests\VersionAwareTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for performance tests.
|
* Base class for performance tests.
|
||||||
*
|
*
|
||||||
@ -21,6 +23,8 @@ namespace Symfony\Component\Form\Test;
|
|||||||
*/
|
*/
|
||||||
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
|
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
|
||||||
{
|
{
|
||||||
|
use VersionAwareTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,8 @@ use Symfony\Component\Form\Test\FormIntegrationTestCase;
|
|||||||
|
|
||||||
abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||||
{
|
{
|
||||||
|
use VersionAwareTest;
|
||||||
|
|
||||||
protected $csrfTokenManager;
|
protected $csrfTokenManager;
|
||||||
protected $testableFeatures = [];
|
protected $testableFeatures = [];
|
||||||
|
|
||||||
|
@ -12,12 +12,15 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\Test\TypeTestCase;
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
use Symfony\Component\Form\Tests\VersionAwareTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
abstract class BaseTypeTest extends TypeTestCase
|
abstract class BaseTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
|
use VersionAwareTest;
|
||||||
|
|
||||||
const TESTED_TYPE = '';
|
const TESTED_TYPE = '';
|
||||||
|
|
||||||
public function testPassDisabledAsOption()
|
public function testPassDisabledAsOption()
|
||||||
|
27
src/Symfony/Component/Form/Tests/VersionAwareTest.php
Normal file
27
src/Symfony/Component/Form/Tests/VersionAwareTest.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
trait VersionAwareTest
|
||||||
|
{
|
||||||
|
protected static $supportedFeatureSetVersion = 304;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $requiredFeatureSetVersion
|
||||||
|
*/
|
||||||
|
protected function requiresFeatureSet($requiredFeatureSetVersion)
|
||||||
|
{
|
||||||
|
if ($requiredFeatureSetVersion > static::$supportedFeatureSetVersion) {
|
||||||
|
$this->markTestSkipped(sprintf('Test requires features from symfony/form %.2f but only version %.2f is supported.', $requiredFeatureSetVersion / 100, static::$supportedFeatureSetVersion / 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user