Skip to content

Commit

Permalink
Make tests support phpunit 8
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jul 31, 2019
1 parent 4e4e1eb commit e820e14
Show file tree
Hide file tree
Showing 58 changed files with 246 additions and 86 deletions.
2 changes: 1 addition & 1 deletion FormErrorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __toString()
if ($error instanceof FormError) {
$string .= 'ERROR: '.$error->getMessage()."\n";
} else {
/** @var self $error */
/* @var self $error */
$string .= $error->form->getName().":\n";
$string .= self::indent((string) $error);
}
Expand Down
2 changes: 1 addition & 1 deletion Test/FormIntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
abstract class FormIntegrationTestCase extends TestCase
{
use TestCaseSetUpTearDownTrait;
use ForwardCompatTestTrait;

/**
* @var FormFactoryInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @internal
*/
trait TestCaseSetUpTearDownTrait
trait ForwardCompatTestTrait
{
private function doSetUp(): void
{
Expand All @@ -47,7 +47,7 @@ protected function tearDown(): void
/**
* @internal
*/
trait TestCaseSetUpTearDownTrait
trait ForwardCompatTestTrait
{
/**
* @return void
Expand Down
2 changes: 1 addition & 1 deletion Test/TypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

abstract class TypeTestCase extends FormIntegrationTestCase
{
use TestCaseSetUpTearDownTrait;
use ForwardCompatTestTrait;

/**
* @var FormBuilder
Expand Down
7 changes: 5 additions & 2 deletions Tests/AbstractFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormBuilder;

abstract class AbstractFormTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var EventDispatcherInterface
*/
Expand All @@ -33,14 +36,14 @@ abstract class AbstractFormTest extends TestCase
*/
protected $form;

protected function setUp()
private function doSetUp()
{
$this->dispatcher = new EventDispatcher();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->form = $this->createForm();
}

protected function tearDown()
private function doTearDown()
{
$this->dispatcher = null;
$this->factory = null;
Expand Down
6 changes: 4 additions & 2 deletions Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@

namespace Symfony\Component\Form\Tests;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Test\FormIntegrationTestCase;

abstract class AbstractLayoutTest extends FormIntegrationTestCase
{
use ForwardCompatTestTrait;
use VersionAwareTest;

protected $csrfTokenManager;
protected $testableFeatures = [];

protected function setUp()
private function doSetUp()
{
if (!\extension_loaded('intl')) {
$this->markTestSkipped('Extension intl is required.');
Expand All @@ -43,7 +45,7 @@ protected function getExtensions()
];
}

protected function tearDown()
private function doTearDown()
{
$this->csrfTokenManager = null;

Expand Down
5 changes: 4 additions & 1 deletion Tests/AbstractRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
use Symfony\Component\Form\Form;
Expand All @@ -26,6 +27,8 @@
*/
abstract class AbstractRequestHandlerTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var RequestHandlerInterface
*/
Expand All @@ -40,7 +43,7 @@ abstract class AbstractRequestHandlerTest extends TestCase

protected $serverParams;

protected function setUp()
private function doSetUp()
{
$this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock();
$this->requestHandler = $this->getRequestHandler();
Expand Down
5 changes: 4 additions & 1 deletion Tests/ButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\FormBuilder;

Expand All @@ -20,11 +21,13 @@
*/
class ButtonTest extends TestCase
{
use ForwardCompatTestTrait;

private $dispatcher;

private $factory;

protected function setUp()
private function doSetUp()
{
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/AbstractChoiceListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
namespace Symfony\Component\Form\Tests\ChoiceList;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;

/**
* @author Bernhard Schussek <[email protected]>
*/
abstract class AbstractChoiceListTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var \Symfony\Component\Form\ChoiceList\ChoiceListInterface
*/
Expand Down Expand Up @@ -103,7 +106,7 @@ abstract class AbstractChoiceListTest extends TestCase
*/
protected $key4;

protected function setUp()
private function doSetUp()
{
parent::setUp();

Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/ArrayChoiceListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

namespace Symfony\Component\Form\Tests\ChoiceList;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;

/**
* @author Bernhard Schussek <[email protected]>
*/
class ArrayChoiceListTest extends AbstractChoiceListTest
{
use ForwardCompatTestTrait;

private $object;

protected function setUp()
private function doSetUp()
{
$this->object = new \stdClass();

Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Factory;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;

/**
* @author Bernhard Schussek <[email protected]>
*/
class CachingFactoryDecoratorTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
Expand All @@ -29,7 +32,7 @@ class CachingFactoryDecoratorTest extends TestCase
*/
private $factory;

protected function setUp()
private function doSetUp()
{
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->factory = new CachingFactoryDecorator($this->decoratedFactory);
Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Factory;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
Expand All @@ -22,6 +23,8 @@

class DefaultChoiceListFactoryTest extends TestCase
{
use ForwardCompatTestTrait;

private $obj1;

private $obj2;
Expand Down Expand Up @@ -84,7 +87,7 @@ public function getGroupAsObject($object)
: new DefaultChoiceListFactoryTest_Castable('Group 2');
}

protected function setUp()
private function doSetUp()
{
$this->obj1 = (object) ['label' => 'A', 'index' => 'w', 'value' => 'a', 'preferred' => false, 'group' => 'Group 1', 'attr' => []];
$this->obj2 = (object) ['label' => 'B', 'index' => 'x', 'value' => 'b', 'preferred' => true, 'group' => 'Group 1', 'attr' => ['attr1' => 'value1']];
Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Factory;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
use Symfony\Component\PropertyAccess\PropertyPath;

Expand All @@ -20,6 +21,8 @@
*/
class PropertyAccessDecoratorTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
Expand All @@ -30,7 +33,7 @@ class PropertyAccessDecoratorTest extends TestCase
*/
private $factory;

protected function setUp()
private function doSetUp()
{
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->factory = new PropertyAccessDecorator($this->decoratedFactory);
Expand Down
5 changes: 4 additions & 1 deletion Tests/ChoiceList/LazyChoiceListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;

Expand All @@ -20,6 +21,8 @@
*/
class LazyChoiceListTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var LazyChoiceList
*/
Expand All @@ -37,7 +40,7 @@ class LazyChoiceListTest extends TestCase

private $value;

protected function setUp()
private function doSetUp()
{
$this->loadedList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
Expand Down
7 changes: 5 additions & 2 deletions Tests/ChoiceList/Loader/CallbackChoiceLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;

Expand All @@ -20,6 +21,8 @@
*/
class CallbackChoiceLoaderTest extends TestCase
{
use ForwardCompatTestTrait;

/**
* @var \Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader
*/
Expand All @@ -45,7 +48,7 @@ class CallbackChoiceLoaderTest extends TestCase
*/
private static $lazyChoiceList;

public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$loader = new CallbackChoiceLoader(function () {
return self::$choices;
Expand Down Expand Up @@ -91,7 +94,7 @@ public function testLoadValuesForChoicesLoadsChoiceListOnFirstCall()
);
}

public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::$loader = null;
self::$value = null;
Expand Down
7 changes: 5 additions & 2 deletions Tests/Console/Descriptor/JsonDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

namespace Symfony\Component\Form\Tests\Console\Descriptor;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Console\Descriptor\JsonDescriptor;

class JsonDescriptorTest extends AbstractDescriptorTest
{
protected function setUp()
use ForwardCompatTestTrait;

private function doSetUp()
{
putenv('COLUMNS=121');
}

protected function tearDown()
private function doTearDown()
{
putenv('COLUMNS');
}
Expand Down
7 changes: 5 additions & 2 deletions Tests/Console/Descriptor/TextDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

namespace Symfony\Component\Form\Tests\Console\Descriptor;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Console\Descriptor\TextDescriptor;

class TextDescriptorTest extends AbstractDescriptorTest
{
protected function setUp()
use ForwardCompatTestTrait;

private function doSetUp()
{
putenv('COLUMNS=121');
}

protected function tearDown()
private function doTearDown()
{
putenv('COLUMNS');
}
Expand Down
Loading

0 comments on commit e820e14

Please sign in to comment.