Skip to content

Commit 102f5b3

Browse files
committed
Fix phpunit errors
1 parent d4e136f commit 102f5b3

25 files changed

+60
-153
lines changed

tests/system/Autoloader/AutoloaderTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use PHPUnit\Framework\Attributes\Group;
2626
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2727
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
28+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2829
use RuntimeException;
2930
use UnnamespacedClass;
3031

@@ -394,12 +395,9 @@ public function testAutoloaderLoadsNonClassFiles(): void
394395

395396
#[PreserveGlobalState(false)]
396397
#[RunInSeparateProcess]
398+
#[WithoutErrorHandler]
397399
public function testLoadHelpers(): void
398400
{
399-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
400-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
401-
restore_error_handler();
402-
403401
$config = new Autoload();
404402
$config->helpers[] = 'form';
405403

tests/system/CodeIgniterTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use PHPUnit\Framework\Attributes\DataProvider;
3535
use PHPUnit\Framework\Attributes\Group;
3636
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
37+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
3738
use Tests\Support\Filters\Customfilter;
3839
use Tests\Support\Filters\RedirectFilter;
3940

@@ -48,15 +49,12 @@ final class CodeIgniterTest extends CIUnitTestCase
4849
private CodeIgniter $codeigniter;
4950
protected $routes;
5051

52+
#[WithoutErrorHandler]
5153
protected function setUp(): void
5254
{
5355
parent::setUp();
5456
$this->resetServices();
5557

56-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
57-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
58-
restore_error_handler();
59-
6058
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
6159

6260
$this->codeigniter = new MockCodeIgniter(new App());

tests/system/Commands/GenerateKeyTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PHPUnit\Framework\Attributes\Group;
2020
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2121
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
22+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2223

2324
/**
2425
* @internal
@@ -31,6 +32,7 @@ final class GenerateKeyTest extends CIUnitTestCase
3132
private string $envPath;
3233
private string $backupEnvPath;
3334

35+
#[WithoutErrorHandler]
3436
protected function setUp(): void
3537
{
3638
parent::setUp();
@@ -43,10 +45,6 @@ protected function setUp(): void
4345
}
4446

4547
$this->resetEnvironment();
46-
47-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
48-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
49-
restore_error_handler();
5048
}
5149

5250
protected function tearDown(): void

tests/system/CommonFunctionsSendTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@
1717
use PHPUnit\Framework\Attributes\Group;
1818
use PHPUnit\Framework\Attributes\PreserveGlobalState;
1919
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
20+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2021

2122
/**
2223
* @internal
2324
*/
2425
#[Group('SeparateProcess')]
2526
final class CommonFunctionsSendTest extends CIUnitTestCase
2627
{
28+
#[WithoutErrorHandler]
2729
protected function setUp(): void
2830
{
2931
parent::setUp();
3032

3133
unset($_ENV['foo'], $_SERVER['foo']);
32-
33-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
34-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
35-
restore_error_handler();
3634
}
3735

3836
/**

tests/system/CommonFunctionsTest.php

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use PHPUnit\Framework\Attributes\Group;
4747
use PHPUnit\Framework\Attributes\PreserveGlobalState;
4848
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
49+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
4950
use RuntimeException;
5051
use stdClass;
5152
use Tests\Support\Models\JobModel;
@@ -274,25 +275,19 @@ public function testEscapeRecursiveArrayRaw(): void
274275

275276
#[PreserveGlobalState(false)]
276277
#[RunInSeparateProcess]
278+
#[WithoutErrorHandler]
277279
public function testSessionInstance(): void
278280
{
279-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
280-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
281-
restore_error_handler();
282-
283281
$this->injectSessionMock();
284282

285283
$this->assertInstanceOf(Session::class, session());
286284
}
287285

288286
#[PreserveGlobalState(false)]
289287
#[RunInSeparateProcess]
288+
#[WithoutErrorHandler]
290289
public function testSessionVariable(): void
291290
{
292-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
293-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
294-
restore_error_handler();
295-
296291
$this->injectSessionMock();
297292

298293
$_SESSION['notbogus'] = 'Hi there';
@@ -302,12 +297,9 @@ public function testSessionVariable(): void
302297

303298
#[PreserveGlobalState(false)]
304299
#[RunInSeparateProcess]
300+
#[WithoutErrorHandler]
305301
public function testSessionVariableNotThere(): void
306302
{
307-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
308-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
309-
restore_error_handler();
310-
311303
$this->injectSessionMock();
312304

313305
$_SESSION['bogus'] = 'Hi there';
@@ -428,12 +420,9 @@ public function testModelExistsAbsoluteClassname(): void
428420

429421
#[PreserveGlobalState(false)]
430422
#[RunInSeparateProcess]
423+
#[WithoutErrorHandler]
431424
public function testOldInput(): void
432425
{
433-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
434-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
435-
restore_error_handler();
436-
437426
$this->injectSessionMock();
438427
// setup from RedirectResponseTest...
439428
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -465,12 +454,9 @@ public function testOldInput(): void
465454

466455
#[PreserveGlobalState(false)]
467456
#[RunInSeparateProcess]
457+
#[WithoutErrorHandler]
468458
public function testOldInputSerializeData(): void
469459
{
470-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
471-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
472-
restore_error_handler();
473-
474460
$this->injectSessionMock();
475461
// setup from RedirectResponseTest...
476462
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -503,12 +489,9 @@ public function testOldInputSerializeData(): void
503489
*/
504490
#[PreserveGlobalState(false)]
505491
#[RunInSeparateProcess]
492+
#[WithoutErrorHandler]
506493
public function testOldInputArray(): void
507494
{
508-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
509-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
510-
restore_error_handler();
511-
512495
$this->injectSessionMock();
513496
// setup from RedirectResponseTest...
514497
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -622,12 +605,9 @@ public function testRedirectResponseCookies1(): void
622605

623606
#[PreserveGlobalState(false)]
624607
#[RunInSeparateProcess]
608+
#[WithoutErrorHandler]
625609
public function testTrace(): void
626610
{
627-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
628-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
629-
restore_error_handler();
630-
631611
ob_start();
632612
trace();
633613
$content = ob_get_clean();
@@ -647,12 +627,9 @@ public function testViewNotSaveData(): void
647627

648628
#[PreserveGlobalState(false)]
649629
#[RunInSeparateProcess]
630+
#[WithoutErrorHandler]
650631
public function testForceHttpsNullRequestAndResponse(): void
651632
{
652-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
653-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
654-
restore_error_handler();
655-
656633
$this->assertNull(Services::response()->header('Location'));
657634

658635
Services::response()->setCookie('force', 'cookie');
@@ -763,12 +740,9 @@ public function testDWithCSP(): void
763740

764741
#[PreserveGlobalState(false)]
765742
#[RunInSeparateProcess]
743+
#[WithoutErrorHandler]
766744
public function testTraceWithCSP(): void
767745
{
768-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
769-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
770-
restore_error_handler();
771-
772746
$this->resetServices();
773747

774748
/** @var App $config */
@@ -780,11 +754,6 @@ public function testTraceWithCSP(): void
780754

781755
Kint::$cli_detection = false;
782756

783-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
784-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
785-
// `$app->initialize()` sets error handler.
786-
restore_error_handler();
787-
788757
$this->expectOutputRegex('/<style class="kint-rich-style" nonce="[0-9a-z]{24}">/u');
789758
trace();
790759
}

tests/system/Config/BaseConfigTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PHPUnit\Framework\Attributes\Group;
2121
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2222
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
23+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2324
use PHPUnit\Framework\MockObject\MockObject;
2425
use RegistrarConfig;
2526
use RuntimeException;
@@ -35,6 +36,7 @@ final class BaseConfigTest extends CIUnitTestCase
3536
{
3637
private string $fixturesFolder;
3738

39+
#[WithoutErrorHandler]
3840
protected function setUp(): void
3941
{
4042
parent::setUp();
@@ -54,10 +56,6 @@ protected function setUp(): void
5456
}
5557

5658
BaseConfig::reset();
57-
58-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
59-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
60-
restore_error_handler();
6159
}
6260

6361
protected function tearDown(): void

tests/system/Config/DotEnvTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\Attributes\Group;
2222
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2323
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
24+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2425
use TypeError;
2526

2627
/**
@@ -34,6 +35,7 @@ final class DotEnvTest extends CIUnitTestCase
3435
private string $path;
3536
private string $fixturesFolder;
3637

38+
#[WithoutErrorHandler]
3739
protected function setUp(): void
3840
{
3941
parent::setUp();
@@ -46,10 +48,6 @@ protected function setUp(): void
4648
$file = 'unreadable.env';
4749
$path = rtrim($this->fixturesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
4850
chmod($path, 0644);
49-
50-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
51-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
52-
restore_error_handler();
5351
}
5452

5553
protected function tearDown(): void

tests/system/Config/ServicesTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
use PHPUnit\Framework\Attributes\Group;
5353
use PHPUnit\Framework\Attributes\PreserveGlobalState;
5454
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
55+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
5556
use RuntimeException;
5657
use Tests\Support\Config\Services;
5758

@@ -63,15 +64,12 @@ final class ServicesTest extends CIUnitTestCase
6364
{
6465
private array $original;
6566

67+
#[WithoutErrorHandler]
6668
protected function setUp(): void
6769
{
6870
parent::setUp();
6971

7072
$this->original = $_SERVER;
71-
72-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
73-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
74-
restore_error_handler();
7573
}
7674

7775
protected function tearDown(): void

tests/system/Events/EventsTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PHPUnit\Framework\Attributes\Group;
2020
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2121
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
22+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2223

2324
/**
2425
* @internal
@@ -31,17 +32,14 @@ final class EventsTest extends CIUnitTestCase
3132
*/
3233
private Events $manager;
3334

35+
#[WithoutErrorHandler]
3436
protected function setUp(): void
3537
{
3638
parent::setUp();
3739

3840
$this->manager = new MockEvents();
3941

4042
Events::removeAllListeners();
41-
42-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
43-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
44-
restore_error_handler();
4543
}
4644

4745
protected function tearDown(): void

tests/system/Filters/HoneypotTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use PHPUnit\Framework\Attributes\Group;
2525
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2626
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
27+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
2728

2829
/**
2930
* @internal
@@ -42,6 +43,7 @@ final class HoneypotTest extends CIUnitTestCase
4243

4344
private ?Response $response = null;
4445

46+
#[WithoutErrorHandler]
4547
protected function setUp(): void
4648
{
4749
parent::setUp();
@@ -51,10 +53,6 @@ protected function setUp(): void
5153
unset($_POST[$this->honey->name]);
5254
$_SERVER['REQUEST_METHOD'] = 'POST';
5355
$_POST[$this->honey->name] = 'hey';
54-
55-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
56-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
57-
restore_error_handler();
5856
}
5957

6058
public function testBeforeTriggered(): void

0 commit comments

Comments
 (0)