Merge branch '3.4' into 4.3
* 3.4: [Yaml] fix test for PHP 7.4 Add polyfill for TestCase::createMock() Skip tests that fatal-error on PHP 7.4 because of missing parent classes
This commit is contained in:
commit
9bfc12a577
@ -15,7 +15,14 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
// A trait to provide forward compatibility with newest PHPUnit versions
|
||||
|
||||
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
|
||||
$r = new \ReflectionClass(TestCase::class);
|
||||
|
||||
if (\PHP_VERSION_ID < 70000 || !$r->hasMethod('createMock') || !$r->getMethod('createMock')->hasReturnType()) {
|
||||
trait ForwardCompatTestTrait
|
||||
{
|
||||
use Legacy\ForwardCompatTestTraitForV5;
|
||||
}
|
||||
} elseif ($r->getMethod('tearDown')->hasReturnType()) {
|
||||
trait ForwardCompatTestTrait
|
||||
{
|
||||
use Legacy\ForwardCompatTestTraitForV8;
|
||||
@ -23,6 +30,6 @@ if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \Reflection
|
||||
} else {
|
||||
trait ForwardCompatTestTrait
|
||||
{
|
||||
use Legacy\ForwardCompatTestTraitForV5;
|
||||
use Legacy\ForwardCompatTestTraitForV7;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -80,6 +82,25 @@ trait ForwardCompatTestTraitForV5
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $originalClassName
|
||||
*
|
||||
* @return MockObject
|
||||
*/
|
||||
protected function createMock($originalClassName)
|
||||
{
|
||||
$mock = $this->getMockBuilder($originalClassName)
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->disableArgumentCloning();
|
||||
|
||||
if (method_exists($mock, 'disallowMockingUnknownTypes')) {
|
||||
$mock = $mock->disallowMockingUnknownTypes();
|
||||
}
|
||||
|
||||
return $mock->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?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\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait ForwardCompatTestTraitForV7
|
||||
{
|
||||
use ForwardCompatTestTraitForV5;
|
||||
|
||||
/**
|
||||
* @param string|string[] $originalClassName
|
||||
*/
|
||||
protected function createMock($originalClassName): MockObject
|
||||
{
|
||||
return $this->getMockBuilder($originalClassName)
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->disableArgumentCloning()
|
||||
->disallowMockingUnknownTypes()
|
||||
->getMock();
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
|
||||
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
@ -25,6 +26,10 @@ class ValidatorCacheWarmerTest extends TestCase
|
||||
|
||||
public function testWarmUp()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$validatorBuilder = new ValidatorBuilder();
|
||||
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
|
||||
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Config\Tests\Resource;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BadParent;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass;
|
||||
@ -77,6 +78,10 @@ EOF
|
||||
|
||||
public function testBadParentWithTimestamp()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$res = new ClassExistenceResource(BadParent::class, false);
|
||||
$this->assertTrue($res->isFresh(time()));
|
||||
}
|
||||
@ -87,6 +92,10 @@ EOF
|
||||
*/
|
||||
public function testBadParentWithNoTimestamp()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$res = new ClassExistenceResource(BadParent::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
@ -353,6 +354,10 @@ class AutowirePassTest extends TestCase
|
||||
*/
|
||||
public function testParentClassNotFoundThrowsException()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$aDefinition = $container->register('a', __NAMESPACE__.'\BadParentTypeHintedArgument');
|
||||
@ -618,6 +623,10 @@ class AutowirePassTest extends TestCase
|
||||
|
||||
public function testIgnoreServiceWithClassNotExisting()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register('class_not_exist', __NAMESPACE__.'\OptionalServiceClass');
|
||||
@ -823,6 +832,10 @@ class AutowirePassTest extends TestCase
|
||||
*/
|
||||
public function testExceptionWhenAliasDoesNotExist()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
// multiple I instances... but no IInterface alias
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
||||
@ -69,6 +70,10 @@ class ResolveBindingsPassTest extends TestCase
|
||||
*/
|
||||
public function testMissingParent()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definition = $container->register(ParentNotExists::class, ParentNotExists::class);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
@ -1060,6 +1061,10 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
public function testHotPathOptimizations()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = include self::$fixturesPath.'/containers/container_inline_requires.php';
|
||||
$container->setParameter('inline_requires', true);
|
||||
$container->compile();
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Psr\Container\ContainerInterface as PsrContainerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
@ -111,6 +112,10 @@ class FileLoaderTest extends TestCase
|
||||
|
||||
public function testRegisterClassesWithExclude()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('other_dir', 'OtherDir');
|
||||
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
|
||||
@ -159,6 +164,10 @@ class FileLoaderTest extends TestCase
|
||||
|
||||
public function testNestedRegisterClasses()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
|
||||
|
||||
@ -187,6 +196,10 @@ class FileLoaderTest extends TestCase
|
||||
|
||||
public function testMissingParentClass()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('bad_classes_dir', 'BadClasses');
|
||||
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Component\Validator\DataCollector\ValidatorDataCollector;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class ValidatorDataCollectorTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testCollectsValidatorCalls()
|
||||
{
|
||||
$originalValidator = $this->createMock(ValidatorInterface::class);
|
||||
@ -71,9 +74,4 @@ class ValidatorDataCollectorTest extends TestCase
|
||||
$this->assertCount(0, $collector->getCalls());
|
||||
$this->assertSame(0, $collector->getViolationsCount());
|
||||
}
|
||||
|
||||
protected function createMock($classname)
|
||||
{
|
||||
return $this->getMockBuilder($classname)->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests\Validator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
@ -23,6 +24,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class TraceableValidatorTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testValidate()
|
||||
{
|
||||
$originalValidator = $this->createMock(ValidatorInterface::class);
|
||||
@ -95,9 +98,4 @@ class TraceableValidatorTest extends TestCase
|
||||
$expects('validatePropertyValue')->willReturn($expected = new ConstraintViolationList());
|
||||
$this->assertSame($expected, $validator->validatePropertyValue(new \stdClass(), 'property', 'value'), 'returns original validator validatePropertyValue() result');
|
||||
}
|
||||
|
||||
protected function createMock($classname)
|
||||
{
|
||||
return $this->getMockBuilder($classname)->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ class ParserTest extends TestCase
|
||||
/** @var Parser */
|
||||
protected $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
private function doSetUp()
|
||||
{
|
||||
$this->parser = new Parser();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
private function doTearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
|
||||
|
Reference in New Issue
Block a user