12
12
namespace Symfony \Component \Form \Tests \Extension \DependencyInjection ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
15
16
use Symfony \Component \Form \AbstractTypeExtension ;
16
17
use Symfony \Component \Form \Extension \DependencyInjection \DependencyInjectionExtension ;
17
18
use Symfony \Component \Form \FormTypeGuesserChain ;
@@ -21,9 +22,6 @@ class DependencyInjectionExtensionTest extends TestCase
21
22
{
22
23
public function testGetTypeExtensions ()
23
24
{
24
- $ container = $ this ->createContainerMock ();
25
- $ container ->expects ($ this ->never ())->method ('get ' );
26
-
27
25
$ typeExtension1 = new TestTypeExtension ();
28
26
$ typeExtension2 = new TestTypeExtension ();
29
27
$ typeExtension3 = new OtherTypeExtension ();
@@ -34,7 +32,7 @@ public function testGetTypeExtensions()
34
32
'other ' => new \ArrayIterator ([$ typeExtension3 , $ typeExtension4 ]),
35
33
];
36
34
37
- $ extension = new DependencyInjectionExtension ($ container , $ extensions , []);
35
+ $ extension = new DependencyInjectionExtension (new ContainerBuilder () , $ extensions , []);
38
36
39
37
$ this ->assertTrue ($ extension ->hasTypeExtensions ('test ' ));
40
38
$ this ->assertTrue ($ extension ->hasTypeExtensions ('other ' ));
@@ -48,40 +46,28 @@ public function testGetTypeExtensions()
48
46
*/
49
47
public function testThrowExceptionForInvalidExtendedType ()
50
48
{
51
- $ container = $ this ->getMockBuilder ('Psr\Container\ContainerInterface ' )->getMock ();
52
- $ container ->expects ($ this ->never ())->method ('get ' );
53
-
54
49
$ extensions = [
55
50
'unmatched ' => new \ArrayIterator ([new TestTypeExtension ()]),
56
51
];
57
52
58
- $ extension = new DependencyInjectionExtension ($ container , $ extensions , []);
53
+ $ extension = new DependencyInjectionExtension (new ContainerBuilder () , $ extensions , []);
59
54
60
55
$ extension ->getTypeExtensions ('unmatched ' );
61
56
}
62
57
63
58
public function testGetTypeGuesser ()
64
59
{
65
- $ container = $ this ->createContainerMock ();
66
- $ extension = new DependencyInjectionExtension ($ container , [], [$ this ->getMockBuilder (FormTypeGuesserInterface::class)->getMock ()]);
60
+ $ extension = new DependencyInjectionExtension (new ContainerBuilder (), [], [$ this ->getMockBuilder (FormTypeGuesserInterface::class)->getMock ()]);
67
61
68
62
$ this ->assertInstanceOf (FormTypeGuesserChain::class, $ extension ->getTypeGuesser ());
69
63
}
70
64
71
65
public function testGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured ()
72
66
{
73
- $ container = $ this ->createContainerMock ();
74
- $ extension = new DependencyInjectionExtension ($ container , [], []);
67
+ $ extension = new DependencyInjectionExtension (new ContainerBuilder (), [], []);
75
68
76
69
$ this ->assertNull ($ extension ->getTypeGuesser ());
77
70
}
78
-
79
- private function createContainerMock ()
80
- {
81
- return $ this ->getMockBuilder ('Psr\Container\ContainerInterface ' )
82
- ->setMethods (['get ' , 'has ' ])
83
- ->getMock ();
84
- }
85
71
}
86
72
87
73
class TestTypeExtension extends AbstractTypeExtension
0 commit comments