Compare commits

...

6 Commits

Author SHA1 Message Date
Fabien Potencier
993f4c9cfc fixed CS 2014-09-22 10:32:35 +02:00
Christian Raue
91e3a1480c removed defaults from PHPUnit configuration 2014-07-07 12:13:42 +02:00
Christian Raue
732b41060b added XSD to PHPUnit configuration 2014-07-07 11:57:21 +02:00
Nicolas Grekas
ca764f8af9 [Debug] fix #10313: FlattenException not found because of https://bugs.php.net/42098 2014-04-29 21:42:43 +02:00
Nicolas Grekas
9fb191fa62 [Debug] fix ErrorHandlerTest when context is not an array 2014-04-28 20:50:14 +02:00
Nicolas Grekas
b2e922174d [Debug] ErrorHandler: remove $GLOBALS from context in PHP5.3 fix #10292 2014-04-28 18:43:50 +02:00
4 changed files with 28 additions and 27 deletions

View File

@@ -125,6 +125,13 @@ class ErrorHandler
if (!class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
require __DIR__.'/Exception/ContextErrorException.php';
}
if (!class_exists('Symfony\Component\Debug\Exception\FlattenException')) {
require __DIR__.'/Exception/FlattenException.php';
}
if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && is_array($context)) {
unset($context['GLOBALS']);
}
$exception = new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context);

View File

@@ -165,18 +165,18 @@ PHP
public function testHandle()
{
$handler = ErrorHandler::register(0);
$this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo'));
$this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array()));
restore_error_handler();
$handler = ErrorHandler::register(3);
$this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo'));
$this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, array()));
restore_error_handler();
$handler = ErrorHandler::register(3);
try {
$handler->handle(111, 'foo', 'foo.php', 12, 'foo');
$handler->handle(111, 'foo', 'foo.php', 12, array());
} catch (\ErrorException $e) {
$this->assertSame('111: foo in foo.php line 12', $e->getMessage());
$this->assertSame(111, $e->getSeverity());
@@ -187,12 +187,12 @@ PHP
restore_error_handler();
$handler = ErrorHandler::register(E_USER_DEPRECATED);
$this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'));
$this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array()));
restore_error_handler();
$handler = ErrorHandler::register(E_DEPRECATED);
$this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo'));
$this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, array()));
restore_error_handler();
@@ -215,7 +215,7 @@ PHP
$handler = ErrorHandler::register(E_USER_DEPRECATED);
$handler->setLogger($logger);
$handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo');
$handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array());
restore_error_handler();
}

View File

@@ -114,7 +114,6 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.');
$this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.');
$this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception');
}
/**
@@ -160,13 +159,13 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(
array(
'message'=> 'test',
'class'=>'Exception',
'trace'=>array(array(
'message' => 'test',
'class' => 'Exception',
'trace' => array(array(
'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123,
'args' => array()
'args' => array(),
)),
)
),
), $flattened->toArray());
}
@@ -202,7 +201,7 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
'line' => 123,
'function' => 'test',
'args' => array(
unserialize('O:14:"BogusTestClass":0:{}')
unserialize('O:14:"BogusTestClass":0:{}'),
),
),
),
@@ -211,9 +210,9 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(
array(
'message'=> 'test',
'class'=>'Exception',
'trace'=>array(
'message' => 'test',
'class' => 'Exception',
'trace' => array(
array(
'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '',
'file' => 'foo.php', 'line' => 123,
@@ -224,12 +223,12 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
'file' => __FILE__, 'line' => 123,
'args' => array(
array(
'incomplete-object', 'BogusTestClass'
'incomplete-object', 'BogusTestClass',
),
),
)
),
),
)
),
), $flattened->toArray());
}
}

View File

@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>