From 4e41d8e5ac4b8ffbdca1fcf2a8a3eadf65df0318 Mon Sep 17 00:00:00 2001 From: Jason Agnew Date: Tue, 8 Dec 2020 17:23:14 +0000 Subject: [PATCH 1/3] Make sure uploads folder is writeable and cleared per soft reset --- package.json | 2 +- update.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 352bccb..38e5c2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bigbite/wp-cypress", - "version": "0.8.0", + "version": "0.8.1", "description": "WordPress end to end testing with Cypress.io", "repository": "https://github.com/bigbite/wp-cypress", "author": { diff --git a/update.sh b/update.sh index 1b716e6..30609aa 100644 --- a/update.sh +++ b/update.sh @@ -4,6 +4,11 @@ HARD_RESET=$2 shopt -s extglob rm -rf !(wp-config.php|wp-cypress-config.php|seeds|wp-content|update.sh|.htaccess) +# Ensure uploads work +rm -rf /var/www/html/wp-content/uploads +mkdir -p /var/www/html/wp-content/uploads +chmod -R 777 /var/www/html/wp-content/uploads + if ${HARD_RESET}; then rm wp-config.php; fi cp -rfp ../${VERSION}/* ./ From 8da8ea8b748abcfa5ac54705ae4ade00a79b4132 Mon Sep 17 00:00:00 2001 From: Jason Agnew Date: Tue, 12 Jan 2021 11:16:41 +0000 Subject: [PATCH 2/3] Only reset images on hard reset otherwise seed images would be lost before first test run --- update.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/update.sh b/update.sh index 30609aa..11b9e64 100644 --- a/update.sh +++ b/update.sh @@ -5,9 +5,7 @@ shopt -s extglob rm -rf !(wp-config.php|wp-cypress-config.php|seeds|wp-content|update.sh|.htaccess) # Ensure uploads work -rm -rf /var/www/html/wp-content/uploads -mkdir -p /var/www/html/wp-content/uploads -chmod -R 777 /var/www/html/wp-content/uploads +if ${HARD_RESET}; then rm -rf /var/www/html/wp-content/uploads && mkdir -p /var/www/html/wp-content/uploads && chmod -R 777 /var/www/html/wp-content/uploads; fi if ${HARD_RESET}; then rm wp-config.php; fi From 9d206b77478b7bdf4dfbd7a2e1c3bbe5c2985c16 Mon Sep 17 00:00:00 2001 From: Jason Agnew Date: Tue, 12 Jan 2021 11:26:24 +0000 Subject: [PATCH 3/3] Allow switchUser command to be loggedout user --- plugin/src/Plugin.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugin/src/Plugin.php b/plugin/src/Plugin.php index e035ea7..17e5c88 100644 --- a/plugin/src/Plugin.php +++ b/plugin/src/Plugin.php @@ -62,14 +62,20 @@ public function add_user_command(): void { * @return void */ public function set_user( $args ): void { - $user = get_user_by( 'login', $args[0] ); + $user_id = 'false'; - if ( ! $user ) { - WP_CLI::error( "User {$args[0]} doesn't exits." ); - return; + if ( 'loggedout' !== $args[0] ) { + $user = get_user_by( 'login', $args[0] ); + + if ( ! $user ) { + WP_CLI::error( "User {$args[0]} doesn't exits." ); + return; + } + + $user_id = $user->ID; } - file_put_contents( get_home_path() . '.userid', $user->ID ); + file_put_contents( get_home_path() . '.userid', $user_id ); WP_CLI::success( 'Current User set to ' . $args[0] ); }