@@ -294,4 +294,63 @@ public function testMultipleUnrecognizedBracketsWithRealLabels()
294294 $ this ->assertSame (1234 , $ responseData ['pull_request ' ]);
295295 $ this ->assertSame ('[Console][FrameworkBundle][TODO][WIP][Foo] Some title ' , $ responseData ['new_title ' ]);
296296 }
297+
298+ /**
299+ * @dataProvider provideTitles
300+ */
301+ public function testBundleNormalizationForSymfonyAi (string $ inputTitle , string $ expectedTitle )
302+ {
303+ $ repository = new Repository ('symfony ' , 'ai ' , null );
304+ $ event = new GitHubEvent (['action ' => 'labeled ' , 'number ' => 1234 , 'pull_request ' => []], $ repository );
305+ $ this ->pullRequestApi ->method ('show ' )->willReturn ([
306+ 'title ' => $ inputTitle ,
307+ 'labels ' => [],
308+ ]);
309+
310+ $ this ->dispatcher ->dispatch ($ event , GitHubEvents::PULL_REQUEST );
311+ $ responseData = $ event ->getResponseData ();
312+
313+ $ this ->assertCount (2 , $ responseData );
314+ $ this ->assertSame (1234 , $ responseData ['pull_request ' ]);
315+ $ this ->assertSame ($ expectedTitle , $ responseData ['new_title ' ]);
316+ }
317+
318+ /**
319+ * @return iterable<string, array{string, string}>
320+ */
321+ public static function provideTitles (): iterable
322+ {
323+ yield 'AiBundle without space ' => ['[AiBundle] Fix something ' , '[AI Bundle] Fix something ' ];
324+ yield 'Ai Bundle with space ' => ['[Ai Bundle] Fix something ' , '[AI Bundle] Fix something ' ];
325+ yield 'lowercase aibundle ' => ['[aibundle] Fix something ' , '[AI Bundle] Fix something ' ];
326+ yield 'lowercase ai bundle ' => ['[ai bundle] Fix something ' , '[AI Bundle] Fix something ' ];
327+ yield 'uppercase AIBUNDLE ' => ['[AIBUNDLE] Fix something ' , '[AI Bundle] Fix something ' ];
328+ yield 'uppercase AI BUNDLE ' => ['[AI BUNDLE] Fix something ' , '[AI Bundle] Fix something ' ];
329+ yield 'ai-bundle with hyphen ' => ['[ai-bundle] Fix something ' , '[AI Bundle] Fix something ' ];
330+ yield 'AI-Bundle with hyphen ' => ['[AI-Bundle] Fix something ' , '[AI Bundle] Fix something ' ];
331+ yield 'McpBundle without space ' => ['[McpBundle] Fix something ' , '[MCP Bundle] Fix something ' ];
332+ yield 'Mcp Bundle with space ' => ['[Mcp Bundle] Fix something ' , '[MCP Bundle] Fix something ' ];
333+ yield 'lowercase mcpbundle ' => ['[mcpbundle] Fix something ' , '[MCP Bundle] Fix something ' ];
334+ yield 'lowercase mcp bundle ' => ['[mcp bundle] Fix something ' , '[MCP Bundle] Fix something ' ];
335+ yield 'uppercase MCPBUNDLE ' => ['[MCPBUNDLE] Fix something ' , '[MCP Bundle] Fix something ' ];
336+ yield 'uppercase MCP BUNDLE ' => ['[MCP BUNDLE] Fix something ' , '[MCP Bundle] Fix something ' ];
337+ yield 'mcp-bundle with hyphen ' => ['[mcp-bundle] Fix something ' , '[MCP Bundle] Fix something ' ];
338+ yield 'MCP-Bundle with hyphen ' => ['[MCP-Bundle] Fix something ' , '[MCP Bundle] Fix something ' ];
339+ }
340+
341+ public function testAiBundleNotNormalizedForOtherRepositories ()
342+ {
343+ $ repository = new Repository ('symfony ' , 'symfony ' , null );
344+ $ event = new GitHubEvent (['action ' => 'labeled ' , 'number ' => 1234 , 'pull_request ' => []], $ repository );
345+ $ this ->pullRequestApi ->method ('show ' )->willReturn ([
346+ 'title ' => '[AiBundle] Fix something ' ,
347+ 'labels ' => [],
348+ ]);
349+
350+ $ this ->dispatcher ->dispatch ($ event , GitHubEvents::PULL_REQUEST );
351+ $ responseData = $ event ->getResponseData ();
352+
353+ // No change expected for non-symfony/ai repositories
354+ $ this ->assertEmpty ($ responseData );
355+ }
297356}
0 commit comments