@@ -92,6 +92,29 @@ public static function provideFormUrlsCases(): iterable
9292 yield 'Remove Category ' => ['/admin/tests/app/category/1/delete ' , [], 'btn_delete ' ];
9393 }
9494
95+ public function testCreateFirstCategory (): void
96+ {
97+ $ client = self ::createClient ();
98+
99+ $ client ->request ('GET ' , '/admin/tests/app/category/create ' , [
100+ 'uniqid ' => 'category ' ,
101+ ]);
102+
103+ static ::assertSame (1 , $ this ->countCategories ());
104+
105+ $ client ->submitForm ('btn_create_and_list ' , [
106+ 'category[name] ' => 'Name ' ,
107+ ]);
108+ $ client ->followRedirect ();
109+
110+ self ::assertResponseIsSuccessful ();
111+
112+ $ client ->request ('GET ' , '/admin/tests/app/category/tree ' );
113+
114+ self ::assertResponseIsSuccessful ();
115+ static ::assertSame (2 , $ this ->countCategories ());
116+ }
117+
95118 /**
96119 * @psalm-suppress UndefinedPropertyFetch
97120 */
@@ -116,4 +139,18 @@ private function prepareData(): void
116139
117140 $ manager ->flush ();
118141 }
142+
143+ /**
144+ * @psalm-suppress UndefinedPropertyFetch
145+ */
146+ private function countCategories (): int
147+ {
148+ // TODO: Simplify this when dropping support for Symfony 4.
149+ // @phpstan-ignore-next-line
150+ $ container = method_exists (static ::class, 'getContainer ' ) ? static ::getContainer () : static ::$ container ;
151+ $ manager = $ container ->get ('doctrine.orm.entity_manager ' );
152+ \assert ($ manager instanceof EntityManagerInterface);
153+
154+ return $ manager ->getRepository (Category::class)->count ([]);
155+ }
119156}
0 commit comments