Skip to content

Commit e0922a2

Browse files
committed
fix: corrected tests
1 parent e4d5210 commit e0922a2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/phpMyFAQ/Controller/Api/GlossaryControllerTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
33
namespace phpMyFAQ\Controller\Api;
44

55
use phpMyFAQ\Configuration;
6+
use phpMyFAQ\Language;
67
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
78
use PHPUnit\Framework\TestCase;
89
use Symfony\Component\HttpFoundation\JsonResponse;
910
use Symfony\Component\HttpFoundation\Request;
1011
use Symfony\Component\HttpFoundation\Response;
12+
use Symfony\Component\HttpFoundation\Session\Session;
1113

1214
#[AllowMockObjectsWithoutExpectations]
1315
class 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

Comments
 (0)