Skip to content

Commit

Permalink
minor #32854 Ensure signatures for setUp|tearDown|setUpAfterClass|tea…
Browse files Browse the repository at this point in the history
…rDownAfterClass methods in tests are compatible with phpunit 8.2 (luispabon)

This PR was squashed before being merged into the 4.3 branch (closes #32854).

Discussion
----------

Ensure signatures for setUp|tearDown|setUpAfterClass|tearDownAfterClass methods in tests are compatible with phpunit 8.2

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | n/a

Please bear with me as this is my first pr to symfony. Branched off 4.3 as requested here: #32844

Tests currently do not pass due to:

```
PHP Fatal error:  Declaration of Symfony\Bridge\Monolog\Logger::reset() must be compatible with Monolog\Logger::reset(): void in /home/luis/Projects/symfony/src/Symfony/Bridge/Monolog/Logger.php on line 23
```

Commits
-------

97bcb5d Ensure signatures for setUp|tearDown|setUpAfterClass|tearDownAfterClass methods in tests are compatible with phpunit 8.2
  • Loading branch information
nicolas-grekas committed Aug 1, 2019
2 parents 2523451 + 97bcb5d commit 0ebf7ee
Show file tree
Hide file tree
Showing 48 changed files with 65 additions and 65 deletions.
Expand Up @@ -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);

Expand Down
Expand Up @@ -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);

Expand Down
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/PhpUnit/Tests/ClassExistsMockTest.php
Expand Up @@ -16,12 +16,12 @@

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,
Expand Down
Expand Up @@ -23,7 +23,7 @@ class CachePoolDeleteCommandTest extends TestCase
{
private $cachePool;

protected function setUp()
protected function setUp(): void
{
$this->cachePool = $this->getMockBuilder(CacheItemPoolInterface::class)
->getMock();
Expand Down
Expand Up @@ -131,13 +131,13 @@ private function getKernelAwareApplicationMock()
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)) {
Expand Down
Expand Up @@ -20,7 +20,7 @@
*/
class CachePoolListCommandTest extends AbstractWebTestCase
{
protected function setUp()
protected function setUp(): void
{
static::bootKernel(['test_case' => 'CachePools', 'root_config' => 'config.yml']);
}
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -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';
Expand Down
Expand Up @@ -24,7 +24,7 @@ class CachePoolPassTest extends TestCase
{
private $cachePoolPass;

protected function setUp()
protected function setUp(): void
{
$this->cachePoolPass = new CachePoolPass();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Tests/Psr16CacheTest.php
Expand Up @@ -21,7 +21,7 @@
*/
class Psr16CacheTest extends SimpleCacheTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
Expand Up @@ -19,15 +19,15 @@

class DumperNativeFallbackTest extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
ClassExistsMock::register(Dumper::class);
ClassExistsMock::withMockedClasses([
CliDumper::class => false,
]);
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
ClassExistsMock::withMockedClasses([]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Tests/Helper/DumperTest.php
Expand Up @@ -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');
Expand Down
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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');
Expand Down
Expand Up @@ -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));
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testLoadValuesForChoicesLoadsChoiceListOnFirstCall()
);
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
self::$loader = null;
self::$value = null;
Expand Down
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/Tests/Psr18ClientTest.php
Expand Up @@ -23,7 +23,7 @@ class Psr18ClientTest extends TestCase
{
private static $server;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
TestHttpServer::start();
}
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -13,7 +13,7 @@

class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
{
public static function setupBeforeClass()
public static function setUpBeforeClass(): void
{
if (!class_exists('RedisCluster')) {
self::markTestSkipped('The RedisCluster class is required.');
Expand Down
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php
Expand Up @@ -25,15 +25,15 @@ 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');

$store = new PdoStore(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
$store->createTable();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
@unlink(self::$dbFile);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php
Expand Up @@ -24,15 +24,15 @@ 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');

$store = new PdoStore('sqlite:'.self::$dbFile);
$store->createTable();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
@unlink(self::$dbFile);
}
Expand Down
Expand Up @@ -26,12 +26,12 @@
*/
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=');
}
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -36,7 +36,7 @@
*/
class AmqpExtIntegrationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
Expand Up @@ -28,7 +28,7 @@ class InMemoryTransportFactoryTest extends TestCase
*/
private $factory;

protected function setUp()
protected function setUp(): void
{
$this->factory = new InMemoryTransportFactory();
}
Expand Down

0 comments on commit 0ebf7ee

Please sign in to comment.