Commit 568034d9 authored by webchick's avatar webchick

#308399 by Damien Tournoud: Fix SimpleTest error handler to not spaz out and...

#308399 by Damien Tournoud: Fix SimpleTest error handler to not spaz out and die when PHP errors are encountered.
parent cf5b00c5
......@@ -637,6 +637,12 @@ function drupal_error_handler($errno, $message, $filename, $line, $context) {
* An associative array with keys 'file', 'line' and 'function'.
*/
function _drupal_get_last_caller($backtrace) {
// Errors that occur inside PHP internal functions
// do not generate information about file and line.
while ($backtrace && !isset($backtrace[0]['line'])) {
array_shift($backtrace);
}
// The first trace is the call itself.
// It gives us the line and the file of the last call.
$call = $backtrace[0];
......
......@@ -75,6 +75,7 @@ class SimpleTestTestCase extends DrupalWebTestCase {
$this->stubTest();
}
else {
// Run twice so test_ids can be accumulated.
for ($i = 0; $i < 2; $i++) {
// Run this test from web interface.
......@@ -107,11 +108,14 @@ class SimpleTestTestCase extends DrupalWebTestCase {
$this->pass(t('Test ID is @id.', array('@id' => $this->test_id)));
// Generates a warning
// Generates a warning.
$i = 1 / 0;
// Call an assert function specific to that class.
$this->assertNothing();
// Generates a warning inside a PHP function.
array_key_exists(NULL, NULL);
}
/**
......@@ -137,6 +141,9 @@ class SimpleTestTestCase extends DrupalWebTestCase {
// Check that the backtracing code works for specific assert function.
$this->assertAssertion('This is nothing.', 'Other', 'Pass', 'simpletest.test', 'SimpleTestTestCase->stubTest()');
// Check that errors that occur inside PHP internal functions are correctly reported.
$this->assertAssertion('The second argument should be either an array or an object', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestTestCase->stubTest()');
$this->test_ids[] = $test_id = $this->getTestIdFromResults();
$this->assertTrue($test_id, t('Found test ID in results.'));
}
......@@ -168,7 +175,7 @@ class SimpleTestTestCase extends DrupalWebTestCase {
$message = trim(strip_tags($message));
$found = FALSE;
foreach ($this->results['assertions'] as $assertion) {
if ($assertion['message'] == $message &&
if ((strpos($assertion['message'], $message) !== FALSE) &&
$assertion['type'] == $type &&
$assertion['status'] == $status &&
$assertion['file'] == $file &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment