@@ -35,9 +35,9 @@ public function testGetTypeExtensions()
3535 ->willReturn ('other ' );
3636
3737 $ services = array (
38- 'extension1 ' => $ typeExtension1 ,
39- 'extension2 ' => $ typeExtension2 ,
40- 'extension3 ' => $ typeExtension3 ,
38+ 'extension1 ' => $ typeExtension1 = $ this -> createFormTypeExtensionMock ( ' test ' ) ,
39+ 'extension2 ' => $ typeExtension2 = $ this -> createFormTypeExtensionMock ( ' test ' ) ,
40+ 'extension3 ' => $ typeExtension3 = $ this -> createFormTypeExtensionMock ( ' other ' ) ,
4141 );
4242
4343 $ container ->expects ($ this ->any ())
@@ -78,4 +78,33 @@ public function testThrowExceptionForInvalidExtendedType()
7878
7979 $ extension ->getTypeExtensions ('test ' );
8080 }
81+
82+ public function testGetTypeGuesser ()
83+ {
84+ $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerInterface ' )->getMock ();
85+ $ container
86+ ->expects ($ this ->once ())
87+ ->method ('get ' )
88+ ->with ('foo ' )
89+ ->willReturn ($ this ->getMockBuilder ('Symfony\Component\Form\FormTypeGuesserInterface ' )->getMock ());
90+ $ extension = new DependencyInjectionExtension ($ container , array (), array (), array ('foo ' ));
91+
92+ $ this ->assertInstanceOf ('Symfony\Component\Form\FormTypeGuesserChain ' , $ extension ->getTypeGuesser ());
93+ }
94+
95+ public function testGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured ()
96+ {
97+ $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerInterface ' )->getMock ();
98+ $ extension = new DependencyInjectionExtension ($ container , array (), array (), array ());
99+
100+ $ this ->assertNull ($ extension ->getTypeGuesser ());
101+ }
102+
103+ private function createFormTypeExtensionMock ($ extendedType )
104+ {
105+ $ extension = $ this ->getMockBuilder ('Symfony\Component\Form\FormTypeExtensionInterface ' )->getMock ();
106+ $ extension ->expects ($ this ->any ())->method ('getExtendedType ' )->willReturn ($ extendedType );
107+
108+ return $ extension ;
109+ }
81110}
0 commit comments