17 $array = [
'a',
'b' ];
18 $object =
new stdClass();
20 }
catch ( Exception
$e ) {
23 # Make sure our stack trace contains an array and an object passed to
24 # some function in the stacktrace. Else, we can not assert the trace
25 # redaction achieved its job.
26 $trace =
$e->getTrace();
29 foreach ( $trace
as $frame ) {
30 if ( !isset( $frame[
'args'] ) ) {
33 foreach ( $frame[
'args']
as $arg ) {
34 $hasObject = $hasObject || is_object( $arg );
35 $hasArray = $hasArray || is_array( $arg );
38 if ( $hasObject && $hasArray ) {
42 $this->assertTrue( $hasObject,
43 "The stacktrace must have a function having an object has parameter" );
44 $this->assertTrue( $hasArray,
45 "The stacktrace must have a function having an array has parameter" );
47 # Now we redact the trace.. and make sure no function arguments are
49 $redacted = MWExceptionHandler::getRedactedTrace(
$e );
51 foreach ( $redacted
as $frame ) {
52 if ( !isset( $frame[
'args'] ) ) {
55 foreach ( $frame[
'args']
as $arg ) {
56 $this->assertNotInternalType(
'array', $arg );
57 $this->assertNotInternalType(
'object', $arg );
61 $this->assertEquals(
'value', $refvar,
'Ensuring reference variable wasn\'t changed' );