Skip to content

Commit 374fe1a

Browse files
committed
fix(integration): no longer use E_USER_ERROR
1 parent 815b431 commit 374fe1a

24 files changed

+852
-47
lines changed

tests/integration/api/error_group_callback/test_error_group_callback_error_web.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
Tests newrelic_set_error_group_callback() API for Web errors.
99
*/
1010

11+
/*SKIPIF
12+
<?php
13+
if (version_compare(PHP_VERSION, "8.4", ">=")) {
14+
die("skip: newer test for PHPs 8.4+\n");
15+
}
16+
*/
17+
18+
1119
/*ENVIRONMENT
1220
REQUEST_METHOD=GET
1321
QUERY_STRING=foo=1&bar=2
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Tests newrelic_set_error_group_callback() API for Web errors.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
if (version_compare(PHP_VERSION, "8.4", "<")) {
14+
die("skip: older test for PHPs < 8.4\n");
15+
}
16+
*/
17+
18+
/*ENVIRONMENT
19+
REQUEST_METHOD=GET
20+
QUERY_STRING=foo=1&bar=2
21+
*/
22+
23+
/*EXPECT_REGEX
24+
ok - callback registered
25+
request_uri => \/test_error_group_callback_error_web.php84.php\?foo=1&bar=2
26+
path => .*test_error_group_callback_error_web.php84.php
27+
method => GET
28+
status_code => 200
29+
30+
klass => E_USER_WARNING
31+
message => I'M COVERED IN BEES
32+
file => .*test_error_group_callback_error_web.php84.php
33+
stack => \[" in trigger_error called at .*test_error_group_callback_error_web.php84.php \(.*\)"," in alpha called at .*test_error_group_callback_error_web.php84.php \(.*\)"\]
34+
*/
35+
36+
/*EXPECT_METRICS
37+
[
38+
"?? agent run id",
39+
"?? timeframe start",
40+
"?? timeframe stop",
41+
[
42+
[{"name":"Apdex"}, [0, "??", "??", "??", "??", "??"]],
43+
[{"name":"Apdex/Uri__FILE__"}, [0, "??", "??", "??", "??", "??"]],
44+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]],
45+
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allWeb"}, [1, "??", "??", "??", "??", "??"]],
46+
[{"name":"Errors/WebTransaction/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]],
47+
[{"name":"Errors/all"}, [1, "??", "??", "??", "??", "??"]],
48+
[{"name":"Errors/allWeb"}, [1, "??", "??", "??", "??", "??"]],
49+
[{"name":"ErrorsByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]],
50+
[{"name":"ErrorsByCaller/Unknown/Unknown/Unknown/Unknown/allWeb"}, [1, "??", "??", "??", "??", "??"]],
51+
[{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]],
52+
[{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
53+
[{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
54+
[{"name":"Supportability/api/set_error_group_callback"}, [1, 0, 0, 0, 0, 0]],
55+
[{"name":"WebTransaction"}, [1, "??", "??", "??", "??", "??"]],
56+
[{"name":"WebTransaction/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]],
57+
[{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
58+
[{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]],
59+
[{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]]
60+
]
61+
]
62+
*/
63+
64+
65+
/*EXPECT_ERROR_EVENTS
66+
[
67+
"?? agent run id",
68+
{
69+
"reservoir_size": 100,
70+
"events_seen": 1
71+
},
72+
[
73+
[
74+
{
75+
"type": "TransactionError",
76+
"timestamp": "??",
77+
"error.class": "E_USER_WARNING",
78+
"error.message": "I'M COVERED IN BEES",
79+
"transactionName": "WebTransaction\/Uri__FILE__",
80+
"duration": "??",
81+
"nr.transactionGuid": "??",
82+
"guid": "??",
83+
"sampled": true,
84+
"priority": "??",
85+
"traceId": "??",
86+
"spanId": "??"
87+
},
88+
{},
89+
{
90+
"response.headers.contentType": "application\/json",
91+
"http.statusCode": 200,
92+
"response.statusCode": 200,
93+
"httpResponseCode": "200",
94+
"request.uri": "__FILE__",
95+
"error.group.name": "CUSTOM ERROR GROUP NAME",
96+
"SERVER_NAME": "127.0.0.1",
97+
"request.method": "GET",
98+
"request.headers.host": "127.0.0.1"
99+
}
100+
]
101+
]
102+
]
103+
*/
104+
105+
/*EXPECT_TRACED_ERRORS
106+
[
107+
"?? agent run id",
108+
[
109+
[
110+
"??",
111+
"WebTransaction\/Uri__FILE__",
112+
"I'M COVERED IN BEES",
113+
"E_USER_WARNING",
114+
{
115+
"stack_trace": [
116+
" in trigger_error called at __FILE__ (??)",
117+
" in alpha called at __FILE__ (??)"
118+
],
119+
"agentAttributes": {
120+
"response.headers.contentType": "application\/json",
121+
"http.statusCode": 200,
122+
"response.statusCode": 200,
123+
"httpResponseCode": "200",
124+
"request.uri": "__FILE__",
125+
"error.group.name": "CUSTOM ERROR GROUP NAME",
126+
"SERVER_NAME": "127.0.0.1",
127+
"request.method": "GET",
128+
"request.headers.host": "127.0.0.1"
129+
},
130+
"intrinsics": {
131+
"totalTime": "??",
132+
"cpu_time": "??",
133+
"cpu_user_time": "??",
134+
"cpu_sys_time": "??",
135+
"guid": "??",
136+
"sampled": true,
137+
"priority": "??",
138+
"traceId": "??"
139+
},
140+
"request_uri": "__FILE__"
141+
},
142+
"?? transaction ID"
143+
]
144+
]
145+
]
146+
*/
147+
148+
require_once(realpath(dirname(__FILE__)) . '/../../../include/tap.php');
149+
150+
header('Content-Type: text/html');
151+
header('Content-Type: application/json');
152+
153+
function alpha()
154+
{
155+
trigger_error("I'M COVERED IN BEES", E_USER_WARNING);
156+
}
157+
158+
$callback = function($txndata, $errdata)
159+
{
160+
foreach($txndata as $tkey => $tdata) {
161+
echo "$tkey => $tdata\n";
162+
};
163+
164+
echo "\n";
165+
166+
foreach($errdata as $ekey => $edata) {
167+
echo "$ekey => $edata\n";
168+
};
169+
170+
$fingerprint = "CUSTOM ERROR GROUP NAME";
171+
return $fingerprint;
172+
};
173+
174+
$result = newrelic_set_error_group_callback($callback);
175+
176+
tap_assert($result, "callback registered");
177+
178+
alpha();

tests/integration/api/notice_error/test_good_4_args_error_handler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@
142142
*/
143143

144144
function a() {
145-
trigger_error("4 arg error", E_USER_ERROR);
145+
trigger_error("4 arg error", E_USER_WARNING);
146146
}
147147

148-
set_error_handler('newrelic_notice_error', E_USER_ERROR);
148+
set_error_handler('newrelic_notice_error', E_USER_WARNING);
149149
a();

tests/integration/api/notice_error/test_good_5_args_error_handler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@
142142
*/
143143

144144
function a() {
145-
trigger_error("5 arg error", E_USER_ERROR);
145+
trigger_error("5 arg error", E_USER_WARNING);
146146
}
147147

148-
set_error_handler('newrelic_notice_error', E_USER_ERROR);
148+
set_error_handler('newrelic_notice_error', E_USER_WARNING);
149149
a();

tests/integration/api/notice_error/test_prioritize_api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function gamma($password)
8484

8585
function omega()
8686
{
87-
trigger_error("ignore me", E_USER_ERROR);
87+
trigger_error("ignore me", E_USER_WARNING);
8888
}
8989

9090
gamma('my super secret password that New Relic cannot know');

tests/integration/api/notice_error/test_priority.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"?? when",
1717
"OtherTransaction/php__FILE__",
1818
"highest priority",
19-
"E_USER_ERROR",
19+
"E_USER_WARNING",
2020
{
2121
"stack_trace": [
2222
" in trigger_error called at __FILE__ (??)"
@@ -42,7 +42,7 @@
4242
{
4343
"type": "TransactionError",
4444
"timestamp": "??",
45-
"error.class": "E_USER_ERROR",
45+
"error.class": "E_USER_WARNING",
4646
"error.message": "highest priority",
4747
"transactionName": "OtherTransaction\/php__FILE__",
4848
"duration": "??",
@@ -60,9 +60,7 @@
6060
]
6161
*/
6262

63-
/*
64-
* Cause three errors to be noticed in order of decreasing priority.
65-
*/
66-
trigger_error ("highest priority", E_USER_ERROR);
67-
trigger_error ("goldilox", E_USER_WARNING);
6863
trigger_error ("lowest priority", E_USER_NOTICE);
64+
trigger_error ("goldilox", E_USER_DEPRECATED);
65+
trigger_error ("highest priority", E_USER_WARNING);
66+
trigger_error ("goldilox", E_USER_DEPRECATED);

tests/integration/api/set_user_id/test_set_user_id_error.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"??",
4545
"OtherTransaction\/php__FILE__",
4646
"I'M COVERED IN BEES",
47-
"E_USER_ERROR",
47+
"E_USER_WARNING",
4848
{
4949
"stack_trace": [
5050
" in trigger_error called at __FILE__ (??)",
@@ -82,7 +82,7 @@
8282
{
8383
"type": "TransactionError",
8484
"timestamp": "??",
85-
"error.class": "E_USER_ERROR",
85+
"error.class": "E_USER_WARNING",
8686
"error.message": "I'M COVERED IN BEES",
8787
"transactionName": "OtherTransaction\/php__FILE__",
8888
"duration": "??",
@@ -106,7 +106,7 @@
106106

107107
function alpha()
108108
{
109-
trigger_error("I'M COVERED IN BEES", E_USER_ERROR);
109+
trigger_error("I'M COVERED IN BEES", E_USER_WARNING);
110110
};
111111

112112
$uuid = "0123456789abcdefghijlkmnopqrstuvwxyz";

tests/integration/distributed_tracing/newrelic/test_error_intrinsic_error.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
},
3333
{},
3434
{
35-
"errorType": "E_USER_ERROR",
35+
"errorType": "E_USER_WARNING",
3636
"errorMessage": "This is an error"
3737
}
3838
]
3939
]
4040
]
4141
*/
4242

43-
trigger_error("This is an error", E_USER_ERROR);
43+
trigger_error("This is an error", E_USER_WARNING);

tests/integration/errors/test_E_DEPRECATED_2.php81.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
if (version_compare(PHP_VERSION, "8.1", "<")) {
1414
die("skip: PHP < 8.1.0 not supported\n");
1515
}
16+
if (version_compare(PHP_VERSION, "8.4", ">=")) {
17+
die("skip: PHP >= 8.4.0 not supported\n");
18+
}
1619
*/
1720

1821
/*INI
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
The agent should capture and report deprecation warnings.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
if (version_compare(PHP_VERSION, "8.4", "<")) {
14+
die("skip: PHP < 8.4.0 not supported\n");
15+
}
16+
*/
17+
18+
/*INI
19+
error_reporting = E_ALL | E_STRICT
20+
display_errors=1
21+
log_errors=0
22+
*/
23+
24+
/*EXPECT_REGEX
25+
^\s*Deprecated: test\(\): Optional parameter \$a declared before required parameter \$b is implicitly treated as a required parameter in .*? on line [0-9]+\s*$
26+
*/
27+
28+
/*EXPECT_TRACED_ERRORS
29+
[
30+
"?? agent run id",
31+
[
32+
[
33+
"?? when",
34+
"OtherTransaction/php__FILE__",
35+
"test(): Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter",
36+
"E_DEPRECATED",
37+
{
38+
"stack_trace": "??",
39+
"agentAttributes": "??",
40+
"intrinsics": "??"
41+
},
42+
"?? transaction ID"
43+
]
44+
]
45+
]
46+
*/
47+
48+
/*EXPECT_ERROR_EVENTS
49+
[
50+
"?? agent run id",
51+
{
52+
"reservoir_size": "??",
53+
"events_seen": 1
54+
},
55+
[
56+
[
57+
{
58+
"type": "TransactionError",
59+
"timestamp": "??",
60+
"error.class": "E_DEPRECATED",
61+
"error.message": "test(): Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter",
62+
"transactionName": "OtherTransaction\/php__FILE__",
63+
"duration": "??",
64+
"nr.transactionGuid": "??",
65+
"guid": "??",
66+
"sampled": true,
67+
"priority": "??",
68+
"traceId": "??",
69+
"spanId": "??"
70+
},
71+
{},
72+
{}
73+
]
74+
]
75+
]
76+
*/
77+
78+
function test($a = [], $b) {
79+
echo "Deprecated";
80+
}

0 commit comments

Comments
 (0)