-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set the configuration options through a command (#41787)
* Set the configuration options through a command * cs
- Loading branch information
Showing
3 changed files
with
27 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Cypress.Commands.add('config_setParameter', (parameter, value) => { | ||
cy.readFile(`${Cypress.env('cmsPath')}/configuration.php`).then((fileContent) => { | ||
// Setup the new value | ||
let newValue = value; | ||
if (typeof value === 'string') { | ||
newValue = `'${value}'`; | ||
} | ||
|
||
// The regex to find the line of the parameter | ||
const regex = new RegExp(`^.*\\$${parameter}\\s.*$`, 'mg'); | ||
|
||
// Replace the whole line with the new value | ||
const content = fileContent.replace(regex, `public $${parameter} = ${newValue};`); | ||
|
||
// Write the modified content back to the configuration file | ||
cy.task('writeFile', { path: 'configuration.php', content }); | ||
}); | ||
}); |