forked from newrelic/newrelic-php-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert test_php_execute.c into integration tests
- Loading branch information
Showing
7 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
happy path - pass argument that will not throw exception. | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT | ||
ok - uncaught(1) | ||
*/ | ||
|
||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
// call a function and don't trigger an exception | ||
$retval = uncaught(1); | ||
|
||
tap_equal(1, $retval, 'uncaught(1)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
call a function and trigger an exception | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT_REGEX | ||
^\s*Fatal error: Uncaught.*RuntimeException.*Division by zero.* | ||
*/ | ||
|
||
/*EXPECT_ERROR_EVENTS | ||
[ | ||
"?? agent run id", | ||
{ | ||
"reservoir_size": 100, | ||
"events_seen": 1 | ||
}, | ||
[ | ||
"?? error event" | ||
] | ||
]*/ | ||
|
||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
// call a function and don't trigger an exception | ||
$retval = uncaught(1); | ||
|
||
// call a function and trigger an exception | ||
$retval = uncaught(0); | ||
|
||
newrelic_end_transaction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
call a function and trigger an exception that is caught | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT | ||
ok - caught(0) | ||
*/ | ||
|
||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
// call a function and trigger an exception that is caught | ||
$retval = caught(0); | ||
|
||
newrelic_end_transaction(); | ||
|
||
tap_equal(1, $retval, 'caught(0)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
call a function and trigger an exception that is caught | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT | ||
ok - followup(0) | ||
*/ | ||
|
||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
$retval = followup(0); | ||
|
||
newrelic_end_transaction(); | ||
|
||
tap_equal(1, $retval, 'followup(0)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
call a function and trigger an exception that is caught but another uncaught exception is thrown | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT_REGEX | ||
^\s*Fatal error: Uncaught.*RuntimeException.*Division by zero.* | ||
*/ | ||
|
||
|
||
/*EXPECT_ERROR_EVENTS | ||
[ | ||
"?? agent run id", | ||
{ | ||
"reservoir_size": 100, | ||
"events_seen": 1 | ||
}, | ||
[ | ||
"?? error event" | ||
] | ||
]*/ | ||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
$retval = followup_uncaught(0); | ||
|
||
newrelic_end_transaction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
call a function and trigger an exception that is caught then rethrown | ||
*/ | ||
|
||
/*INI | ||
display_errors=1 | ||
log_errors=0 | ||
*/ | ||
|
||
/*EXPECT_REGEX | ||
^\s*Fatal error: Uncaught.*RuntimeException.*Rethrown caught exception.*Division by zero.* | ||
*/ | ||
|
||
|
||
/*EXPECT_ERROR_EVENTS | ||
[ | ||
"?? agent run id", | ||
{ | ||
"reservoir_size": 100, | ||
"events_seen": 1 | ||
}, | ||
[ | ||
"?? error event" | ||
] | ||
]*/ | ||
|
||
|
||
require_once(__DIR__.'/functions.inc'); | ||
require_once(__DIR__.'/../include/tap.php'); | ||
|
||
$retval = rethrow(0); | ||
|
||
newrelic_end_transaction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
function three($a) { | ||
if (0 == $a) { | ||
throw new RuntimeException('Division by zero'); | ||
} else { | ||
return $a; | ||
} | ||
} | ||
|
||
function two($a) { | ||
return three($a); | ||
} | ||
|
||
function uncaught($a) { | ||
return two($a); | ||
} | ||
|
||
function caught($a) { | ||
try { | ||
two($a); | ||
} catch (Exception $e) { | ||
return 1; | ||
} | ||
return 1; | ||
} | ||
|
||
function followup($a) { | ||
try { | ||
two($a); | ||
} catch (Exception $e) { | ||
return three(1); | ||
} | ||
return three(1); | ||
} | ||
|
||
function followup_uncaught($a) { | ||
try { | ||
two($a); | ||
} catch (Exception $e) { | ||
return three(0); | ||
} | ||
return three(1); | ||
} | ||
|
||
function rethrow($a) { | ||
try { | ||
two($a); | ||
} catch (Exception $e) { | ||
throw new RuntimeException('Rethrown caught exception: '. $e->getMessage()); | ||
} | ||
return three(1); | ||
} |