8000 [Tests] Replace `setUp()`/`tearDown()` with `before()`/`after()` by phansys · Pull Request #32651 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Tests] Replace setUp()/tearDown() with before()/after() #32651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ matrix:
env: deps=high
- php: 7.3
env: deps=low
- php: 7.4snapshot
fast_finish: true

cache:
Expand Down Expand Up @@ -178,7 +179,7 @@ before_install:
[[ -e $ext_cache ]] || (tfold ext.symfony_debug "cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && mv modules/symfony_debug.so $ext_cache && phpize --clean")
echo extension = $ext_cache >> $INI
elif [[ $PHP = 7.* ]]; then
tfold ext.apcu tpecl apcu-5.1.16 apcu.so $INI
tfold ext.apcu tpecl apcu-5.1.17 apcu.so $INI
tfold ext.mongodb tpecl mongodb-1.6.0alpha1 mongodb.so $INI
fi
done
Expand Down
8 changes: 6 additions & 2 deletions phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}
if (\PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
if (\PHP_VERSION_ID >= 70400) {
putenv('SYMFONY_PHPUNIT_VERSION=8.2');
} elseif (\PHP_VERSION_ID >= 70000) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class ContainerAwareEventManagerTest extends TestCase
private $container;
private $evm;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->container = new Container();
$this->evm = new ContainerAwareEventManager($this->container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ class DoctrineExtensionTest extends TestCase
*/
private $extension;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();

$this->extension = $this
->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class DoctrineChoiceLoaderTest extends TestCase
*/
private $obj3;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class CollectionToArrayTransformerTest extends TestCase
*/
private $transformer;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->transformer = new CollectionToArrayTransformer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class MergeDoctrineCollectionListenerTest extends TestCase
private $factory;
private $form;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->collection = new ArrayCollection(['test']);
$this->dispatcher = new EventDispatcher();
Expand All @@ -37,7 +40,10 @@ protected function setUp()
->getForm();
}

protected function tearDown()
/**
* @after
*/
protected function after()
{
$this->collection = null;
$this->dispatcher = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ protected function getExtensions()
];
}

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->em = DoctrineTestHelper::createTestEntityManager();

parent::setUp();

$schemaTool = new SchemaTool($this->em);
$classes = [
$this->em->getClassMetadata(self::ENTITY_CLASS),
Expand Down
13 changes: 8 additions & 5 deletions src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ class EntityTypeTest extends BaseTypeTest

protected static $supportedFeatureSetVersion = 304;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->em = DoctrineTestHelper::createTestEntityManager();
$this->emRegistry = $this->createRegistryMock('default', $this->em);

parent::setUp();

$schemaTool = new SchemaTool($this->em);
$classes = [
$this->em->getClassMetadata(self::ITEM_GROUP_CLASS),
Expand All @@ -89,9 +90,11 @@ protected function setUp()
}
}

protected function tearDown()
/**
* @after
*/
protected function after()
{
parent::tearDown();

$this->em = null;
$this->emRegistry = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class DoctrineExtractorTest extends TestCase
*/
private $extractor;

protected function setUp()
/**
* @before
*/
protected function before()
{
$config = Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true);
$entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase

protected $repositoryFactory;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->repositoryFactory = new TestRepositoryFactory();

Expand All @@ -73,7 +76,6 @@ protected function setUp()
$this->registry = $this->createRegistryMock($this->em);
$this->createSchema($this->em);

parent::setUp();
}

protected function createRegistryMock(ObjectManager $em = null)
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public static function setUpBeforeClass()
ClockMock::register(__CLASS__);
}

protected function setUp()
/**
* @before
*/
protected function before()
{
ClockMock::withClockMock(1234567890.125);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

class DnsMockTest extends TestCase
{
protected function tearDown()
/**
* @after
*/
protected function after()
{
DnsMock::withMockedHosts(array());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ class RuntimeInstantiatorTest extends TestCase

/**
* {@inheritdoc}
*
* @before
*/
protected function setUp()
protected function before()
{
$this->instantiator = new RuntimeInstantiator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class ProxyDumperTest extends TestCase

/**
* {@inheritdoc}
*
* @before
*/
protected function setUp()
protected function before()
{
$this->dumper = new ProxyDumper();
}
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class AppVariableTest extends TestCase
*/
protected $appVariable;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->appVariable = new AppVariable();
}
Expand Down
10 changes: 8 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ private function createFile($content)
return $filename;
}

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->files = [];
}

protected function tearDown()
/**
* @after
*/
protected function after()
{
foreach ($this->files as $file) {
if (file_exists($file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
*/
private $renderer;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
*/
private $renderer;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori

private $renderer;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
*/
private $renderer;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest

protected static $supportedFeatureSetVersion = 304;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest

protected static $supportedFeatureSetVersion = 304;

protected function setUp()
/**
* @before
*/
protected function before()
{
parent::setUp();
parent::before();

$loader = new StubFilesystemLoader([
__DIR__.'/../../Resources/views/Form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class WebLinkExtensionTest extends TestCase
*/
private $extension;

protected function setUp()
/**
* @before
*/
protected function before()
{
$this->request = new Request();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class WorkflowExtensionTest extends TestCase
{
private $extension;

protected function setUp()
/**
* @before
*/
protected function before()
{
$places = ['ordered', 'waiting_for_payment', 'processed'];
$transitions = [
Expand Down
Loading
0