|
4 | 4 |
|
5 | 5 | namespace phpMyFAQ\Controller\Administration\Api; |
6 | 6 |
|
| 7 | +final class LdapControllerTestRuntime |
| 8 | +{ |
| 9 | + public static ?bool $ldapExtensionLoaded = null; |
| 10 | +} |
| 11 | + |
| 12 | +function extension_loaded(string $extension): bool |
| 13 | +{ |
| 14 | + if ($extension === 'ldap' && LdapControllerTestRuntime::$ldapExtensionLoaded !== null) { |
| 15 | + return LdapControllerTestRuntime::$ldapExtensionLoaded; |
| 16 | + } |
| 17 | + |
| 18 | + return \extension_loaded($extension); |
| 19 | +} |
| 20 | + |
7 | 21 | use phpMyFAQ\Configuration; |
8 | 22 | use phpMyFAQ\Core\Exception; |
9 | 23 | use phpMyFAQ\Database; |
@@ -38,6 +52,7 @@ final class LdapControllerTest extends TestCase |
38 | 52 | protected function setUp(): void |
39 | 53 | { |
40 | 54 | parent::setUp(); |
| 55 | + LdapControllerTestRuntime::$ldapExtensionLoaded = null; |
41 | 56 |
|
42 | 57 | Strings::init(); |
43 | 58 |
|
@@ -75,6 +90,8 @@ protected function setUp(): void |
75 | 90 |
|
76 | 91 | protected function tearDown(): void |
77 | 92 | { |
| 93 | + LdapControllerTestRuntime::$ldapExtensionLoaded = null; |
| 94 | + |
78 | 95 | $configurationReflection = new \ReflectionClass(Configuration::class); |
79 | 96 | $configurationProperty = $configurationReflection->getProperty('configuration'); |
80 | 97 | $configurationProperty->setValue(null, $this->previousConfiguration); |
@@ -188,9 +205,7 @@ public function testConfigurationStripsPasswords(): void |
188 | 205 |
|
189 | 206 | public function testHealthcheckReturnsUnavailableWhenExtensionMissing(): void |
190 | 207 | { |
191 | | - if (extension_loaded('ldap')) { |
192 | | - self::markTestSkipped('LDAP extension is loaded; cannot test missing extension path.'); |
193 | | - } |
| 208 | + LdapControllerTestRuntime::$ldapExtensionLoaded = false; |
194 | 209 |
|
195 | 210 | $controller = $this->createController(); |
196 | 211 | $controller->setContainer($this->createAuthenticatedContainer()); |
|
0 commit comments