33namespace phpMyFAQ \Controller \Api ;
44
55use phpMyFAQ \Configuration ;
6+ use phpMyFAQ \Language ;
67use PHPUnit \Framework \Attributes \AllowMockObjectsWithoutExpectations ;
78use PHPUnit \Framework \TestCase ;
89use Symfony \Component \HttpFoundation \JsonResponse ;
910use Symfony \Component \HttpFoundation \Request ;
1011use Symfony \Component \HttpFoundation \Response ;
12+ use Symfony \Component \HttpFoundation \Session \Session ;
1113
1214#[AllowMockObjectsWithoutExpectations]
1315class GlossaryControllerTest extends TestCase
1416{
1517 private Configuration $ configuration ;
1618
17- public function testListReturnsGlossaryItems (): void
19+ protected function setUp (): void
1820 {
1921 $ this ->configuration = Configuration::getConfigurationInstance ();
22+ $ language = new Language ($ this ->configuration , $ this ->createStub (Session::class));
23+ $ language ->setLanguageWithDetection ('language_en.php ' );
24+ $ this ->configuration ->setLanguage ($ language );
25+ }
26+
27+ public function testListReturnsGlossaryItems (): void
28+ {
2029
2130 $ glossaryController = new GlossaryController ();
2231
@@ -37,8 +46,6 @@ public function testListReturnsGlossaryItems(): void
3746
3847 public function testListHandlesAcceptLanguageHeader (): void
3948 {
40- $ this ->configuration = Configuration::getConfigurationInstance ();
41-
4249 $ glossaryController = new GlossaryController ();
4350
4451 // Test with complex Accept-Language header
@@ -54,8 +61,6 @@ public function testListHandlesAcceptLanguageHeader(): void
5461
5562 public function testListWithoutAcceptLanguageHeader (): void
5663 {
57- $ this ->configuration = Configuration::getConfigurationInstance ();
58-
5964 $ glossaryController = new GlossaryController ();
6065
6166 $ request = Request::create ('/api/v3.2/glossary ' , 'GET ' );
0 commit comments