Skip to content

Commit 1179692

Browse files
Merge pull request #18696 from MauricioFauth/phpunit-max-execution-time-error
Fix max execution time exceeded error in tests
2 parents 97ebf29 + 56b9b8d commit 1179692

6 files changed

Lines changed: 72 additions & 36 deletions

File tree

test/classes/Http/Factory/ServerRequestFactoryTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
1818
use PhpMyAdmin\Http\Factory\UriFactory;
1919
use PhpMyAdmin\Http\ServerRequest;
20-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
2120
use PHPUnit\Framework\Attributes\CoversClass;
2221
use PHPUnit\Framework\Attributes\DataProvider;
2322
use PHPUnit\Framework\Attributes\Medium;
23+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
24+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2425
use PHPUnit\Framework\TestCase;
2526
use Psr\Http\Message\ServerRequestFactoryInterface;
2627
use Psr\Http\Message\ServerRequestInterface;
@@ -70,7 +71,8 @@ public static function providerForTestCreateServerRequest(): iterable
7071

7172
/** @psalm-param class-string<ServerRequestFactoryInterface> $provider */
7273
#[DataProvider('providerForTestCreate')]
73-
#[BackupStaticProperties(true)]
74+
#[RunInSeparateProcess]
75+
#[PreserveGlobalState(false)]
7476
public function testCreate(string $provider): void
7577
{
7678
$this->skipIfNotAvailable($provider);
@@ -91,7 +93,8 @@ public static function providerForTestCreate(): iterable
9193
yield 'httpsoft/http-message' => [HttpSoftServerRequestFactory::class];
9294
}
9395

94-
#[BackupStaticProperties(true)]
96+
#[RunInSeparateProcess]
97+
#[PreserveGlobalState(false)]
9598
public function testCreateWithoutProvider(): void
9699
{
97100
(new ReflectionProperty(ServerRequestFactory::class, 'providers'))
@@ -107,7 +110,8 @@ public function testCreateWithoutProvider(): void
107110
* @psalm-param class-string<UriInterface> $expectedUri
108111
*/
109112
#[DataProvider('providerForTestFromGlobals')]
110-
#[BackupStaticProperties(true)]
113+
#[RunInSeparateProcess]
114+
#[PreserveGlobalState(false)]
111115
public function testFromGlobals(string $provider, string $uriFactoryProvider, string $expectedUri): void
112116
{
113117
$this->skipIfNotAvailable($provider);
@@ -145,7 +149,8 @@ public function testFromGlobals(string $provider, string $uriFactoryProvider, st
145149
* @psalm-param class-string<UriInterface> $expectedUri
146150
*/
147151
#[DataProvider('providerForTestFromGlobals')]
148-
#[BackupStaticProperties(true)]
152+
#[RunInSeparateProcess]
153+
#[PreserveGlobalState(false)]
149154
public function testFromGlobals2(string $provider, string $uriFactoryProvider, string $expectedUri): void
150155
{
151156
$this->skipIfNotAvailable($provider);
@@ -198,7 +203,8 @@ public function testFromGlobals2(string $provider, string $uriFactoryProvider, s
198203
* @psalm-param class-string<UriInterface> $expectedUri
199204
*/
200205
#[DataProvider('providerForTestFromGlobals')]
201-
#[BackupStaticProperties(true)]
206+
#[RunInSeparateProcess]
207+
#[PreserveGlobalState(false)]
202208
public function testFromGlobals3(string $provider, string $uriFactoryProvider, string $expectedUri): void
203209
{
204210
$this->skipIfNotAvailable($provider);

test/classes/Plugins/Auth/AuthenticationConfigTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use PhpMyAdmin\Plugins\Auth\AuthenticationConfig;
1111
use PhpMyAdmin\ResponseRenderer;
1212
use PhpMyAdmin\Tests\AbstractTestCase;
13-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
1413
use PHPUnit\Framework\Attributes\CoversClass;
1514
use PHPUnit\Framework\Attributes\Medium;
15+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
16+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1617
use ReflectionProperty;
1718
use Throwable;
1819

@@ -57,7 +58,8 @@ protected function tearDown(): void
5758
unset($this->object);
5859
}
5960

60-
#[BackupStaticProperties(true)]
61+
#[RunInSeparateProcess]
62+
#[PreserveGlobalState(false)]
6163
public function testAuth(): void
6264
{
6365
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
@@ -81,7 +83,8 @@ public function testAuthSetUser(): void
8183
);
8284
}
8385

84-
#[BackupStaticProperties(true)]
86+
#[RunInSeparateProcess]
87+
#[PreserveGlobalState(false)]
8588
public function testAuthFails(): void
8689
{
8790
Config::getInstance()->settings['Servers'] = [1];

test/classes/Plugins/Auth/AuthenticationCookieTest.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
use PhpMyAdmin\ResponseRenderer;
1313
use PhpMyAdmin\Tests\AbstractTestCase;
1414
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
15-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
1615
use PHPUnit\Framework\Attributes\CoversClass;
1716
use PHPUnit\Framework\Attributes\DataProvider;
1817
use PHPUnit\Framework\Attributes\Group;
1918
use PHPUnit\Framework\Attributes\Medium;
19+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
20+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2021
use ReflectionException;
2122
use ReflectionMethod;
2223
use ReflectionProperty;
@@ -78,7 +79,8 @@ protected function tearDown(): void
7879
}
7980

8081
#[Group('medium')]
81-
#[BackupStaticProperties(true)]
82+
#[RunInSeparateProcess]
83+
#[PreserveGlobalState(false)]
8284
public function testAuthErrorAJAX(): void
8385
{
8486
$GLOBALS['conn_error'] = true;
@@ -116,7 +118,8 @@ private function getAuthErrorMockResponse(): void
116118
ErrorHandler::$instance = $mockErrorHandler;
117119
}
118120

119-
#[BackupStaticProperties(true)]
121+
#[RunInSeparateProcess]
122+
#[PreserveGlobalState(false)]
120123
#[Group('medium')]
121124
public function testAuthError(): void
122125
{
@@ -192,7 +195,8 @@ public function testAuthError(): void
192195
$this->assertStringContainsString('<input type="hidden" name="table" value="testTable">', $result);
193196
}
194197

195-
#[BackupStaticProperties(true)]
198+
#[RunInSeparateProcess]
199+
#[PreserveGlobalState(false)]
196200
#[Group('medium')]
197201
public function testAuthCaptcha(): void
198202
{
@@ -254,7 +258,8 @@ public function testAuthCaptcha(): void
254258
);
255259
}
256260

257-
#[BackupStaticProperties(true)]
261+
#[RunInSeparateProcess]
262+
#[PreserveGlobalState(false)]
258263
#[Group('medium')]
259264
public function testAuthCaptchaCheckbox(): void
260265
{
@@ -318,7 +323,8 @@ public function testAuthCaptchaCheckbox(): void
318323
);
319324
}
320325

321-
#[BackupStaticProperties(true)]
326+
#[RunInSeparateProcess]
327+
#[PreserveGlobalState(false)]
322328
public function testAuthHeader(): void
323329
{
324330
$config = Config::getInstance();
@@ -338,7 +344,8 @@ public function testAuthHeader(): void
338344
$this->assertSame(302, $response->getStatusCode());
339345
}
340346

341-
#[BackupStaticProperties(true)]
347+
#[RunInSeparateProcess]
348+
#[PreserveGlobalState(false)]
342349
public function testAuthHeaderPartial(): void
343350
{
344351
$config = Config::getInstance();
@@ -381,7 +388,8 @@ public function testAuthCheckCaptcha(): void
381388
);
382389
}
383390

384-
#[BackupStaticProperties(true)]
391+
#[RunInSeparateProcess]
392+
#[PreserveGlobalState(false)]
385393
public function testLogoutDelete(): void
386394
{
387395
$responseStub = new ResponseRendererStub();
@@ -409,7 +417,8 @@ public function testLogoutDelete(): void
409417
$this->assertArrayNotHasKey('pmaAuth-0', $_COOKIE);
410418
}
411419

412-
#[BackupStaticProperties(true)]
420+
#[RunInSeparateProcess]
421+
#[PreserveGlobalState(false)]
413422
public function testLogout(): void
414423
{
415424
$responseStub = new ResponseRendererStub();
@@ -666,7 +675,8 @@ public function testAuthSetUserWithHeaders(): void
666675
$this->object->rememberCredentials();
667676
}
668677

669-
#[BackupStaticProperties(true)]
678+
#[RunInSeparateProcess]
679+
#[PreserveGlobalState(false)]
670680
public function testAuthFailsNoPass(): void
671681
{
672682
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -741,7 +751,8 @@ public function testAuthFailsTooLongPass(string $password, bool $trueFalse, stri
741751
$this->assertEquals($GLOBALS['conn_error'], $connError);
742752
}
743753

744-
#[BackupStaticProperties(true)]
754+
#[RunInSeparateProcess]
755+
#[PreserveGlobalState(false)]
745756
public function testAuthFailsDeny(): void
746757
{
747758
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -773,7 +784,8 @@ public function testAuthFailsDeny(): void
773784
$this->assertEquals($GLOBALS['conn_error'], 'Access denied!');
774785
}
775786

776-
#[BackupStaticProperties(true)]
787+
#[RunInSeparateProcess]
788+
#[PreserveGlobalState(false)]
777789
public function testAuthFailsActivity(): void
778790
{
779791
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -812,7 +824,8 @@ public function testAuthFailsActivity(): void
812824
);
813825
}
814826

815-
#[BackupStaticProperties(true)]
827+
#[RunInSeparateProcess]
828+
#[PreserveGlobalState(false)]
816829
public function testAuthFailsDBI(): void
817830
{
818831
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -855,7 +868,8 @@ public function testAuthFailsDBI(): void
855868
$this->assertEquals($GLOBALS['conn_error'], '#42 Cannot log in to the MySQL server');
856869
}
857870

858-
#[BackupStaticProperties(true)]
871+
#[RunInSeparateProcess]
872+
#[PreserveGlobalState(false)]
859873
public function testAuthFailsErrno(): void
860874
{
861875
$this->object = $this->getMockBuilder(AuthenticationCookie::class)
@@ -1022,7 +1036,8 @@ public function testAuthenticate(): void
10221036
* @param mixed[] $rules rules
10231037
* @param string $expected expected result
10241038
*/
1025-
#[BackupStaticProperties(true)]
1039+
#[RunInSeparateProcess]
1040+
#[PreserveGlobalState(false)]
10261041
#[DataProvider('checkRulesProvider')]
10271042
public function testCheckRules(
10281043
string $user,

test/classes/Plugins/Auth/AuthenticationHttpTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
use PhpMyAdmin\ResponseRenderer;
1212
use PhpMyAdmin\Tests\AbstractTestCase;
1313
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
14-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
1514
use PHPUnit\Framework\Attributes\CoversClass;
1615
use PHPUnit\Framework\Attributes\DataProvider;
1716
use PHPUnit\Framework\Attributes\Group;
1817
use PHPUnit\Framework\Attributes\Medium;
18+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
1919
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2020
use ReflectionProperty;
2121
use Throwable;
@@ -63,7 +63,8 @@ protected function tearDown(): void
6363
unset($this->object);
6464
}
6565

66-
#[BackupStaticProperties(true)]
66+
#[RunInSeparateProcess]
67+
#[PreserveGlobalState(false)]
6768
public function testAuthLogoutUrl(): void
6869
{
6970
$config = Config::getInstance();
@@ -80,7 +81,8 @@ public function testAuthLogoutUrl(): void
8081
$this->assertSame(302, $response->getStatusCode());
8182
}
8283

83-
#[BackupStaticProperties(true)]
84+
#[RunInSeparateProcess]
85+
#[PreserveGlobalState(false)]
8486
public function testAuthVerbose(): void
8587
{
8688
$config = Config::getInstance();
@@ -101,7 +103,8 @@ public function testAuthVerbose(): void
101103
$this->assertSame(401, $response->getStatusCode());
102104
}
103105

104-
#[BackupStaticProperties(true)]
106+
#[RunInSeparateProcess]
107+
#[PreserveGlobalState(false)]
105108
public function testAuthHost(): void
106109
{
107110
$config = Config::getInstance();
@@ -123,7 +126,8 @@ public function testAuthHost(): void
123126
$this->assertSame(401, $response->getStatusCode());
124127
}
125128

126-
#[BackupStaticProperties(true)]
129+
#[RunInSeparateProcess]
130+
#[PreserveGlobalState(false)]
127131
public function testAuthRealm(): void
128132
{
129133
$config = Config::getInstance();
@@ -278,6 +282,7 @@ public function testAuthSetUser(): void
278282

279283
#[Group('medium')]
280284
#[RunInSeparateProcess]
285+
#[PreserveGlobalState(false)]
281286
public function testAuthFails(): void
282287
{
283288
$config = Config::getInstance();

test/classes/Plugins/Auth/AuthenticationSignonTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
use PhpMyAdmin\ResponseRenderer;
1313
use PhpMyAdmin\Tests\AbstractTestCase;
1414
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
15-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
1615
use PHPUnit\Framework\Attributes\CoversClass;
16+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
17+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1718
use ReflectionProperty;
1819
use Throwable;
1920

@@ -58,7 +59,8 @@ protected function tearDown(): void
5859
unset($this->object);
5960
}
6061

61-
#[BackupStaticProperties(true)]
62+
#[RunInSeparateProcess]
63+
#[PreserveGlobalState(false)]
6264
public function testAuth(): void
6365
{
6466
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
@@ -81,7 +83,8 @@ public function testAuth(): void
8183
$this->assertStringContainsString('You must set SignonURL!', $result);
8284
}
8385

84-
#[BackupStaticProperties(true)]
86+
#[RunInSeparateProcess]
87+
#[PreserveGlobalState(false)]
8588
public function testAuthLogoutURL(): void
8689
{
8790
$responseStub = new ResponseRendererStub();
@@ -98,7 +101,8 @@ public function testAuthLogoutURL(): void
98101
$this->assertSame(302, $response->getStatusCode());
99102
}
100103

101-
#[BackupStaticProperties(true)]
104+
#[RunInSeparateProcess]
105+
#[PreserveGlobalState(false)]
102106
public function testAuthLogout(): void
103107
{
104108
$responseStub = new ResponseRendererStub();
@@ -149,7 +153,8 @@ public function testAuthCheckSession(): void
149153
$this->assertEquals('https://example.com/SignonURL', $_SESSION['LAST_SIGNON_URL']);
150154
}
151155

152-
#[BackupStaticProperties(true)]
156+
#[RunInSeparateProcess]
157+
#[PreserveGlobalState(false)]
153158
public function testAuthCheckToken(): void
154159
{
155160
$_SESSION = [' PMA_token ' => 'eefefef'];

test/classes/Setup/FormProcessingTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
use PhpMyAdmin\Setup\FormProcessing;
1313
use PhpMyAdmin\Tests\AbstractTestCase;
1414
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
15-
use PHPUnit\Framework\Attributes\BackupStaticProperties;
1615
use PHPUnit\Framework\Attributes\CoversClass;
16+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
17+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1718
use ReflectionProperty;
1819
use Throwable;
1920

@@ -38,7 +39,8 @@ protected function setUp(): void
3839
Config::getInstance()->settings['ServerDefault'] = 1;
3940
}
4041

41-
#[BackupStaticProperties(true)]
42+
#[RunInSeparateProcess]
43+
#[PreserveGlobalState(false)]
4244
public function testProcessFormSet(): void
4345
{
4446
DatabaseInterface::$instance = $this->createDatabaseInterface();

0 commit comments

Comments
 (0)