Skip to content

Commit cba4cce

Browse files
committed
chore(agent): Adds EXPECT_ANALYTICS_EVENT to tests
1 parent 920bd0c commit cba4cce

8 files changed

+282
-0
lines changed

tests/integration/api/notice_error/test_good_1_arg_exception.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,37 @@
8989
]
9090
*/
9191

92+
/*EXPECT_ANALYTICS_EVENTS
93+
[
94+
"?? agent run id",
95+
{
96+
"reservoir_size": "??",
97+
"events_seen": "??"
98+
},
99+
[
100+
[
101+
{
102+
"type": "Transaction",
103+
"name": "OtherTransaction\/php__FILE__",
104+
"timestamp": "??",
105+
"duration": "??",
106+
"totalTime": "??",
107+
"guid": "??",
108+
"sampled": true,
109+
"priority": "??",
110+
"traceId": "??",
111+
"error": true
112+
},
113+
{},
114+
{
115+
"errorType": "Exception",
116+
"errorMessage": "Noticed exception 'Exception' with message '1 arg exception' in __FILE__:??"
117+
}
118+
]
119+
]
120+
]
121+
*/
122+
92123
require_once(realpath(dirname(__FILE__)) . '/../../../include/tap.php');
93124

94125
function a()

tests/integration/api/notice_error/test_good_1_arg_exception_handler.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@
110110
]
111111
*/
112112

113+
/*EXPECT_ANALYTICS_EVENTS
114+
[
115+
"?? agent run id",
116+
{
117+
"reservoir_size": "??",
118+
"events_seen": "??"
119+
},
120+
[
121+
[
122+
{
123+
"type": "Transaction",
124+
"name": "OtherTransaction\/php__FILE__",
125+
"timestamp": "??",
126+
"duration": "??",
127+
"totalTime": "??",
128+
"guid": "??",
129+
"sampled": true,
130+
"priority": "??",
131+
"traceId": "??",
132+
"error": true
133+
},
134+
{},
135+
{
136+
"errorType": "Exception",
137+
"errorMessage": "Noticed exception 'Exception' with message '1 arg exception' in __FILE__:??"
138+
}
139+
]
140+
]
141+
]
142+
*/
143+
113144
function a()
114145
{
115146
throw new Exception("1 arg exception");

tests/integration/api/notice_error/test_good_1_arg_string.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,69 @@
9090
]
9191
*/
9292

93+
94+
/*EXPECT_ANALYTICS_EVENTS
95+
[
96+
"?? agent run id",
97+
{
98+
"reservoir_size": "??",
99+
"events_seen": "??"
100+
},
101+
[
102+
[
103+
{
104+
"type": "Transaction",
105+
"name": "OtherTransaction\/php__FILE__",
106+
"timestamp": "??",
107+
"duration": "??",
108+
"totalTime": "??",
109+
"guid": "??",
110+
"sampled": true,
111+
"priority": "??",
112+
"traceId": "??",
113+
"error": true
114+
},
115+
{},
116+
{
117+
"errorType": "NoticedError",
118+
"errorMessage": "Exception 1 arg string"
119+
}
120+
]
121+
]
122+
]
123+
*/
124+
125+
/*EXPECT_ANALYTICS_EVENTS
126+
[
127+
"?? agent run id",
128+
{
129+
"reservoir_size": "??",
130+
"events_seen": "??"
131+
},
132+
[
133+
[
134+
{
135+
"type": "Transaction",
136+
"name": "OtherTransaction\/php__FILE__",
137+
"timestamp": "??",
138+
"duration": "??",
139+
"totalTime": "??",
140+
"guid": "??",
141+
"sampled": true,
142+
"priority": "??",
143+
"traceId": "??",
144+
"error": true
145+
},
146+
{},
147+
{
148+
"errorType": "NoticedError",
149+
"errorMessage": "Exception 1 arg string"
150+
}
151+
]
152+
]
153+
]
154+
*/
155+
93156
function a()
94157
{
95158
// First arg must be a string or an exception.

tests/integration/api/notice_error/test_good_2_args.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,37 @@
8989
]
9090
*/
9191

92+
/*EXPECT_ANALYTICS_EVENTS
93+
[
94+
"?? agent run id",
95+
{
96+
"reservoir_size": "??",
97+
"events_seen": "??"
98+
},
99+
[
100+
[
101+
{
102+
"type": "Transaction",
103+
"name": "OtherTransaction\/php__FILE__",
104+
"timestamp": "??",
105+
"duration": "??",
106+
"totalTime": "??",
107+
"guid": "??",
108+
"sampled": true,
109+
"priority": "??",
110+
"traceId": "??",
111+
"error": true
112+
},
113+
{},
114+
{
115+
"errorType": "Exception",
116+
"errorMessage": "Noticed exception 'Exception' with message '2 arg exception' in __FILE__:??"
117+
}
118+
]
119+
]
120+
]
121+
*/
122+
92123
function a()
93124
{
94125
// Args must be string, exception.

tests/integration/api/notice_error/test_good_4_args.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@
9090
]
9191
*/
9292

93+
/*EXPECT_ANALYTICS_EVENTS
94+
[
95+
"?? agent run id",
96+
{
97+
"reservoir_size": "??",
98+
"events_seen": "??"
99+
},
100+
[
101+
[
102+
{
103+
"type": "Transaction",
104+
"name": "OtherTransaction\/php__FILE__",
105+
"timestamp": "??",
106+
"duration": "??",
107+
"totalTime": "??",
108+
"guid": "??",
109+
"sampled": true,
110+
"priority": "??",
111+
"traceId": "??",
112+
"error": true
113+
},
114+
{},
115+
{
116+
"errorType": "NoticedError",
117+
"errorMessage": "4 arg error"
118+
}
119+
]
120+
]
121+
]
122+
*/
123+
124+
93125
function a() {
94126
// Four argument form requires integer, string, string, integer
95127
// This is like the five argument form but for PHP 8+ where the context is not supplied

tests/integration/api/notice_error/test_good_4_args_error_handler.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@
110110
]
111111
*/
112112

113+
/*EXPECT_ANALYTICS_EVENTS
114+
[
115+
"?? agent run id",
116+
{
117+
"reservoir_size": "??",
118+
"events_seen": "??"
119+
},
120+
[
121+
[
122+
{
123+
"type": "Transaction",
124+
"name": "OtherTransaction\/php__FILE__",
125+
"timestamp": "??",
126+
"duration": "??",
127+
"totalTime": "??",
128+
"guid": "??",
129+
"sampled": true,
130+
"priority": "??",
131+
"traceId": "??",
132+
"error": true
133+
},
134+
{},
135+
{
136+
"errorType": "NoticedError",
137+
"errorMessage": "4 arg error"
138+
}
139+
]
140+
]
141+
]
142+
*/
143+
113144
function a() {
114145
trigger_error("4 arg error", E_USER_ERROR);
115146
}

tests/integration/api/notice_error/test_good_5_args.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@
9090
]
9191
*/
9292

93+
94+
/*EXPECT_ANALYTICS_EVENTS
95+
[
96+
"?? agent run id",
97+
{
98+
"reservoir_size": "??",
99+
"events_seen": "??"
100+
},
101+
[
102+
[
103+
{
104+
"type": "Transaction",
105+
"name": "OtherTransaction\/php__FILE__",
106+
"timestamp": "??",
107+
"duration": "??",
108+
"totalTime": "??",
109+
"guid": "??",
110+
"sampled": true,
111+
"priority": "??",
112+
"traceId": "??",
113+
"error": true
114+
},
115+
{},
116+
{
117+
"errorType": "NoticedError",
118+
"errorMessage": "5 arg error"
119+
}
120+
]
121+
]
122+
]
123+
*/
124+
93125
function a() {
94126
// Five argument form requires second arg to be convertible to a string.
95127
newrelic_notice_error(42, "5 arg error", "file", __LINE__, "string");

tests/integration/api/notice_error/test_good_5_args_error_handler.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@
110110
]
111111
*/
112112

113+
/*EXPECT_ANALYTICS_EVENTS
114+
[
115+
"?? agent run id",
116+
{
117+
"reservoir_size": "??",
118+
"events_seen": "??"
119+
},
120+
[
121+
[
122+
{
123+
"type": "Transaction",
124+
"name": "OtherTransaction\/php__FILE__",
125+
"timestamp": "??",
126+
"duration": "??",
127+
"totalTime": "??",
128+
"guid": "??",
129+
"sampled": true,
130+
"priority": "??",
131+
"traceId": "??",
132+
"error": true
133+
},
134+
{},
135+
{
136+
"errorType": "NoticedError",
137+
"errorMessage": "5 arg error"
138+
}
139+
]
140+
]
141+
]
142+
*/
143+
113144
function a() {
114145
trigger_error("5 arg error", E_USER_ERROR);
115146
}

0 commit comments

Comments
 (0)