| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/enoikio/core/tests/Drupal/Nightwatch/Commands/ |
Upload File : |
import { execSync } from 'child_process';
import { URL } from 'url';
import { commandAsWebserver } from '../globals';
/**
* Installs a Drupal test site.
*
* @param {oject} [settings={}]
* Settings object
* @param {string} [settings.setupFile='']
* Setup file used by TestSiteApplicationTest
* @param {function} callback
* A callback which will be called, when the installation is finished.
* @return {object}
* The 'browser' object.
*/
exports.command = function drupalInstall({ setupFile = '' } = {}, callback) {
const self = this;
try {
setupFile = setupFile ? `--setup-file "${setupFile}"` : '';
const dbOption =
process.env.DRUPAL_TEST_DB_URL.length > 0
? `--db-url ${process.env.DRUPAL_TEST_DB_URL}`
: '';
const install = execSync(
commandAsWebserver(
`php ./scripts/test-site.php install ${setupFile} --install-profile nightwatch_testing --base-url ${process.env.DRUPAL_TEST_BASE_URL} ${dbOption} --json`,
),
);
const installData = JSON.parse(install.toString());
this.globals.drupalDbPrefix = installData.db_prefix;
this.globals.drupalSitePath = installData.site_path;
const url = new URL(process.env.DRUPAL_TEST_BASE_URL);
this.url(process.env.DRUPAL_TEST_BASE_URL).setCookie({
name: 'SIMPLETEST_USER_AGENT',
// Colons need to be URL encoded to be valid.
value: encodeURIComponent(installData.user_agent),
path: url.pathname,
domain: url.host,
});
} catch (error) {
this.assert.fail(error);
}
// Nightwatch doesn't like it when no actions are added in a command file.
// https://github.com/nightwatchjs/nightwatch/issues/1792
this.pause(1);
if (typeof callback === 'function') {
callback.call(self);
}
return this;
};