minor #21867 [Form] fix BC layer for form type guessers (xabbuh)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[Form] fix BC layer for form type guessers
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
5c38c4f
[Form] fix BC layer for form type guessers
This commit is contained in:
commit
8953d0bc85
@ -42,6 +42,7 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
|||||||
$this->guesserServiceIds = $guesserServiceIds;
|
$this->guesserServiceIds = $guesserServiceIds;
|
||||||
$this->typeServiceIds = $typeExtensionServices;
|
$this->typeServiceIds = $typeExtensionServices;
|
||||||
$typeExtensionServices = $guesserServices;
|
$typeExtensionServices = $guesserServices;
|
||||||
|
$guesserServices = $guesserServiceIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->typeContainer = $typeContainer;
|
$this->typeContainer = $typeContainer;
|
||||||
|
@ -14,6 +14,8 @@ namespace Symfony\Component\Form\Tests\Extension\DependencyInjection;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension;
|
use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension;
|
||||||
|
use Symfony\Component\Form\FormTypeGuesserChain;
|
||||||
|
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||||
|
|
||||||
class DependencyInjectionExtensionTest extends TestCase
|
class DependencyInjectionExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -107,6 +109,49 @@ class DependencyInjectionExtensionTest extends TestCase
|
|||||||
$extension->getTypeExtensions('test');
|
$extension->getTypeExtensions('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetTypeGuesser()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerMock();
|
||||||
|
$extension = new DependencyInjectionExtension($container, array(), array($this->getMockBuilder(FormTypeGuesserInterface::class)->getMock()));
|
||||||
|
|
||||||
|
$this->assertInstanceOf(FormTypeGuesserChain::class, $extension->getTypeGuesser());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerMock();
|
||||||
|
$extension = new DependencyInjectionExtension($container, array(), array());
|
||||||
|
|
||||||
|
$this->assertNull($extension->getTypeGuesser());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
|
public function testLegacyGetTypeGuesser()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerMock();
|
||||||
|
$container
|
||||||
|
->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with('foo')
|
||||||
|
->willReturn($this->getMockBuilder(FormTypeGuesserInterface::class)->getMock());
|
||||||
|
$extension = new DependencyInjectionExtension($container, array(), array(), array('foo'));
|
||||||
|
|
||||||
|
$this->assertInstanceOf(FormTypeGuesserChain::class, $extension->getTypeGuesser());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
|
public function testLegacyGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerMock();
|
||||||
|
$extension = new DependencyInjectionExtension($container, array(), array(), array());
|
||||||
|
|
||||||
|
$this->assertNull($extension->getTypeGuesser());
|
||||||
|
}
|
||||||
|
|
||||||
private function createContainerMock()
|
private function createContainerMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Psr\Container\ContainerInterface')
|
return $this->getMockBuilder('Psr\Container\ContainerInterface')
|
||||||
|
Reference in New Issue
Block a user