Skip to content

Commit 875cb04

Browse files
added php 8.4 to tests
1 parent 4930b58 commit 875cb04

10 files changed

Lines changed: 169 additions & 16 deletions

.github/workflows/test-package.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
guzzle-version: '^7.0'
2424
- php-version: '8.2'
2525
guzzle-version: '^7.0'
26+
- php-version: '8.3'
27+
guzzle-version: '^7.0'
28+
- php-version: '8.4'
29+
guzzle-version: '^7.9'
2630

2731
steps:
2832
- uses: actions/checkout@v2

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"guzzlehttp/guzzle": "^5.0|^6.0|^7.0"
1717
},
1818
"require-dev": {
19-
"guzzlehttp/psr7": "^1.3",
19+
"guzzlehttp/psr7": "^1.3|^2.0",
2020
"mtdowling/burgomaster": "dev-master#72151eddf5f0cf101502b94bf5031f9c53501a04",
2121
"phpunit/phpunit": "^4.8.36|^7.5.15|^9.3.10",
2222
"php-mock/php-mock-phpunit": "^1.1|^2.1",

tests/ConfigurationTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ public function testNotifier()
4646

4747
public function testShouldIgnore()
4848
{
49-
$this->config->setErrorReportingLevel(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
49+
$reportingLevel = E_ALL & ~E_NOTICE & ~E_DEPRECATED;
50+
51+
if (PHP_VERSION_ID < 80400) {
52+
$reportingLevel &= ~E_STRICT;
53+
}
54+
55+
$this->config->setErrorReportingLevel($reportingLevel);
5056

5157
$this->assertTrue($this->config->shouldIgnoreErrorCode(E_NOTICE));
5258
}
@@ -55,7 +61,7 @@ public function testShouldNotIgnore()
5561
{
5662
$this->config->setErrorReportingLevel(E_ALL);
5763

58-
$this->assertfalse($this->config->shouldIgnoreErrorCode(E_NOTICE));
64+
$this->assertFalse($this->config->shouldIgnoreErrorCode(E_NOTICE));
5965
}
6066

6167
public function testRootPath()
@@ -98,15 +104,15 @@ public function testRootPathRegex()
98104
{
99105
$this->assertFalse($this->config->isInProject('/root/dir/app/afile.php'));
100106

101-
$this->config->setProjectRootRegex('/^('.preg_quote('/root/dir/app', '/').'|'.preg_quote('/root/dir/lib', '/').')[\\/]?/i');
107+
$this->config->setProjectRootRegex('/^(' . preg_quote('/root/dir/app', '/') . '|' . preg_quote('/root/dir/lib', '/') . ')[\\/]?/i');
102108

103109
$this->assertTrue($this->config->isInProject('/root/dir/app/afile.php'));
104110
$this->assertTrue($this->config->isInProject('/root/dir/lib/afile.php'));
105111
$this->assertFalse($this->config->isInProject('/root'));
106112
$this->assertFalse($this->config->isInProject('/root/dir/other-directory/afile.php'));
107113
$this->assertFalse($this->config->isInProject('/base/root/dir/app/afile.php'));
108114

109-
$this->config->setProjectRootRegex('/^('.preg_quote('/root/dir/app/', '/').'|'.preg_quote('/root/dir/lib/', '/').')[\\/]?/i');
115+
$this->config->setProjectRootRegex('/^(' . preg_quote('/root/dir/app/', '/') . '|' . preg_quote('/root/dir/lib/', '/') . ')[\\/]?/i');
110116

111117
$this->assertTrue($this->config->isInProject('/root/dir/app/afile.php'));
112118
$this->assertTrue($this->config->isInProject('/root/dir/lib/afile.php'));
@@ -117,7 +123,7 @@ public function testRootPathRegex()
117123

118124
public function testRootPathRegexNull()
119125
{
120-
$this->config->setProjectRootRegex('/^('.preg_quote('/root/dir/app', '/').'|'.preg_quote('/root/dir/lib', '/').')[\\/]?/i');
126+
$this->config->setProjectRootRegex('/^(' . preg_quote('/root/dir/app', '/') . '|' . preg_quote('/root/dir/lib', '/') . ')[\\/]?/i');
121127
$this->config->setProjectRootRegex(null);
122128

123129
$this->assertFalse($this->config->isInProject('/root/dir/app/afile.php'));

tests/ErrorTypesTest.php

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function testGetAllCodes()
6262
{
6363
$codes = ErrorTypes::getAllCodes();
6464

65+
if (PHP_VERSION_ID < 80400)
66+
unset($codes[E_STRICT]);
67+
6568
// If we actually got all of the codes, they should combine to equal E_ALL
6669
$combined = array_reduce($codes, function ($acc, $code) {
6770
return $acc | $code;
@@ -85,7 +88,7 @@ public function testCodeToString($code, $expected)
8588

8689
public function levelsForSeverityProvider()
8790
{
88-
return [
91+
$levels = [
8992
'error' => [
9093
'error',
9194
E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR,
@@ -96,18 +99,24 @@ public function levelsForSeverityProvider()
9699
],
97100
'info' => [
98101
'info',
99-
E_NOTICE | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED,
102+
E_NOTICE | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED,
100103
],
101104
'non existent severity' => [
102105
'non existent severity',
103106
0,
104107
],
105108
];
109+
110+
if (PHP_VERSION_ID < 80400) {
111+
$levels['info'][1] |= E_STRICT;
112+
}
113+
114+
return $levels;
106115
}
107116

108117
public function isFatalProvider()
109118
{
110-
return [
119+
$fatals = [
111120
'E_ERROR' => [E_ERROR, true],
112121
'E_PARSE' => [E_PARSE, true],
113122
'E_CORE_ERROR' => [E_CORE_ERROR, true],
@@ -120,16 +129,21 @@ public function isFatalProvider()
120129
'E_USER_WARNING' => [E_USER_WARNING, false],
121130
'E_NOTICE' => [E_NOTICE, false],
122131
'E_USER_NOTICE' => [E_USER_NOTICE, false],
123-
'E_STRICT' => [E_STRICT, false],
124132
'E_DEPRECATED' => [E_DEPRECATED, false],
125133
'E_USER_DEPRECATED' => [E_USER_DEPRECATED, false],
126134
'invalid code' => ['hello', true],
127135
];
136+
137+
if (PHP_VERSION_ID < 80400) {
138+
$fatals['E_STRICT'] = [E_STRICT, false];
139+
}
140+
141+
return $fatals;
128142
}
129143

130144
public function nameProvider()
131145
{
132-
return [
146+
$names = [
133147
'E_ERROR' => [E_ERROR, 'PHP Fatal Error'],
134148
'E_WARNING' => [E_WARNING, 'PHP Warning'],
135149
'E_PARSE' => [E_PARSE, 'PHP Parse Error'],
@@ -141,17 +155,22 @@ public function nameProvider()
141155
'E_USER_ERROR' => [E_USER_ERROR, 'User Error'],
142156
'E_USER_WARNING' => [E_USER_WARNING, 'User Warning'],
143157
'E_USER_NOTICE' => [E_USER_NOTICE, 'User Notice'],
144-
'E_STRICT' => [E_STRICT, 'PHP Strict'],
145158
'E_RECOVERABLE_ERROR' => [E_RECOVERABLE_ERROR, 'PHP Recoverable Error'],
146159
'E_DEPRECATED' => [E_DEPRECATED, 'PHP Deprecated'],
147160
'E_USER_DEPRECATED' => [E_USER_DEPRECATED, 'User Deprecated'],
148161
'invalid code' => ['hello', 'Unknown'],
149162
];
163+
164+
if (PHP_VERSION_ID < 80400) {
165+
$names['E_STRICT'] = [E_STRICT, 'PHP Strict'];
166+
}
167+
168+
return $names;
150169
}
151170

152171
public function severityProvider()
153172
{
154-
return [
173+
$severities = [
155174
'E_ERROR' => [E_ERROR, 'error'],
156175
'E_PARSE' => [E_PARSE, 'error'],
157176
'E_CORE_ERROR' => [E_CORE_ERROR, 'error'],
@@ -164,16 +183,21 @@ public function severityProvider()
164183
'E_USER_WARNING' => [E_USER_WARNING, 'warning'],
165184
'E_NOTICE' => [E_NOTICE, 'info'],
166185
'E_USER_NOTICE' => [E_USER_NOTICE, 'info'],
167-
'E_STRICT' => [E_STRICT, 'info'],
168186
'E_DEPRECATED' => [E_DEPRECATED, 'info'],
169187
'E_USER_DEPRECATED' => [E_USER_DEPRECATED, 'info'],
170188
'invalid code' => ['hello', 'error'],
171189
];
190+
191+
if (PHP_VERSION_ID < 80400) {
192+
$severities['E_STRICT'] = [E_STRICT, 'info'];
193+
}
194+
195+
return $severities;
172196
}
173197

174198
public function codeToStringProvider()
175199
{
176-
return [
200+
$strings = [
177201
'E_ERROR' => [E_ERROR, 'E_ERROR'],
178202
'E_PARSE' => [E_PARSE, 'E_PARSE'],
179203
'E_CORE_ERROR' => [E_CORE_ERROR, 'E_CORE_ERROR'],
@@ -186,10 +210,15 @@ public function codeToStringProvider()
186210
'E_USER_WARNING' => [E_USER_WARNING, 'E_USER_WARNING'],
187211
'E_NOTICE' => [E_NOTICE, 'E_NOTICE'],
188212
'E_USER_NOTICE' => [E_USER_NOTICE, 'E_USER_NOTICE'],
189-
'E_STRICT' => [E_STRICT, 'E_STRICT'],
190213
'E_DEPRECATED' => [E_DEPRECATED, 'E_DEPRECATED'],
191214
'E_USER_DEPRECATED' => [E_USER_DEPRECATED, 'E_USER_DEPRECATED'],
192215
'invalid code' => ['hello', 'Unknown'],
193216
];
217+
218+
if (PHP_VERSION_ID < 80400) {
219+
$strings['E_STRICT'] = [E_STRICT, 'E_STRICT'];
220+
}
221+
222+
return $strings;
194223
}
195224
}

tests/phpt/handler_should_report_user_errors.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ trigger_error('abc', E_USER_ERROR);
1212

1313
var_dump('I should not be reached');
1414
?>
15+
--SKIPIF--
16+
<?php
17+
if (PHP_VERSION_ID >= 80400) {
18+
echo 'SKIP — this test uses methods depreciated in PHP 8.4+';
19+
}
20+
?>
1521
--EXPECTF--
1622
Fatal error: abc in %s on line 6
1723
Guzzle request made (1 event)!
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bugsnag\Handler should report parse errors
3+
--FILE--
4+
<?php
5+
$client = require __DIR__ . '/../_prelude.php';
6+
7+
Bugsnag\Handler::register($client);
8+
9+
include __DIR__ . '/../fixtures/parse_error.php';
10+
11+
var_dump('I should not be reached');
12+
?>
13+
--SKIPIF--
14+
<?php
15+
if (PHP_VERSION_ID < 80400) {
16+
echo 'SKIP — this test has different output on PHP <8.4';
17+
}
18+
--EXPECTF--
19+
Parse error: syntax error, unexpected token "{" in %s/parse_error.php on line 3
20+
Guzzle request made (1 event)!
21+
* Method: 'POST'
22+
* URI: 'http://localhost/notify'
23+
* Events:
24+
- syntax error, unexpected token "{"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Bugsnag\Handler should report parse errors with a previous handler
3+
--FILE--
4+
<?php
5+
$client = require __DIR__ . '/../_prelude.php';
6+
7+
set_exception_handler(function ($throwable) {
8+
var_dump($throwable);
9+
throw $throwable;
10+
});
11+
12+
Bugsnag\Handler::register($client);
13+
14+
include __DIR__ . '/../fixtures/parse_error.php';
15+
16+
var_dump('I should not be reached');
17+
?>
18+
--SKIPIF--
19+
<?php
20+
if (PHP_VERSION_ID < 80400) {
21+
echo 'SKIP — this test has different output on PHP <8.4';
22+
}
23+
?>
24+
--EXPECTF--
25+
object(ParseError)#%d (7) {
26+
["message":protected]=>
27+
string(34) "syntax error, unexpected token "{""
28+
["string":"Error":private]=>
29+
string(0) ""
30+
["code":protected]=>
31+
int(0)
32+
["file":protected]=>
33+
string(%d) "%s/parse_error.php"
34+
["line":protected]=>
35+
int(3)
36+
["trace":"Error":private]=>
37+
array(0) {
38+
}
39+
["previous":"Error":private]=>
40+
NULL
41+
}
42+
43+
Parse error: syntax error, unexpected token "{" in %s/parse_error.php on line 3
44+
Guzzle request made (1 event)!
45+
* Method: 'POST'
46+
* URI: 'http://localhost/notify'
47+
* Events:
48+
- syntax error, unexpected token "{"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bugsnag\Handler should report user errors
3+
4+
TODO this is currently reported twice! Once in the error handler and once on shutdown
5+
--FILE--
6+
<?php
7+
$client = require __DIR__ . '/../_prelude.php';
8+
9+
Bugsnag\Handler::register($client);
10+
11+
throw new Error('abc');
12+
13+
var_dump('I should not be reached');
14+
?>
15+
--SKIPIF--
16+
<?php
17+
if(PHP_VERSION_ID < 80400) {
18+
echo 'SKIP — this case is already tested in PHP <8.4';
19+
}
20+
?>
21+
--EXPECTF--
22+
Fatal error: Uncaught Error: abc in %s:6
23+
Stack trace:
24+
#0 {main}
25+
thrown in %s on line 6
26+
Guzzle request made (1 event)!
27+
* Method: 'POST'
28+
* URI: 'http://localhost/notify'
29+
* Events:
30+
- abc

tests/phpt/php8/handler_should_report_parse_errors.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ var_dump('I should not be reached');
1515
if (PHP_MAJOR_VERSION !== 8) {
1616
echo 'SKIP — this test has different output on PHP 5 & 7';
1717
}
18+
if (PHP_VERSION_ID >= 80400) {
19+
echo 'SKIP — this test has different output on PHP 8.4+';
20+
}
1821
?>
1922
--EXPECTF--
2023
Parse error: syntax error, unexpected token "}" in %s/parse_error.php on line 3

tests/phpt/php8/handler_should_report_parse_errors_with_previous_handler.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ var_dump('I should not be reached');
2020
if (PHP_MAJOR_VERSION !== 8) {
2121
echo 'SKIP — this test has different output on PHP 5 & 7';
2222
}
23+
if (PHP_VERSION_ID >= 80400) {
24+
echo 'SKIP — this test has different output on PHP 8.4+';
25+
}
2326
?>
2427
--EXPECTF--
2528
object(ParseError)#%d (7) {

0 commit comments

Comments
 (0)