diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index 0fb83f5dcfe0..8895da5b9b7e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -35,9 +35,9 @@ public function testGetTypeExtensions() ->willReturn('other'); $services = array( - 'extension1' => $typeExtension1, - 'extension2' => $typeExtension2, - 'extension3' => $typeExtension3, + 'extension1' => $typeExtension1 = $this->createFormTypeExtensionMock('test'), + 'extension2' => $typeExtension2 = $this->createFormTypeExtensionMock('test'), + 'extension3' => $typeExtension3 = $this->createFormTypeExtensionMock('other'), ); $container->expects($this->any()) @@ -78,4 +78,33 @@ public function testThrowExceptionForInvalidExtendedType() $extension->getTypeExtensions('test'); } + + public function testGetTypeGuesser() + { + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container + ->expects($this->once()) + ->method('get') + ->with('foo') + ->willReturn($this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock()); + $extension = new DependencyInjectionExtension($container, array(), array(), array('foo')); + + $this->assertInstanceOf('Symfony\Component\Form\FormTypeGuesserChain', $extension->getTypeGuesser()); + } + + public function testGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured() + { + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $extension = new DependencyInjectionExtension($container, array(), array(), array()); + + $this->assertNull($extension->getTypeGuesser()); + } + + private function createFormTypeExtensionMock($extendedType) + { + $extension = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); + $extension->expects($this->any())->method('getExtendedType')->willReturn($extendedType); + + return $extension; + } } diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 93c17a7bf6e6..cff703344b78 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -513,22 +513,20 @@ public function testSetDataIsIgnoredIfDataIsLocked() $this->assertSame('default', $form->getData()); } - public function testPresSetDataChangesDataIfDataIsLocked() + public function testPreSetDataChangesDataIfDataIsLocked() { $config = new FormConfigBuilder('name', null, $this->dispatcher); $config ->setData('default') ->setDataLocked(true) - ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { + ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $event->setData('foobar'); }); $form = new Form($config); - $form->submit(false); - - $this->assertTrue($form->isValid()); - $this->assertSame('foobar', $form->getData()); + $this->assertSame('foobar', $form->getNormData()); + $this->assertSame('foobar', $form->getViewData()); } public function testSubmitConvertsEmptyToNullIfNoTransformer() diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index c564937a8de6..8360b460c0ab 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -26,7 +26,7 @@ "require-dev": { "doctrine/collections": "~1.0", "symfony/validator": "^2.8.18|~3.2.5", - "symfony/dependency-injection": "~2.3|~3.0.0", + "symfony/dependency-injection": "~2.7|~3.0.0", "symfony/http-foundation": "~2.2|~3.0.0", "symfony/http-kernel": "~2.4|~3.0.0", "symfony/security-csrf": "~2.4|~3.0.0",