Skip to content

Commit 2206005

Browse files
committed
Fix phpunit errors
1 parent 7001e7f commit 2206005

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

tests/system/Autoloader/AutoloaderTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ final class AutoloaderTest extends CIUnitTestCase
4343
*/
4444
private Closure $classLoader;
4545

46+
public static function setUpBeforeClass(): void
47+
{
48+
parent::setUpBeforeClass();
49+
50+
set_error_handler(null);
51+
}
52+
53+
public static function tearDownAfterClass(): void
54+
{
55+
parent::tearDownAfterClass();
56+
57+
restore_error_handler();
58+
}
59+
4660
protected function setUp(): void
4761
{
4862
parent::setUp();
@@ -396,10 +410,6 @@ public function testAutoloaderLoadsNonClassFiles(): void
396410
#[RunInSeparateProcess]
397411
public function testLoadHelpers(): void
398412
{
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-
403413
$config = new Autoload();
404414
$config->helpers[] = 'form';
405415

tests/system/CodeIgniterTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,25 @@ final class CodeIgniterTest extends CIUnitTestCase
4848
private CodeIgniter $codeigniter;
4949
protected $routes;
5050

51+
public static function setUpBeforeClass(): void
52+
{
53+
parent::setUpBeforeClass();
54+
55+
set_error_handler(null);
56+
}
57+
58+
public static function tearDownAfterClass(): void
59+
{
60+
parent::tearDownAfterClass();
61+
62+
restore_error_handler();
63+
}
64+
5165
protected function setUp(): void
5266
{
5367
parent::setUp();
5468
$this->resetServices();
5569

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-
6070
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
6171

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

tests/system/Helpers/URLHelper/MiscUrlTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ final class MiscUrlTest extends CIUnitTestCase
3838
{
3939
private App $config;
4040

41+
public static function setUpBeforeClass(): void
42+
{
43+
parent::setUpBeforeClass();
44+
45+
set_error_handler(null);
46+
}
47+
48+
public static function tearDownAfterClass(): void
49+
{
50+
parent::tearDownAfterClass();
51+
52+
restore_error_handler();
53+
}
54+
4155
protected function setUp(): void
4256
{
4357
parent::setUp();
@@ -63,10 +77,6 @@ protected function tearDown(): void
6377
#[RunInSeparateProcess]
6478
public function testPreviousURLUsesSessionFirst(): void
6579
{
66-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
67-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
68-
restore_error_handler();
69-
7080
$uri1 = 'http://example.com/one?two';
7181
$uri2 = 'http://example.com/two?foo';
7282

@@ -98,10 +108,6 @@ private function createRequest(string $uri): void
98108
#[RunInSeparateProcess]
99109
public function testPreviousURLUsesRefererIfNeeded(): void
100110
{
101-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
102-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
103-
restore_error_handler();
104-
105111
$uri1 = 'http://example.com/one?two';
106112

107113
$_SERVER['HTTP_REFERER'] = $uri1;

tests/system/View/ParserPluginTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ final class ParserPluginTest extends CIUnitTestCase
2929
private Parser $parser;
3030
private Validation $validator;
3131

32+
public static function setUpBeforeClass(): void
33+
{
34+
parent::setUpBeforeClass();
35+
36+
set_error_handler(null);
37+
}
38+
39+
public static function tearDownAfterClass(): void
40+
{
41+
parent::tearDownAfterClass();
42+
43+
restore_error_handler();
44+
}
45+
3246
protected function setUp(): void
3347
{
3448
parent::setUp();
@@ -51,10 +65,6 @@ public function testCurrentURL(): void
5165
#[RunInSeparateProcess]
5266
public function testPreviousURL(): void
5367
{
54-
// Workaround for errors on PHPUnit 10 and PHP 8.3.
55-
// See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619
56-
restore_error_handler();
57-
5868
$template = '{+ previous_url +}';
5969

6070
// Ensure a previous URL exists to work with.

0 commit comments

Comments
 (0)