Skip to content

Commit c0e4d31

Browse files
Merge pull request #19074 from kamil-tekiela/testing-phpunit
Fixing PHPUnit performance
2 parents 7d6bddd + abdaefc commit c0e4d31

14 files changed

Lines changed: 0 additions & 98 deletions

tests/unit/Controllers/JavaScriptMessagesControllerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpMyAdmin\Controllers\JavaScriptMessagesController;
99
use PhpMyAdmin\Http\Factory\ResponseFactory;
1010
use PHPUnit\Framework\Attributes\CoversClass;
11-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1211
use PHPUnit\Framework\TestCase;
1312

1413
use function json_decode;
@@ -18,7 +17,6 @@
1817
#[CoversClass(JavaScriptMessagesController::class)]
1918
class JavaScriptMessagesControllerTest extends TestCase
2019
{
21-
#[RunInSeparateProcess]
2220
public function testIndex(): void
2321
{
2422
$response = (new JavaScriptMessagesController(ResponseFactory::create()))();

tests/unit/Controllers/SchemaExportControllerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
use PhpMyAdmin\Tests\AbstractTestCase;
1212
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
1313
use PHPUnit\Framework\Attributes\CoversClass;
14-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1514

1615
#[CoversClass(SchemaExportController::class)]
1716
class SchemaExportControllerTest extends AbstractTestCase
1817
{
19-
#[RunInSeparateProcess]
2018
public function testExport(): void
2119
{
2220
DatabaseInterface::$instance = $this->createDatabaseInterface();

tests/unit/Controllers/Table/GetFieldControllerTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313
use PhpMyAdmin\Tests\AbstractTestCase;
1414
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
1515
use PHPUnit\Framework\Attributes\CoversClass;
16-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
17-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1816

1917
use function bin2hex;
2018

2119
#[CoversClass(GetFieldController::class)]
2220
class GetFieldControllerTest extends AbstractTestCase
2321
{
24-
#[PreserveGlobalState(false)]
25-
#[RunInSeparateProcess]
2622
public function testGetFieldController(): void
2723
{
2824
Current::$database = 'test_db';

tests/unit/Controllers/ThemeSetControllerTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use PhpMyAdmin\UserPreferences;
1616
use PHPUnit\Framework\Attributes\CoversClass;
1717
use PHPUnit\Framework\Attributes\DataProvider;
18-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
19-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2018

2119
#[CoversClass(ThemeSetController::class)]
2220
class ThemeSetControllerTest extends AbstractTestCase
@@ -28,8 +26,6 @@ protected function setUp(): void
2826
DatabaseInterface::$instance = $this->createDatabaseInterface();
2927
}
3028

31-
#[PreserveGlobalState(false)]
32-
#[RunInSeparateProcess]
3329
public function testSetTheme(): void
3430
{
3531
Config::getInstance()->settings['ThemeManager'] = true;
@@ -52,8 +48,6 @@ public function testSetTheme(): void
5248

5349
/** @param string[]|string|null $themeName */
5450
#[DataProvider('providerForTestWithoutTheme')]
55-
#[PreserveGlobalState(false)]
56-
#[RunInSeparateProcess]
5751
public function testWithoutTheme(bool $hasThemes, array|string|null $themeName): void
5852
{
5953
Config::getInstance()->settings['ThemeManager'] = $hasThemes;

tests/unit/Http/Factory/ServerRequestFactoryTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ public function testCreateWithoutProvider(): void
110110
* @psalm-param class-string<UriInterface> $expectedUri
111111
*/
112112
#[DataProvider('providerForTestFromGlobals')]
113-
#[RunInSeparateProcess]
114-
#[PreserveGlobalState(false)]
115113
public function testFromGlobals(string $provider, string $uriFactoryProvider, string $expectedUri): void
116114
{
117115
$this->skipIfNotAvailable($provider);
@@ -149,8 +147,6 @@ public function testFromGlobals(string $provider, string $uriFactoryProvider, st
149147
* @psalm-param class-string<UriInterface> $expectedUri
150148
*/
151149
#[DataProvider('providerForTestFromGlobals')]
152-
#[RunInSeparateProcess]
153-
#[PreserveGlobalState(false)]
154150
public function testFromGlobals2(string $provider, string $uriFactoryProvider, string $expectedUri): void
155151
{
156152
$this->skipIfNotAvailable($provider);
@@ -203,8 +199,6 @@ public function testFromGlobals2(string $provider, string $uriFactoryProvider, s
203199
* @psalm-param class-string<UriInterface> $expectedUri
204200
*/
205201
#[DataProvider('providerForTestFromGlobals')]
206-
#[RunInSeparateProcess]
207-
#[PreserveGlobalState(false)]
208202
public function testFromGlobals3(string $provider, string $uriFactoryProvider, string $expectedUri): void
209203
{
210204
$this->skipIfNotAvailable($provider);

tests/unit/Plugins/Auth/AuthenticationConfigTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
use PhpMyAdmin\Tests\AbstractTestCase;
1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Medium;
16-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
17-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1816
use ReflectionProperty;
1917
use Throwable;
2018

@@ -57,8 +55,6 @@ protected function tearDown(): void
5755
unset($this->object);
5856
}
5957

60-
#[RunInSeparateProcess]
61-
#[PreserveGlobalState(false)]
6258
public function testAuth(): void
6359
{
6460
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
@@ -82,8 +78,6 @@ public function testAuthSetUser(): void
8278
);
8379
}
8480

85-
#[RunInSeparateProcess]
86-
#[PreserveGlobalState(false)]
8781
public function testAuthFails(): void
8882
{
8983
Config::getInstance()->settings['Servers'] = [1];

tests/unit/Plugins/Auth/AuthenticationCookieTest.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use PHPUnit\Framework\Attributes\CoversClass;
1717
use PHPUnit\Framework\Attributes\DataProvider;
1818
use PHPUnit\Framework\Attributes\Medium;
19-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
20-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2119
use ReflectionException;
2220
use ReflectionMethod;
2321
use ReflectionProperty;
@@ -74,8 +72,6 @@ protected function tearDown(): void
7472
unset($this->object);
7573
}
7674

77-
#[RunInSeparateProcess]
78-
#[PreserveGlobalState(false)]
7975
public function testAuthErrorAJAX(): void
8076
{
8177
$GLOBALS['conn_error'] = true;
@@ -113,8 +109,6 @@ private function getAuthErrorMockResponse(): void
113109
ErrorHandler::$instance = $mockErrorHandler;
114110
}
115111

116-
#[RunInSeparateProcess]
117-
#[PreserveGlobalState(false)]
118112
public function testAuthError(): void
119113
{
120114
$_REQUEST = [];
@@ -189,8 +183,6 @@ public function testAuthError(): void
189183
self::assertStringContainsString('<input type="hidden" name="table" value="testTable">', $result);
190184
}
191185

192-
#[RunInSeparateProcess]
193-
#[PreserveGlobalState(false)]
194186
public function testAuthCaptcha(): void
195187
{
196188
$_REQUEST['old_usr'] = '';
@@ -251,8 +243,6 @@ public function testAuthCaptcha(): void
251243
);
252244
}
253245

254-
#[RunInSeparateProcess]
255-
#[PreserveGlobalState(false)]
256246
public function testAuthCaptchaCheckbox(): void
257247
{
258248
$_REQUEST['old_usr'] = '';
@@ -315,8 +305,6 @@ public function testAuthCaptchaCheckbox(): void
315305
);
316306
}
317307

318-
#[RunInSeparateProcess]
319-
#[PreserveGlobalState(false)]
320308
public function testAuthHeader(): void
321309
{
322310
$config = Config::getInstance();
@@ -336,8 +324,6 @@ public function testAuthHeader(): void
336324
self::assertSame(302, $response->getStatusCode());
337325
}
338326

339-
#[RunInSeparateProcess]
340-
#[PreserveGlobalState(false)]
341327
public function testAuthHeaderPartial(): void
342328
{
343329
$config = Config::getInstance();
@@ -377,8 +363,6 @@ public function testAuthCheckCaptcha(): void
377363
self::assertSame('Missing Captcha verification, maybe it has been blocked by adblock?', $GLOBALS['conn_error']);
378364
}
379365

380-
#[RunInSeparateProcess]
381-
#[PreserveGlobalState(false)]
382366
public function testLogoutDelete(): void
383367
{
384368
$responseStub = new ResponseRendererStub();
@@ -406,8 +390,6 @@ public function testLogoutDelete(): void
406390
self::assertArrayNotHasKey('pmaAuth-0', $_COOKIE);
407391
}
408392

409-
#[RunInSeparateProcess]
410-
#[PreserveGlobalState(false)]
411393
public function testLogout(): void
412394
{
413395
$responseStub = new ResponseRendererStub();
@@ -657,8 +639,6 @@ public function testAuthSetUserWithHeaders(): void
657639
$this->object->rememberCredentials();
658640
}
659641

660-
#[RunInSeparateProcess]
661-
#[PreserveGlobalState(false)]
662642
public function testAuthFailsNoPass(): void
663643
{
664644
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -727,8 +707,6 @@ public function testAuthFailsTooLongPass(string $password, bool $expected, strin
727707
self::assertSame($GLOBALS['conn_error'], $connError);
728708
}
729709

730-
#[RunInSeparateProcess]
731-
#[PreserveGlobalState(false)]
732710
public function testAuthFailsDeny(): void
733711
{
734712
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -759,8 +737,6 @@ public function testAuthFailsDeny(): void
759737
self::assertSame($GLOBALS['conn_error'], 'Access denied!');
760738
}
761739

762-
#[RunInSeparateProcess]
763-
#[PreserveGlobalState(false)]
764740
public function testAuthFailsActivity(): void
765741
{
766742
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -798,8 +774,6 @@ public function testAuthFailsActivity(): void
798774
);
799775
}
800776

801-
#[RunInSeparateProcess]
802-
#[PreserveGlobalState(false)]
803777
public function testAuthFailsDBI(): void
804778
{
805779
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -841,8 +815,6 @@ public function testAuthFailsDBI(): void
841815
self::assertSame($GLOBALS['conn_error'], '#42 Cannot log in to the MySQL server');
842816
}
843817

844-
#[RunInSeparateProcess]
845-
#[PreserveGlobalState(false)]
846818
public function testAuthFailsErrno(): void
847819
{
848820
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -1007,8 +979,6 @@ public function testAuthenticate(): void
1007979
* @param mixed[] $rules rules
1008980
* @param string $expected expected result
1009981
*/
1010-
#[RunInSeparateProcess]
1011-
#[PreserveGlobalState(false)]
1012982
#[DataProvider('checkRulesProvider')]
1013983
public function testCheckRules(
1014984
string $user,

tests/unit/Plugins/Auth/AuthenticationHttpTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use PHPUnit\Framework\Attributes\CoversClass;
1616
use PHPUnit\Framework\Attributes\DataProvider;
1717
use PHPUnit\Framework\Attributes\Medium;
18-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
19-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2018
use ReflectionProperty;
2119
use Throwable;
2220

@@ -59,8 +57,6 @@ protected function tearDown(): void
5957
unset($this->object);
6058
}
6159

62-
#[RunInSeparateProcess]
63-
#[PreserveGlobalState(false)]
6460
public function testAuthLogoutUrl(): void
6561
{
6662
$config = Config::getInstance();
@@ -77,8 +73,6 @@ public function testAuthLogoutUrl(): void
7773
self::assertSame(302, $response->getStatusCode());
7874
}
7975

80-
#[RunInSeparateProcess]
81-
#[PreserveGlobalState(false)]
8276
public function testAuthVerbose(): void
8377
{
8478
$config = Config::getInstance();
@@ -99,8 +93,6 @@ public function testAuthVerbose(): void
9993
self::assertSame(401, $response->getStatusCode());
10094
}
10195

102-
#[RunInSeparateProcess]
103-
#[PreserveGlobalState(false)]
10496
public function testAuthHost(): void
10597
{
10698
$config = Config::getInstance();
@@ -122,8 +114,6 @@ public function testAuthHost(): void
122114
self::assertSame(401, $response->getStatusCode());
123115
}
124116

125-
#[RunInSeparateProcess]
126-
#[PreserveGlobalState(false)]
127117
public function testAuthRealm(): void
128118
{
129119
$config = Config::getInstance();
@@ -276,8 +266,6 @@ public function testAuthSetUser(): void
276266
self::assertSame(3, Current::$server);
277267
}
278268

279-
#[RunInSeparateProcess]
280-
#[PreserveGlobalState(false)]
281269
public function testAuthFails(): void
282270
{
283271
$config = Config::getInstance();

tests/unit/Plugins/Auth/AuthenticationSignonTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use PhpMyAdmin\Tests\AbstractTestCase;
1515
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
1616
use PHPUnit\Framework\Attributes\CoversClass;
17-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
18-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1917
use ReflectionProperty;
2018
use Throwable;
2119

@@ -57,8 +55,6 @@ protected function tearDown(): void
5755
unset($this->object);
5856
}
5957

60-
#[RunInSeparateProcess]
61-
#[PreserveGlobalState(false)]
6258
public function testAuth(): void
6359
{
6460
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
@@ -81,8 +77,6 @@ public function testAuth(): void
8177
self::assertStringContainsString('You must set SignonURL!', $result);
8278
}
8379

84-
#[RunInSeparateProcess]
85-
#[PreserveGlobalState(false)]
8680
public function testAuthLogoutURL(): void
8781
{
8882
$responseStub = new ResponseRendererStub();
@@ -99,8 +93,6 @@ public function testAuthLogoutURL(): void
9993
self::assertSame(302, $response->getStatusCode());
10094
}
10195

102-
#[RunInSeparateProcess]
103-
#[PreserveGlobalState(false)]
10496
public function testAuthLogout(): void
10597
{
10698
$responseStub = new ResponseRendererStub();
@@ -151,8 +143,6 @@ public function testAuthCheckSession(): void
151143
self::assertSame('https://example.com/SignonURL', $_SESSION['LAST_SIGNON_URL']);
152144
}
153145

154-
#[RunInSeparateProcess]
155-
#[PreserveGlobalState(false)]
156146
public function testAuthCheckToken(): void
157147
{
158148
$_SESSION = [' PMA_token ' => 'eefefef'];

tests/unit/SessionTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66

77
use PhpMyAdmin\Session;
88
use PHPUnit\Framework\Attributes\CoversClass;
9-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
10-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
119
use PHPUnit\Framework\TestCase;
1210

1311
#[CoversClass(Session::class)]
1412
final class SessionTest extends TestCase
1513
{
16-
#[RunInSeparateProcess]
17-
#[PreserveGlobalState(false)]
1814
public function testSecure(): void
1915
{
2016
$_SESSION[' PMA_token '] = null;

0 commit comments

Comments
 (0)