2222
2323use DarkWebDesign \SymfonyAddon \FormType \EntityType ;
2424use DarkWebDesign \SymfonyAddon \FormType \Tests \Models \City ;
25+ use Symfony \Component \Form \PreloadedExtension ;
2526use Symfony \Component \Form \Test \TypeTestCase ;
2627
2728class EntityTypeTest extends TypeTestCase
@@ -47,13 +48,8 @@ class EntityTypeTest extends TypeTestCase
4748 /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata */
4849 private $ metadata ;
4950
50- /** @var \DarkWebDesign\SymfonyAddon\FormType\EntityType */
51- private $ type ;
52-
5351 protected function setUp ()
5452 {
55- parent ::setUp ();
56-
5753 $ this ->entity = new City ();
5854 $ this ->entity ->setId (123 );
5955
@@ -72,8 +68,20 @@ protected function setUp()
7268 $ this ->metadata ->method ('getIdentifierValues ' )->willReturn (array ('id ' => $ this ->identifier ));
7369
7470 $ this ->metadata ->isIdentifierComposite = false ;
75-
76- $ this ->type = new EntityType ($ this ->registry );
71+
72+ parent ::setUp ();
73+ }
74+
75+ /**
76+ * @return array
77+ */
78+ protected function getExtensions ()
79+ {
80+ $ type = new EntityType ($ this ->registry );
81+
82+ return array (
83+ new PreloadedExtension (array ($ type ), array ()),
84+ );
7785 }
7886
7987 public function test ()
@@ -86,7 +94,7 @@ public function test()
8694 'class ' => $ this ->className ,
8795 );
8896
89- $ form = $ this ->factory ->create ($ this -> type , null , $ options );
97+ $ form = $ this ->factory ->create (EntityType::class , null , $ options );
9098 $ form ->submit ($ this ->identifier );
9199
92100 $ this ->assertTrue ($ form ->isSynchronized ());
@@ -103,7 +111,7 @@ public function testEntityNotFound()
103111 'class ' => $ this ->className ,
104112 );
105113
106- $ form = $ this ->factory ->create ($ this -> type , null , $ options );
114+ $ form = $ this ->factory ->create (EntityType::class , null , $ options );
107115 $ form ->submit ($ this ->identifier );
108116
109117 $ this ->assertFalse ($ form ->isSynchronized ());
@@ -119,7 +127,7 @@ public function testEntityManagerObject()
119127 'entity_manager ' => $ this ->entityManager ,
120128 );
121129
122- $ form = $ this ->factory ->create ($ this -> type , null , $ options );
130+ $ form = $ this ->factory ->create (EntityType::class , null , $ options );
123131 $ form ->submit ($ this ->identifier );
124132
125133 $ this ->assertTrue ($ form ->isSynchronized ());
@@ -137,7 +145,7 @@ public function testEntityManagerString()
137145 'entity_manager ' => 'Doctrine\ORM\EntityManager ' ,
138146 );
139147
140- $ form = $ this ->factory ->create ($ this -> type , null , $ options );
148+ $ form = $ this ->factory ->create (EntityType::class , null , $ options );
141149 $ form ->submit ($ this ->identifier );
142150
143151 $ this ->assertTrue ($ form ->isSynchronized ());
@@ -159,7 +167,7 @@ public function testNoEntityManager()
159167 'class ' => $ this ->className ,
160168 );
161169
162- $ form = $ this ->factory ->create ($ this -> type , null , $ options );
170+ $ form = $ this ->factory ->create (EntityType::class , null , $ options );
163171 $ form ->submit ($ this ->identifier );
164172
165173 $ this ->assertTrue ($ form ->isSynchronized ());
0 commit comments