summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2015-09-07 11:39:17 (GMT)
committerNathaniel Catchpole2015-09-07 11:50:32 (GMT)
commit70880e91eed6d6c92602c2aed974aeb60d7792fc (patch)
tree95d661cedc8b9f6cffe42de206ae4d24f7022db6
parente12fd0d08dc8a57c3446638d36d7b4e3d129e7bb (diff)
Issue #2561207 by stefan.r, Aki Tendo: assert() without a message breaks in PHP 5
-rw-r--r--core/lib/Drupal/Component/Assertion/Handle.php2
-rw-r--r--core/modules/simpletest/src/Tests/SimpleTestTest.php13
2 files changed, 12 insertions, 3 deletions
diff --git a/core/lib/Drupal/Component/Assertion/Handle.php b/core/lib/Drupal/Component/Assertion/Handle.php
index 3912156..dd9911e 100644
--- a/core/lib/Drupal/Component/Assertion/Handle.php
+++ b/core/lib/Drupal/Component/Assertion/Handle.php
@@ -57,7 +57,7 @@ class Handle {
if (version_compare(PHP_VERSION, '7.0.0-dev') < 0) {
// PHP 5 - create a handler to throw the exception directly.
- assert_options(ASSERT_CALLBACK, function($file, $line, $code, $message) {
+ assert_options(ASSERT_CALLBACK, function($file = '', $line = 0, $code = '', $message = '') {
if (empty($message)) {
$message = $code;
}
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index c3758a7..8785897 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -167,11 +167,20 @@ EOD;
// Check to see if runtime assertions are indeed on, if successful this
// will be the first of sixteen passes asserted in confirmStubResults()
try {
- assert(FALSE, 'Lorem Ipsum');
+ // Test with minimum possible arguments to make sure no notice for
+ // missing argument is thrown.
+ assert(FALSE);
$this->fail('Runtime assertions are not working.');
}
catch (\AssertionError $e) {
- $this->assertEqual($e->getMessage(), 'Lorem Ipsum', 'Runtime assertions Enabled and running.');
+ try {
+ // Now test with an error message to insure it is correctly passed
+ // along by the rethrow.
+ assert(FALSE, 'Lorem Ipsum');
+ }
+ catch ( \AssertionError $e ) {
+ $this->assertEqual($e->getMessage(), 'Lorem Ipsum', 'Runtime assertions Enabled and running.');
+ }
}
// This causes the second of the sixteen passes asserted in
// confirmStubResults().