Merge branch '4.3' into 4.4

* 4.3:
  Fix assertInternalType deprecation in phpunit 9
  Ensure signatures for setUp|tearDown|setUpAfterClass|tearDownAfterClass methods in tests are compatible with phpunit 8.2
This commit is contained in:
Nicolas Grekas 2019-08-01 13:49:11 +02:00
commit 122a7cffb1
53 changed files with 77 additions and 74 deletions

View File

@ -27,7 +27,7 @@ class DoctrineCloseConnectionMiddlewareTest extends MiddlewareTestCase
private $middleware;
private $entityManagerName = 'default';
protected function setUp()
protected function setUp(): void
{
$this->connection = $this->createMock(Connection::class);

View File

@ -27,7 +27,7 @@ class DoctrinePingConnectionMiddlewareTest extends MiddlewareTestCase
private $middleware;
private $entityManagerName = 'default';
protected function setUp()
protected function setUp(): void
{
$this->connection = $this->createMock(Connection::class);

View File

@ -25,7 +25,7 @@ class DoctrineTransactionMiddlewareTest extends MiddlewareTestCase
private $entityManager;
private $middleware;
public function setUp()
public function setUp(): void
{
$this->connection = $this->createMock(Connection::class);

View File

@ -16,12 +16,12 @@ use Symfony\Bridge\PhpUnit\ClassExistsMock;
class ClassExistsMockTest extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
ClassExistsMock::register(__CLASS__);
}
protected function setUp()
protected function setUp(): void
{
ClassExistsMock::withMockedClasses([
ExistingClass::class => false,

View File

@ -23,7 +23,7 @@ class CachePoolDeleteCommandTest extends TestCase
{
private $cachePool;
protected function setUp()
protected function setUp(): void
{
$this->cachePool = $this->getMockBuilder(CacheItemPoolInterface::class)
->getMock();

View File

@ -131,13 +131,13 @@ EOF;
return $application;
}
protected function setUp()
protected function setUp(): void
{
@mkdir(sys_get_temp_dir().'/xliff-lint-test');
$this->files = [];
}
protected function tearDown()
protected function tearDown(): void
{
foreach ($this->files as $file) {
if (file_exists($file)) {

View File

@ -20,7 +20,7 @@ use Symfony\Component\Console\Tester\CommandTester;
*/
class CachePoolListCommandTest extends AbstractWebTestCase
{
protected function setUp()
protected function setUp(): void
{
static::bootKernel(['test_case' => 'CachePools', 'root_config' => 'config.yml']);
}

View File

@ -21,7 +21,7 @@ class RouterDebugCommandTest extends AbstractWebTestCase
{
private $application;
protected function setUp()
protected function setUp(): void
{
$kernel = static::createKernel(['test_case' => 'RouterDebug', 'root_config' => 'config.yml']);
$this->application = new Application($kernel);

View File

@ -21,7 +21,7 @@ class TranslationDebugCommandTest extends AbstractWebTestCase
{
private $application;
protected function setUp()
protected function setUp(): void
{
$kernel = static::createKernel(['test_case' => 'TransDebug', 'root_config' => 'config.yml']);
$this->application = new Application($kernel);

View File

@ -18,7 +18,7 @@ class PredisTagAwareAdapterTest extends PredisAdapterTest
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -18,7 +18,7 @@ class PredisTagAwareClusterAdapterTest extends PredisClusterAdapterTest
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -18,7 +18,7 @@ class PredisTagAwareRedisClusterAdapterTest extends PredisRedisClusterAdapterTes
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -19,7 +19,7 @@ class RedisTagAwareAdapterTest extends RedisAdapterTest
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -18,7 +18,7 @@ class RedisTagAwareArrayAdapterTest extends RedisArrayAdapterTest
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -19,7 +19,7 @@ class RedisTagAwareClusterAdapterTest extends RedisClusterAdapterTest
{
use TagAwareTestTrait;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';

View File

@ -24,7 +24,7 @@ class CachePoolPassTest extends TestCase
{
private $cachePoolPass;
protected function setUp()
protected function setUp(): void
{
$this->cachePoolPass = new CachePoolPass();
}

View File

@ -21,7 +21,7 @@ use Symfony\Component\Cache\Psr16Cache;
*/
class Psr16CacheTest extends SimpleCacheTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
class DumperNativeFallbackTest extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
ClassExistsMock::register(Dumper::class);
ClassExistsMock::withMockedClasses([
@ -27,7 +27,7 @@ class DumperNativeFallbackTest extends TestCase
]);
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
ClassExistsMock::withMockedClasses([]);
}

View File

@ -20,13 +20,13 @@ class DumperTest extends TestCase
{
use VarDumperTestTrait;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
putenv('DUMP_LIGHT_ARRAY=1');
putenv('DUMP_COMMA_SEPARATOR=1');
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
putenv('DUMP_LIGHT_ARRAY');
putenv('DUMP_COMMA_SEPARATOR');

View File

@ -24,12 +24,12 @@ class ConsoleSectionOutputTest extends TestCase
{
private $stream;
protected function setUp()
protected function setUp(): void
{
$this->stream = fopen('php://memory', 'r+b', false);
}
protected function tearDown()
protected function tearDown(): void
{
$this->stream = null;
}

View File

@ -19,7 +19,7 @@ class QuestionTest extends TestCase
{
private $question;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->question = new Question('Test question');

View File

@ -26,7 +26,7 @@ class ContainerBagTest extends TestCase
/** @var ContainerBag */
private $containerBag;
protected function setUp()
protected function setUp(): void
{
$this->parameterBag = new ParameterBag(['foo' => 'value']);
$this->containerBag = new ContainerBag(new Container($this->parameterBag));

View File

@ -23,7 +23,7 @@ class DebugClassLoaderTest extends TestCase
private $loader;
protected function setUp()
protected function setUp(): void
{
$this->errorReporting = error_reporting(E_ALL);
$this->loader = new ClassLoader();
@ -31,7 +31,7 @@ class DebugClassLoaderTest extends TestCase
DebugClassLoader::enable();
}
protected function tearDown()
protected function tearDown(): void
{
DebugClassLoader::disable();
spl_autoload_unregister([$this->loader, 'loadClass']);

View File

@ -32,13 +32,13 @@ class EventDispatcherTest extends TestCase
private $listener;
protected function setUp()
protected function setUp(): void
{
$this->dispatcher = $this->createEventDispatcher();
$this->listener = new TestEventListener();
}
protected function tearDown()
protected function tearDown(): void
{
$this->dispatcher = null;
$this->listener = null;

View File

@ -47,7 +47,7 @@ class IntlCallbackChoiceLoaderTest extends TestCase
*/
private static $lazyChoiceList;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$loader = new IntlCallbackChoiceLoader(function () {
return self::$choices;
@ -98,7 +98,7 @@ class IntlCallbackChoiceLoaderTest extends TestCase
);
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
self::$loader = null;
self::$value = null;

View File

@ -18,12 +18,12 @@ class StringToFloatTransformerTest extends TestCase
{
private $transformer;
protected function setUp()
protected function setUp(): void
{
$this->transformer = new StringToFloatTransformer();
}
protected function tearDown()
protected function tearDown(): void
{
$this->transformer = null;
}

View File

@ -23,7 +23,7 @@ class Psr18ClientTest extends TestCase
{
private static $server;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
TestHttpServer::start();
}

View File

@ -37,7 +37,7 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
*/
abstract protected function createRedisClient(string $host);
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -54,7 +54,7 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
);
}
protected function tearDown()
protected function tearDown(): void
{
$this->redisClient = null;
$this->storage = null;

View File

@ -20,7 +20,7 @@ class MigratingSessionHandlerTest extends TestCase
private $currentHandler;
private $writeOnlyHandler;
protected function setUp()
protected function setUp(): void
{
$this->currentHandler = $this->createMock(\SessionHandlerInterface::class);
$this->writeOnlyHandler = $this->createMock(\SessionHandlerInterface::class);

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
{
public static function setupBeforeClass()
public static function setUpBeforeClass(): void
{
if (!class_exists('RedisCluster')) {
self::markTestSkipped('The RedisCluster class is required.');

View File

@ -26,7 +26,7 @@ class LocaleAwareListenerTest extends TestCase
private $localeAwareService;
private $requestStack;
protected function setUp()
protected function setUp(): void
{
$this->localeAwareService = $this->getMockBuilder(LocaleAwareInterface::class)->getMock();
$this->requestStack = new RequestStack();

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Intl\Tests;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Currencies;
/**
@ -18,6 +19,8 @@ use Symfony\Component\Intl\Currencies;
*/
class CurrenciesTest extends ResourceBundleTestCase
{
use ForwardCompatTestTrait;
// The below arrays document the state of the ICU data bundled with this package.
private static $currencies = [
@ -693,7 +696,7 @@ class CurrenciesTest extends ResourceBundleTestCase
*/
public function testGetRoundingIncrement($currency)
{
$this->assertInternalType('numeric', Currencies::getRoundingIncrement($currency));
$this->assertIsNumeric(Currencies::getRoundingIncrement($currency));
}
public function provideCurrenciesWithNumericEquivalent()

View File

@ -696,7 +696,7 @@ abstract class ResourceBundleTestCase extends TestCase
private static $rootLocales;
protected function setUp()
protected function setUp(): void
{
Locale::setDefault('en');
Locale::setDefaultFallback('en');

View File

@ -25,7 +25,7 @@ class PdoDbalStoreTest extends AbstractStoreTest
protected static $dbFile;
public static function setupBeforeClass()
public static function setUpBeforeClass(): void
{
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_lock');
@ -33,7 +33,7 @@ class PdoDbalStoreTest extends AbstractStoreTest
$store->createTable();
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
@unlink(self::$dbFile);
}

View File

@ -25,7 +25,7 @@ class PdoStoreTest extends AbstractStoreTest
protected static $dbFile;
public static function setupBeforeClass()
public static function setUpBeforeClass(): void
{
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_lock');
@ -33,7 +33,7 @@ class PdoStoreTest extends AbstractStoreTest
$store->createTable();
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
@unlink(self::$dbFile);
}

View File

@ -26,12 +26,12 @@ use Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler;
*/
class DebugCommandTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
}
protected function tearDown()
protected function tearDown(): void
{
putenv('COLUMNS=');
}

View File

@ -28,7 +28,7 @@ class MessengerDataCollectorTest extends TestCase
/** @var CliDumper */
private $dumper;
protected function setUp()
protected function setUp(): void
{
$this->dumper = new CliDumper();
$this->dumper->setColors(false);

View File

@ -36,7 +36,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
*/
class AmqpExtIntegrationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

View File

@ -28,7 +28,7 @@ class InMemoryTransportFactoryTest extends TestCase
*/
private $factory;
protected function setUp()
protected function setUp(): void
{
$this->factory = new InMemoryTransportFactory();
}

View File

@ -25,7 +25,7 @@ class InMemoryTransportTest extends TestCase
*/
private $transport;
protected function setUp()
protected function setUp(): void
{
$this->transport = new InMemoryTransport();
}

View File

@ -23,7 +23,7 @@ class RedisExtIntegrationTest extends TestCase
private $redis;
private $connection;
protected function setUp()
protected function setUp(): void
{
if (!getenv('MESSENGER_REDIS_DSN')) {
$this->markTestSkipped('The "MESSENGER_REDIS_DSN" environment variable is required.');

View File

@ -16,7 +16,7 @@ use Symfony\Component\Mime\MimeTypeGuesserInterface;
abstract class AbstractMimeTypeGuesserTest extends TestCase
{
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
$path = __DIR__.'/Fixtures/mimetypes/to_delete';
if (file_exists($path)) {

View File

@ -41,7 +41,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase
*/
private $largeTestTmpFilepath;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -53,7 +53,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase
@unlink($this->largeTestTmpFilepath);
}
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();

View File

@ -26,14 +26,14 @@ class CompiledUrlMatcherDumperTest extends TestCase
*/
private $dumpPath;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->dumpPath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_matcher.'.uniqid('CompiledUrlMatcher').'.php';
}
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
class SodiumPasswordEncoderTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
if (!SodiumPasswordEncoder::isSupported()) {
$this->markTestSkipped('Libsodium is not available.');

View File

@ -25,7 +25,7 @@ class ConstraintViolationListNormalizerTest extends TestCase
{
private $normalizer;
protected function setUp()
protected function setUp(): void
{
$this->normalizer = new ConstraintViolationListNormalizer();
}

View File

@ -24,7 +24,7 @@ class DateTimeZoneNormalizerTest extends TestCase
*/
private $normalizer;
protected function setUp()
protected function setUp(): void
{
$this->normalizer = new DateTimeZoneNormalizer();
}

View File

@ -188,13 +188,13 @@ XLIFF;
return new CommandTester($command);
}
protected function setUp()
protected function setUp(): void
{
$this->files = [];
@mkdir(sys_get_temp_dir().'/translation-xliff-lint-test');
}
protected function tearDown()
protected function tearDown(): void
{
foreach ($this->files as $file) {
if (file_exists($file)) {

View File

@ -23,7 +23,7 @@ class CliDescriptorTest extends TestCase
private static $timezone;
private static $prevTerminalEmulator;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
@ -32,7 +32,7 @@ class CliDescriptorTest extends TestCase
putenv('TERMINAL_EMULATOR');
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
date_default_timezone_set(self::$timezone);
putenv('TERMINAL_EMULATOR'.(self::$prevTerminalEmulator ? '='.self::$prevTerminalEmulator : ''));

View File

@ -21,13 +21,13 @@ class HtmlDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
date_default_timezone_set(self::$timezone);
}

View File

@ -14,7 +14,7 @@ class InMemoryMetadataStoreTest extends TestCase
private $store;
private $transition;
protected function setUp()
protected function setUp(): void
{
$workflowMetadata = [
'title' => 'workflow title',

View File

@ -87,7 +87,7 @@ class RegistryTest extends TestCase
public function testAllWithOneMatchWithSuccess()
{
$workflows = $this->registry->all(new Subject1());
$this->assertInternalType('array', $workflows);
$this->assertIsArray($workflows);
$this->assertCount(1, $workflows);
$this->assertInstanceOf(Workflow::class, $workflows[0]);
$this->assertSame('workflow1', $workflows[0]->getName());
@ -96,7 +96,7 @@ class RegistryTest extends TestCase
public function testAllWithMultipleMatchWithSuccess()
{
$workflows = $this->registry->all(new Subject2());
$this->assertInternalType('array', $workflows);
$this->assertIsArray($workflows);
$this->assertCount(2, $workflows);
$this->assertInstanceOf(Workflow::class, $workflows[0]);
$this->assertInstanceOf(Workflow::class, $workflows[1]);
@ -107,7 +107,7 @@ class RegistryTest extends TestCase
public function testAllWithNoMatch()
{
$workflows = $this->registry->all(new \stdClass());
$this->assertInternalType('array', $workflows);
$this->assertIsArray($workflows);
$this->assertCount(0, $workflows);
}

View File

@ -25,12 +25,12 @@ class ParserTest extends TestCase
/** @var Parser */
protected $parser;
protected function setUp()
protected function setUp(): void
{
$this->parser = new Parser();
}
protected function tearDown()
protected function tearDown(): void
{
$this->parser = null;