@@ -35,9 +35,9 @@ public function testGetTypeExtensions()
35
35
->willReturn ('other ' );
36
36
37
37
$ 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 ' ) ,
41
41
);
42
42
43
43
$ container ->expects ($ this ->any ())
@@ -78,4 +78,33 @@ public function testThrowExceptionForInvalidExtendedType()
78
78
79
79
$ extension ->getTypeExtensions ('test ' );
80
80
}
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
+ }
81
110
}
0 commit comments