Skip to content

Commit

Permalink
Improve testruns even more
Browse files Browse the repository at this point in the history
This makes sure that WordPress is only installed once at the beginning
and also makes sure that the admin-email page is not displayed every now
and then. That requires some magic but as that only happes once at the
beginning that is OK.
  • Loading branch information
heiglandreas committed Aug 14, 2024
1 parent ed0ac96 commit 68f12a1
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ class FeatureContext implements Context
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*
* @BeforeSuite
*/
public function __construct()
public static function beforeSuite()
{
exec('wp --allow-root core install --url=localhost --title=Example --admin_user=localadmin --admin_password=P@ssw0rd [email protected]');
exec('wp --allow-root plugin activate authldap');
exec('wp --allow-root plugin is-active authldap', $response, $code);
if ($code !== 0) {
exec('wp --allow-root plugin activate authldap');
}
exec('wp --allow-root theme list | grep -E "\Wactive" | awk \'{ print $1; }\'', $result);
exec ('wp --allow-root theme path ' . $result[0] . ' --dir', $output, $code);
file_put_contents($output[0] . '/functions.php', <<<'EOF'
<?php add_filter( 'admin_email_check_interval', '__return_false' );
EOF);
}


Expand Down Expand Up @@ -153,6 +163,18 @@ public function anLdapGroupExists($arg1)
*/
public function aWordpressUserWithNameAndEmailExists($arg1, $arg2, $arg3)
{
exec(sprintf(
'wp --allow-root user get %1$s',
$arg1
), $result, $code);
if ($code === 0) {

exec(sprintf(
'wp --allow-root user delete %1$s --yes',
$arg1
));
}

exec(sprintf(
'wp --allow-root user create %1$s %3$s --display_name=%2$s --porcelain',
$arg1,
Expand All @@ -167,9 +189,15 @@ public function aWordpressUserWithNameAndEmailExists($arg1, $arg2, $arg3)
public function aWordpressRoleExists($arg1)
{
exec(sprintf(
'wp --allow-root role create %1$s %1$s',
$arg1,
));
'wp --allow-root role exists %1$s',
$arg1
), $result, $code);
if ($code !== 0) {
exec(sprintf(
'wp --allow-root role create %1$s %1$s',
$arg1,
));
}
}

/**
Expand Down

0 comments on commit 68f12a1

Please sign in to comment.