Mercurial > hg > isophonics-drupal-site
diff core/tests/Drupal/Tests/BrowserTestBase.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line diff
--- a/core/tests/Drupal/Tests/BrowserTestBase.php Fri Feb 23 15:51:18 2018 +0000 +++ b/core/tests/Drupal/Tests/BrowserTestBase.php Fri Feb 23 15:52:07 2018 +0000 @@ -35,6 +35,10 @@ * Drupal\Tests\yourmodule\Functional namespace and live in the * modules/yourmodule/tests/src/Functional directory. * + * Tests extending this base class should only translate text when testing + * translation functionality. For example, avoid wrapping test text with t() + * or TranslatableMarkup(). + * * @ingroup testing */ abstract class BrowserTestBase extends TestCase { @@ -62,6 +66,7 @@ createUser as drupalCreateUser; } use XdebugRequestTrait; + use PhpunitCompatibilityTrait; /** * The database prefix of this test run. @@ -342,7 +347,7 @@ protected function getDefaultDriverInstance() { // Get default driver params from environment if availables. if ($arg_json = getenv('MINK_DRIVER_ARGS')) { - $this->minkDefaultDriverArgs = json_decode($arg_json); + $this->minkDefaultDriverArgs = json_decode($arg_json, TRUE); } // Get and check default driver class from environment if availables. @@ -446,6 +451,15 @@ * {@inheritdoc} */ protected function setUp() { + // Installing Drupal creates 1000s of objects. Garbage collection of these + // objects is expensive. This appears to be causing random segmentation + // faults in PHP 5.x due to https://bugs.php.net/bug.php?id=72286. Once + // Drupal is installed is rebuilt, garbage collection is re-enabled. + $disable_gc = version_compare(PHP_VERSION, '7', '<') && gc_enabled(); + if ($disable_gc) { + gc_collect_cycles(); + gc_disable(); + } parent::setUp(); $this->setupBaseUrl(); @@ -466,6 +480,11 @@ // Set up the browser test output file. $this->initBrowserOutputFile(); + // If garbage collection was disabled prior to rebuilding container, + // re-enable it. + if ($disable_gc) { + gc_enable(); + } } /** @@ -777,10 +796,10 @@ * be unchecked. * @param string $submit * Value of the submit button whose click is to be emulated. For example, - * t('Save'). The processing of the request depends on this value. For - * example, a form may have one button with the value t('Save') and another - * button with the value t('Delete'), and execute different code depending - * on which one is clicked. + * 'Save'. The processing of the request depends on this value. For example, + * a form may have one button with the value 'Save' and another button with + * the value 'Delete', and execute different code depending on which one is + * clicked. * @param string $form_html_id * (optional) HTML ID of the form to be submitted. On some pages * there are many identical forms, so just using the value of the submit @@ -859,11 +878,11 @@ * @code * // First step in form. * $edit = array(...); - * $this->drupalPostForm('some_url', $edit, t('Save')); + * $this->drupalPostForm('some_url', $edit, 'Save'); * * // Second step in form. * $edit = array(...); - * $this->drupalPostForm(NULL, $edit, t('Save')); + * $this->drupalPostForm(NULL, $edit, 'Save'); * @endcode * @param array $edit * Field data in an associative array. Changes the current input fields @@ -893,10 +912,10 @@ * https://www.drupal.org/node/2802401 * @param string $submit * Value of the submit button whose click is to be emulated. For example, - * t('Save'). The processing of the request depends on this value. For - * example, a form may have one button with the value t('Save') and another - * button with the value t('Delete'), and execute different code depending - * on which one is clicked. + * 'Save'. The processing of the request depends on this value. For example, + * a form may have one button with the value 'Save' and another button with + * the value 'Delete', and execute different code depending on which one is + * clicked. * * This function can also be called to emulate an Ajax submission. In this * case, this value needs to be an array with the following keys: