Mercurial > hg > isophonics-drupal-site
annotate core/tests/Drupal/Nightwatch/Commands/drupalUninstall.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@17 | 1 import { execSync } from 'child_process'; |
Chris@17 | 2 import { commandAsWebserver } from '../globals'; |
Chris@17 | 3 |
Chris@17 | 4 /** |
Chris@17 | 5 * Uninstalls a test Drupal site. |
Chris@17 | 6 * |
Chris@17 | 7 * @param {function} callback |
Chris@17 | 8 * A callback which will be called, when the uninstallation is finished. |
Chris@17 | 9 * @return {object} |
Chris@17 | 10 * The 'browser' object. |
Chris@17 | 11 */ |
Chris@17 | 12 exports.command = function drupalUninstal(callback) { |
Chris@17 | 13 const self = this; |
Chris@17 | 14 const prefix = self.drupalDbPrefix; |
Chris@17 | 15 |
Chris@17 | 16 // Check for any existing errors, because running this will cause Nightwatch to hang. |
Chris@17 | 17 if (!this.currentTest.results.errors && !this.currentTest.results.failed) { |
Chris@17 | 18 const dbOption = |
Chris@17 | 19 process.env.DRUPAL_TEST_DB_URL.length > 0 |
Chris@17 | 20 ? `--db-url ${process.env.DRUPAL_TEST_DB_URL}` |
Chris@17 | 21 : ''; |
Chris@17 | 22 try { |
Chris@17 | 23 if (!prefix || !prefix.length) { |
Chris@17 | 24 throw new Error( |
Chris@17 | 25 'Missing database prefix parameter, unable to uninstall Drupal (the initial install was probably unsuccessful).', |
Chris@17 | 26 ); |
Chris@17 | 27 } |
Chris@17 | 28 execSync( |
Chris@17 | 29 commandAsWebserver( |
Chris@17 | 30 `php ./scripts/test-site.php tear-down ${prefix} ${dbOption}`, |
Chris@17 | 31 ), |
Chris@17 | 32 ); |
Chris@17 | 33 } catch (error) { |
Chris@17 | 34 this.assert.fail(error); |
Chris@17 | 35 } |
Chris@17 | 36 } |
Chris@17 | 37 |
Chris@17 | 38 // Nightwatch doesn't like it when no actions are added in a command file. |
Chris@17 | 39 // https://github.com/nightwatchjs/nightwatch/issues/1792 |
Chris@17 | 40 this.pause(1); |
Chris@17 | 41 |
Chris@17 | 42 if (typeof callback === 'function') { |
Chris@17 | 43 callback.call(self); |
Chris@17 | 44 } |
Chris@17 | 45 return this; |
Chris@17 | 46 }; |