Skip to content

Commit 325319a

Browse files
committed
test: Suppress PHPUnit error handler warnings
1 parent 0718b62 commit 325319a

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

tests/Cms/App/AppTest.php

+17-25
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Kirby\Session\Session;
1212
use Kirby\Toolkit\Str;
1313
use ReflectionMethod;
14+
use Whoops\Handler\PrettyPageHandler;
1415

1516
/**
1617
* @coversDefaultClass \Kirby\Cms\App
@@ -29,6 +30,7 @@ public function setUp(): void
2930

3031
public function tearDown(): void
3132
{
33+
App::destroy();
3234
Dir::remove(static::TMP);
3335
$_SERVER = $this->_SERVER;
3436
}
@@ -456,7 +458,6 @@ public function testOptionWithDotNotation()
456458

457459
public function testOptionFromPlugin()
458460
{
459-
App::destroy();
460461
App::plugin('namespace/plugin', [
461462
'options' => [
462463
'key' => 'A',
@@ -500,8 +501,6 @@ public function testOptionFromPlugin()
500501

501502
public function testOptions()
502503
{
503-
App::destroy();
504-
505504
$app = new App([
506505
'roots' => [
507506
'index' => '/dev/null'
@@ -520,8 +519,6 @@ public function testOptions()
520519

521520
public function testOptionsFromFile()
522521
{
523-
App::destroy();
524-
525522
$app = new App([
526523
'roots' => [
527524
'index' => '/dev/null',
@@ -545,8 +542,6 @@ public function testOptionsFromFile()
545542

546543
public function testOptionsFromFileWithEnv1()
547544
{
548-
App::destroy();
549-
550545
$app = new App([
551546
'roots' => [
552547
'index' => '/dev/null',
@@ -571,8 +566,6 @@ public function testOptionsFromFileWithEnv1()
571566

572567
public function testOptionsFromFileWithEnv2()
573568
{
574-
App::destroy();
575-
576569
$app = new App([
577570
'roots' => [
578571
'index' => '/dev/null',
@@ -597,10 +590,8 @@ public function testOptionsFromFileWithEnv2()
597590
], $app->options());
598591
}
599592

600-
public function testOptionsOnReady()
593+
public function testOptionsOnReady(): void
601594
{
602-
App::destroy();
603-
604595
$app = new App([
605596
'cli' => false,
606597
'roots' => [
@@ -626,25 +617,31 @@ public function testOptionsOnReady()
626617
]);
627618

628619
$this->assertSame([
629-
'ready' => $ready,
630-
'whoops' => true,
631-
'test' => '/dev/null',
620+
'ready' => $ready,
621+
'whoops' => true,
622+
'test' => '/dev/null',
632623
'another.test' => 'foo',
633-
'debug' => true,
634-
'home' => 'test',
635-
'error' => 'another-test',
636-
'slugs' => 'de'
624+
'debug' => true,
625+
'home' => 'test',
626+
'error' => 'another-test',
627+
'slugs' => 'de'
637628
], $app->options());
638629

639630
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
640631
$whoopsMethod->setAccessible(true);
641632
$whoopsHandler = $whoopsMethod->invoke($app)->getHandlers()[0];
642-
$this->assertInstanceOf('Whoops\Handler\PrettyPageHandler', $whoopsHandler);
633+
$this->assertInstanceOf(PrettyPageHandler::class, $whoopsHandler);
643634

644635
$this->assertSame('test', $app->site()->homePageId());
645636
$this->assertSame('another-test', $app->site()->errorPageId());
646637

647638
$this->assertSame('ss', Str::$language['ß']);
639+
640+
// Suppresses PHPUnit warnings:
641+
// Test code or tested code did not remove its own error handlers
642+
// Test code or tested code did not remove its own exception handlers
643+
restore_error_handler();
644+
restore_exception_handler();
648645
}
649646

650647
public function testRolesFromFixtures()
@@ -730,7 +727,6 @@ public function testSession()
730727

731728
public function testInstance()
732729
{
733-
App::destroy();
734730
$this->assertNull(App::instance(null, true));
735731

736732
$instance1 = new App();
@@ -951,8 +947,6 @@ public function testUrl($url, $expected)
951947

952948
public function testUrlFromEnvWithDetection()
953949
{
954-
App::destroy();
955-
956950
$app = new App([
957951
'roots' => [
958952
'index' => '/dev/null',
@@ -971,8 +965,6 @@ public function testUrlFromEnvWithDetection()
971965

972966
public function testUrlFromEnvWithOverride()
973967
{
974-
App::destroy();
975-
976968
$app = new App([
977969
'roots' => [
978970
'index' => '/dev/null',

0 commit comments

Comments
 (0)