Skip to content

Commit

Permalink
minor #21233 [Form] Removed unused ResolvedTypeFactory in FormFactory…
Browse files Browse the repository at this point in the history
… constructor (HeahDude)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Form] Removed unused ResolvedTypeFactory in FormFactory constructor

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

____
This PR just removes some legacy code from 2.x.

Commits
-------

3607eb3 [Form] Removed unused ResolvedTypeFactory in FormFactory constructor
  • Loading branch information
fabpot committed Jan 10, 2017
2 parents 8b35478 + 3607eb3 commit cbecfc3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
11 changes: 1 addition & 10 deletions src/Symfony/Component/Form/FormFactory.php
Expand Up @@ -15,20 +15,11 @@

class FormFactory implements FormFactoryInterface
{
/**
* @var FormRegistryInterface
*/
private $registry;

/**
* @var ResolvedFormTypeFactoryInterface
*/
private $resolvedTypeFactory;

public function __construct(FormRegistryInterface $registry, ResolvedFormTypeFactoryInterface $resolvedTypeFactory)
public function __construct(FormRegistryInterface $registry)
{
$this->registry = $registry;
$this->resolvedTypeFactory = $resolvedTypeFactory;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Form/FormFactoryBuilder.php
Expand Up @@ -154,9 +154,8 @@ public function getFormFactory()
$extensions[] = new PreloadedExtension($this->types, $this->typeExtensions, $typeGuesser);
}

$resolvedTypeFactory = $this->resolvedTypeFactory ?: new ResolvedFormTypeFactory();
$registry = new FormRegistry($extensions, $resolvedTypeFactory);
$registry = new FormRegistry($extensions, $this->resolvedTypeFactory ?: new ResolvedFormTypeFactory());

return new FormFactory($registry, $resolvedTypeFactory);
return new FormFactory($registry);
}
}
12 changes: 3 additions & 9 deletions src/Symfony/Component/Form/Tests/FormFactoryTest.php
Expand Up @@ -37,11 +37,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
*/
private $registry;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $resolvedTypeFactory;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
Expand All @@ -54,12 +49,11 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactoryInterface')->getMock();
$this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
$this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
$this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
$this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock();
$this->factory = new FormFactory($this->registry, $this->resolvedTypeFactory);
$this->factory = new FormFactory($this->registry);

$this->registry->expects($this->any())
->method('getTypeGuesser')
Expand Down Expand Up @@ -244,7 +238,7 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser()
$registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
$factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
->setMethods(array('createNamedBuilder'))
->setConstructorArgs(array($registry, $this->resolvedTypeFactory))
->setConstructorArgs(array($registry))
->getMock();

$factory->expects($this->once())
Expand Down Expand Up @@ -474,7 +468,7 @@ private function getMockFactory(array $methods = array())
{
return $this->getMockBuilder('Symfony\Component\Form\FormFactory')
->setMethods($methods)
->setConstructorArgs(array($this->registry, $this->resolvedTypeFactory))
->setConstructorArgs(array($this->registry))
->getMock();
}

Expand Down

0 comments on commit cbecfc3

Please sign in to comment.