summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc6
-rw-r--r--modules/simpletest/simpletest.test11
2 files changed, 15 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 3a00beea4..33109f00e 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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];
diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index 711748d79..dbb91c2ef 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -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 &&