Skip to content

Commit

Permalink
Merge branch '4.2'
Browse files Browse the repository at this point in the history
* 4.2: (27 commits)
  cs fix
  cs fix
  [PHPUnit-Bridge] override some environment variables
  [TwigBridge] Remove use spaceless tag
  Upgrade zookeeper ext
  [translation] Update defaut format from yml to yaml
  Change default log level for output streams
  update docblock to match the actual behavior
  Don't resolve the Deprecation error handler mode until a deprecation is triggered
  compatibility with phpunit8
  Make 'headers' key optional for encoded messages
  [Debug][DebugClassLoader] Detect annotations before blank docblock lines on final and internal methods
  Fix undefined variable fromConstructor when passing context to getTypes
  Added translations for chineese language.
  Allow 3rd argument to be null
  Remove whitespace (tab on blank line)
  [Monolog] Really reset logger when calling logger::reset()
  [Form] Fixes debug:form appears many times as type extensions configured with new getExtendedTypes method
  Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
  Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
  ...
  • Loading branch information
nicolas-grekas committed Mar 10, 2019
2 parents 0389292 + 321a2a4 commit 02c8b41
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/FormPass.php
Expand Up @@ -102,9 +102,9 @@ private function processFormTypeExtensions(ContainerBuilder $container)
} elseif (method_exists($serviceDefinition->getClass(), 'getExtendedTypes')) {
$extendsTypes = false;

$typeExtensionsClasses[] = $serviceDefinition->getClass();
foreach ($serviceDefinition->getClass()::getExtendedTypes() as $extendedType) {
$typeExtensions[$extendedType][] = new Reference($serviceId);
$typeExtensionsClasses[] = $serviceDefinition->getClass();
$extendsTypes = true;
}

Expand Down
4 changes: 3 additions & 1 deletion Test/FormIntegrationTestCase.php
Expand Up @@ -20,12 +20,14 @@
*/
abstract class FormIntegrationTestCase extends TestCase
{
use TestCaseSetUpTearDownTrait;

/**
* @var FormFactoryInterface
*/
protected $factory;

protected function setUp()
private function doSetUp()
{
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
Expand Down
82 changes: 82 additions & 0 deletions Test/TestCaseSetUpTearDownTrait.php
@@ -0,0 +1,82 @@
<?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\Component\Form\Test;

use PHPUnit\Framework\TestCase;

// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods

if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
eval('
namespace Symfony\Component\Form\Test;
/**
* @internal
*/
trait TestCaseSetUpTearDownTrait
{
private function doSetUp(): void
{
}
private function doTearDown(): void
{
}
protected function setUp(): void
{
$this->doSetUp();
}
protected function tearDown(): void
{
$this->doTearDown();
}
}
');
} else {
/**
* @internal
*/
trait TestCaseSetUpTearDownTrait
{
/**
* @return void
*/
private function doSetUp()
{
}

/**
* @return void
*/
private function doTearDown()
{
}

/**
* @return void
*/
protected function setUp()
{
$this->doSetUp();
}

/**
* @return void
*/
protected function tearDown()
{
$this->doTearDown();
}
}
}
6 changes: 4 additions & 2 deletions Test/TypeTestCase.php
Expand Up @@ -17,6 +17,8 @@

abstract class TypeTestCase extends FormIntegrationTestCase
{
use TestCaseSetUpTearDownTrait;

/**
* @var FormBuilder
*/
Expand All @@ -27,15 +29,15 @@ abstract class TypeTestCase extends FormIntegrationTestCase
*/
protected $dispatcher;

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

$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory);
}

protected function tearDown()
private function doTearDown()
{
if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) {
$this->validator = null;
Expand Down

0 comments on commit 02c8b41

Please sign in to comment.