Skip to content

Commit a47bf1d

Browse files
hahuja2mfulb
authored andcommitted
chore(tests): add integration tests
1 parent 785e83c commit a47bf1d

6 files changed

+200
-9
lines changed

tests/integration/attributes/test_transaction_additional_params.php renamed to tests/integration/api/notice_error/test_transaction_additional_params.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
"timestamp": "??",
2424
"error.class": "NoticedError",
2525
"error.message": "Test Error Has Occurred!",
26-
"error.file": "random.php",
27-
"error.line": 46,
28-
"error.context": "Random Error Has Been Detected",
29-
"error.no": 256,
3026
"transactionName": "??",
3127
"duration": "??",
3228
"nr.transactionGuid": "??",
@@ -36,11 +32,17 @@
3632
"traceId": "??",
3733
"spanId": "??"
3834
},
39-
{},
35+
{
36+
"user.error.message": "Test Error Has Occurred!",
37+
"user.error.file": "Random.php",
38+
"user.error.line": 100,
39+
"user.error.context": "Random Error Has Been Detected",
40+
"user.error.number": 256
41+
},
4042
{}
4143
]
4244
]
4345
]
4446
*/
4547

46-
newrelic_notice_error(256, "Test Error Has Occurred!", "random.php", 46, "Random Error Has Been Detected");
48+
newrelic_notice_error(256, "Test Error Has Occurred!", "Random.php", 100, "Random Error Has Been Detected");

tests/integration/attributes/test_transaction_additional_params2.php renamed to tests/integration/api/notice_error/test_transaction_additional_params2.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*/
66

77
/*DESCRIPTION
8-
Test the use case where two parameters are passed into newrelic_notice_error
9-
and the exception is shown as the error message.
8+
Test the use case where two parameters are passed into newrelic_notice_error.
109
*/
1110

1211
/*EXPECT_ERROR_EVENTS
@@ -32,7 +31,9 @@
3231
"traceId": "??",
3332
"spanId": "??"
3433
},
35-
{},
34+
{
35+
"user.error.message": "Noticed exception 'Exception' with message 'Sample Exception' in __FILE__:??"
36+
},
3637
{}
3738
]
3839
]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Ensure that all user attributes show up correctly when both
9+
newrelic_set_user_attributes and newrelic_notice_error are called.
10+
*/
11+
12+
/*EXPECT_ERROR_EVENTS
13+
[
14+
"?? agent run id",
15+
{
16+
"reservoir_size": 100,
17+
"events_seen": 1
18+
},
19+
[
20+
[
21+
{
22+
"type": "TransactionError",
23+
"timestamp": "??",
24+
"error.class": "NoticedError",
25+
"error.message": "Test Error Has Occurred!",
26+
"transactionName": "??",
27+
"duration": "??",
28+
"nr.transactionGuid": "??",
29+
"guid": "??",
30+
"sampled": "??",
31+
"priority": "??",
32+
"traceId": "??",
33+
"spanId": "??"
34+
},
35+
{
36+
"product": "my_product",
37+
"account": "my_account",
38+
"user": "my_user",
39+
"user.error.message": "Test Error Has Occurred!",
40+
"user.error.file": "Random.php",
41+
"user.error.line": 100,
42+
"user.error.context": "Random Error Has Been Detected",
43+
"user.error.number": 256
44+
},
45+
{}
46+
]
47+
]
48+
]
49+
*/
50+
51+
newrelic_set_user_attributes("my_user", "my_account", "my_product");
52+
newrelic_notice_error(256, "Test Error Has Occurred!", "Random.php", 100, "Random Error Has Been Detected");
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Ensure null values are handled correctly when passed into newrelic_notice_error.
9+
*/
10+
11+
/*EXPECT_ERROR_EVENTS
12+
[
13+
"?? agent run id",
14+
{
15+
"reservoir_size": 100,
16+
"events_seen": 1
17+
},
18+
[
19+
[
20+
{
21+
"type": "TransactionError",
22+
"timestamp": "??",
23+
"error.class": "NoticedError",
24+
"error.message": "Test Error Has Occurred!",
25+
"transactionName": "??",
26+
"duration": "??",
27+
"nr.transactionGuid": "??",
28+
"guid": "??",
29+
"sampled": "??",
30+
"priority": "??",
31+
"traceId": "??",
32+
"spanId": "??"
33+
},
34+
{
35+
"user.error.message": "Test Error Has Occurred!",
36+
"user.error.line": 100,
37+
"user.error.number": 256
38+
},
39+
{}
40+
]
41+
]
42+
]
43+
*/
44+
45+
newrelic_notice_error(256, "Test Error Has Occurred!", null, 100, null);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Ensure null values are handled correctly when passed into newrelic_notice_error.
9+
*/
10+
11+
/*EXPECT_ERROR_EVENTS
12+
[
13+
"?? agent run id",
14+
{
15+
"reservoir_size": 100,
16+
"events_seen": 1
17+
},
18+
[
19+
[
20+
{
21+
"type": "TransactionError",
22+
"timestamp": "??",
23+
"error.class": "NoticedError",
24+
"error.message": "Test Error Has Occurred!",
25+
"transactionName": "??",
26+
"duration": "??",
27+
"nr.transactionGuid": "??",
28+
"guid": "??",
29+
"sampled": "??",
30+
"priority": "??",
31+
"traceId": "??",
32+
"spanId": "??"
33+
},
34+
{
35+
"user.error.message": "Test Error Has Occurred!",
36+
"user.error.file": "Random.php",
37+
"user.error.line": 100,
38+
"user.error.number": 256
39+
},
40+
{}
41+
]
42+
]
43+
]
44+
*/
45+
46+
newrelic_notice_error(256, "Test Error Has Occurred!", "Random.php", 100, null);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Ensure null values are handled correctly when passed into newrelic_notice_error.
9+
*/
10+
11+
/*EXPECT_ERROR_EVENTS
12+
[
13+
"?? agent run id",
14+
{
15+
"reservoir_size": 100,
16+
"events_seen": 1
17+
},
18+
[
19+
[
20+
{
21+
"type": "TransactionError",
22+
"timestamp": "??",
23+
"error.class": "NoticedError",
24+
"transactionName": "??",
25+
"duration": "??",
26+
"nr.transactionGuid": "??",
27+
"guid": "??",
28+
"sampled": "??",
29+
"priority": "??",
30+
"traceId": "??",
31+
"spanId": "??"
32+
},
33+
{
34+
"user.error.file": "Random.php",
35+
"user.error.context": "Random Error Has Been Detected",
36+
"user.error.line": 100,
37+
"user.error.number": 256
38+
},
39+
{}
40+
]
41+
]
42+
]
43+
*/
44+
45+
newrelic_notice_error(256, null, "Random.php", 100, "Random Error Has Been Detected");

0 commit comments

Comments
 (0)