summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/MWExceptionHandlerTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-03-12 18:12:23 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-03-12 18:12:23 +0100
commitd417de70fcf39e0a7a15ba780b597914d16ca0f7 (patch)
tree06ef8c333473660350b995abc03e18f3f85359eb /tests/phpunit/includes/MWExceptionHandlerTest.php
parenta4edbfa031eb4cd72678051f1510afde4f77951e (diff)
Update to MediaWiki 1.22.4
Diffstat (limited to 'tests/phpunit/includes/MWExceptionHandlerTest.php')
-rw-r--r--tests/phpunit/includes/MWExceptionHandlerTest.php73
1 files changed, 0 insertions, 73 deletions
diff --git a/tests/phpunit/includes/MWExceptionHandlerTest.php b/tests/phpunit/includes/MWExceptionHandlerTest.php
deleted file mode 100644
index 987dfa83..00000000
--- a/tests/phpunit/includes/MWExceptionHandlerTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * Tests for includes/Exception.php.
- *
- * @author Antoine Musso
- * @copyright Copyright © 2013, Antoine Musso
- * @copyright Copyright © 2013, Wikimedia Foundation Inc.
- * @file
- */
-
-class MWExceptionHandlerTest extends MediaWikiTestCase {
-
- /**
- * @covers MWExceptionHandler::getRedactedTrace
- */
- function testGetRedactedTrace() {
- try {
- $array = array( 'a', 'b' );
- $object = new StdClass();
- self::helperThrowAnException( $array, $object );
- } catch (Exception $e) {
- }
-
- # Make sure our strack trace contains an array and an object passed to
- # some function in the stacktrace. Else, we can not assert the trace
- # redaction achieved its job.
- $trace = $e->getTrace();
- $hasObject = false;
- $hasArray = false;
- foreach ( $trace as $frame ) {
- if ( ! isset( $frame['args'] ) ) {
- continue;
- }
- foreach ( $frame['args'] as $arg ) {
- $hasObject = $hasObject || is_object( $arg );
- $hasArray = $hasArray || is_array( $arg );
- }
-
- if( $hasObject && $hasArray ) {
- break;
- }
- }
- $this->assertTrue( $hasObject,
- "The stacktrace must have a function having an object has parameter" );
- $this->assertTrue( $hasArray,
- "The stacktrace must have a function having an array has parameter" );
-
- # Now we redact the trace.. and make sure no function arguments are
- # arrays or objects.
- $redacted = MWExceptionHandler::getRedactedTrace( $e );
-
- foreach ( $redacted as $frame ) {
- if ( ! isset( $frame['args'] ) ) {
- continue;
- }
- foreach ( $frame['args'] as $arg ) {
- $this->assertNotInternalType( 'array', $arg);
- $this->assertNotInternalType( 'object', $arg);
- }
- }
- }
-
- /**
- * Helper function for testExpandArgumentsInCall
- *
- * Pass it an object and an array :-)
- *
- * @throws Exception
- */
- protected static function helperThrowAnException( $a, $b ) {
- throw new Exception();
- }
-}