11
11
use Kirby \Session \Session ;
12
12
use Kirby \Toolkit \Str ;
13
13
use ReflectionMethod ;
14
+ use Whoops \Handler \PrettyPageHandler ;
14
15
15
16
/**
16
17
* @coversDefaultClass \Kirby\Cms\App
@@ -29,6 +30,7 @@ public function setUp(): void
29
30
30
31
public function tearDown (): void
31
32
{
33
+ App::destroy ();
32
34
Dir::remove (static ::TMP );
33
35
$ _SERVER = $ this ->_SERVER ;
34
36
}
@@ -456,7 +458,6 @@ public function testOptionWithDotNotation()
456
458
457
459
public function testOptionFromPlugin ()
458
460
{
459
- App::destroy ();
460
461
App::plugin ('namespace/plugin ' , [
461
462
'options ' => [
462
463
'key ' => 'A ' ,
@@ -500,8 +501,6 @@ public function testOptionFromPlugin()
500
501
501
502
public function testOptions ()
502
503
{
503
- App::destroy ();
504
-
505
504
$ app = new App ([
506
505
'roots ' => [
507
506
'index ' => '/dev/null '
@@ -520,8 +519,6 @@ public function testOptions()
520
519
521
520
public function testOptionsFromFile ()
522
521
{
523
- App::destroy ();
524
-
525
522
$ app = new App ([
526
523
'roots ' => [
527
524
'index ' => '/dev/null ' ,
@@ -545,8 +542,6 @@ public function testOptionsFromFile()
545
542
546
543
public function testOptionsFromFileWithEnv1 ()
547
544
{
548
- App::destroy ();
549
-
550
545
$ app = new App ([
551
546
'roots ' => [
552
547
'index ' => '/dev/null ' ,
@@ -571,8 +566,6 @@ public function testOptionsFromFileWithEnv1()
571
566
572
567
public function testOptionsFromFileWithEnv2 ()
573
568
{
574
- App::destroy ();
575
-
576
569
$ app = new App ([
577
570
'roots ' => [
578
571
'index ' => '/dev/null ' ,
@@ -597,10 +590,8 @@ public function testOptionsFromFileWithEnv2()
597
590
], $ app ->options ());
598
591
}
599
592
600
- public function testOptionsOnReady ()
593
+ public function testOptionsOnReady (): void
601
594
{
602
- App::destroy ();
603
-
604
595
$ app = new App ([
605
596
'cli ' => false ,
606
597
'roots ' => [
@@ -626,25 +617,31 @@ public function testOptionsOnReady()
626
617
]);
627
618
628
619
$ this ->assertSame ([
629
- 'ready ' => $ ready ,
630
- 'whoops ' => true ,
631
- 'test ' => '/dev/null ' ,
620
+ 'ready ' => $ ready ,
621
+ 'whoops ' => true ,
622
+ 'test ' => '/dev/null ' ,
632
623
'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 '
637
628
], $ app ->options ());
638
629
639
630
$ whoopsMethod = new ReflectionMethod (App::class, 'whoops ' );
640
631
$ whoopsMethod ->setAccessible (true );
641
632
$ whoopsHandler = $ whoopsMethod ->invoke ($ app )->getHandlers ()[0 ];
642
- $ this ->assertInstanceOf (' Whoops\Handler\ PrettyPageHandler' , $ whoopsHandler );
633
+ $ this ->assertInstanceOf (PrettyPageHandler::class , $ whoopsHandler );
643
634
644
635
$ this ->assertSame ('test ' , $ app ->site ()->homePageId ());
645
636
$ this ->assertSame ('another-test ' , $ app ->site ()->errorPageId ());
646
637
647
638
$ 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 ();
648
645
}
649
646
650
647
public function testRolesFromFixtures ()
@@ -730,7 +727,6 @@ public function testSession()
730
727
731
728
public function testInstance ()
732
729
{
733
- App::destroy ();
734
730
$ this ->assertNull (App::instance (null , true ));
735
731
736
732
$ instance1 = new App ();
@@ -951,8 +947,6 @@ public function testUrl($url, $expected)
951
947
952
948
public function testUrlFromEnvWithDetection ()
953
949
{
954
- App::destroy ();
955
-
956
950
$ app = new App ([
957
951
'roots ' => [
958
952
'index ' => '/dev/null ' ,
@@ -971,8 +965,6 @@ public function testUrlFromEnvWithDetection()
971
965
972
966
public function testUrlFromEnvWithOverride ()
973
967
{
974
- App::destroy ();
975
-
976
968
$ app = new App ([
977
969
'roots ' => [
978
970
'index ' => '/dev/null ' ,
0 commit comments