MediaWiki  1.23.8
MWExceptionHandlerTest.php
Go to the documentation of this file.
1 <?php
10 
14  public function testGetRedactedTrace() {
15  $refvar = 'value';
16  try {
17  $array = array( 'a', 'b' );
18  $object = new StdClass();
19  self::helperThrowAnException( $array, $object, $refvar );
20  } catch ( Exception $e ) {
21  }
22 
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();
27  $hasObject = false;
28  $hasArray = false;
29  foreach ( $trace as $frame ) {
30  if ( ! isset( $frame['args'] ) ) {
31  continue;
32  }
33  foreach ( $frame['args'] as $arg ) {
34  $hasObject = $hasObject || is_object( $arg );
35  $hasArray = $hasArray || is_array( $arg );
36  }
37 
38  if ( $hasObject && $hasArray ) {
39  break;
40  }
41  }
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" );
46 
47  # Now we redact the trace.. and make sure no function arguments are
48  # arrays or objects.
50 
51  foreach ( $redacted as $frame ) {
52  if ( ! isset( $frame['args'] ) ) {
53  continue;
54  }
55  foreach ( $frame['args'] as $arg ) {
56  $this->assertNotInternalType( 'array', $arg );
57  $this->assertNotInternalType( 'object', $arg );
58  }
59  }
60 
61  $this->assertEquals( 'value', $refvar, 'Ensuring reference variable wasn\'t changed' );
62  }
63 
71  protected static function helperThrowAnException( $a, $b, &$c ) {
72  throw new Exception();
73  }
74 }
MWExceptionHandlerTest\helperThrowAnException
static helperThrowAnException( $a, $b, &$c)
Helper function for testExpandArgumentsInCall.
Definition: MWExceptionHandlerTest.php:71
MWExceptionHandlerTest
Definition: MWExceptionHandlerTest.php:9
MWExceptionHandlerTest\testGetRedactedTrace
testGetRedactedTrace()
@covers MWExceptionHandler::getRedactedTrace
Definition: MWExceptionHandlerTest.php:14
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MWExceptionHandler\getRedactedTrace
static getRedactedTrace(Exception $e)
Return a copy of an exception's backtrace as an array.
Definition: MWExceptionHandler.php:206
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$e
if( $useReadline) $e
Definition: eval.php:66