From 19e2e0a4f7771b3886b935cbba13d419b31e2e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Mon, 30 Nov 2020 16:47:30 +0100 Subject: [PATCH] Unzip Woocommerce plugin for codeception [MAILPOET-3321] --- tests/docker/codeception/docker-entrypoint.sh | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tests/docker/codeception/docker-entrypoint.sh b/tests/docker/codeception/docker-entrypoint.sh index b78d9a183e..bab0c57c83 100755 --- a/tests/docker/codeception/docker-entrypoint.sh +++ b/tests/docker/codeception/docker-entrypoint.sh @@ -45,8 +45,36 @@ else wp core multisite-install $WP_CORE_INSTALL_PARAMS fi +# Load Composer dependencies +# Set SKIP_DEPS environment flag to not download them. E.g. you have downloaded them yourself +# Example: docker-compose run -e SKIP_DEPS=1 codeception ... +if [[ -z "${SKIP_DEPS}" ]]; then + cd /project + ./tools/vendor/composer.phar install + cd - >/dev/null +fi + # install WooCommerce (activate & deactivate it to populate DB for backup) -wp plugin install woocommerce +if [[ ! -d "/wp-core/wp-content/plugins/woocommerce" ]]; then + cd /wp-core/wp-content/plugins + WOOCOMMERCE_SOURCE_ZIP="/wp-core/wp-content/plugins/mailpoet/tools/vendor/woocommerce.zip" + WOOCOMMERCE_TARGET_ZIP="/wp-core/wp-content/plugins/woocommerce.zip" + # download woocommerce plugin if file doesn't exist + if [ -f "$WOOCOMMERCE_SOURCE_ZIP" ]; then + echo "Copy Woocommerce plugin from $WOOCOMMERCE_SOURCE_ZIP" + cp "$WOOCOMMERCE_SOURCE_ZIP" "$WOOCOMMERCE_TARGET_ZIP" + else + DOWNLOAD_URL=$(curl -s https://api.github.com/repos/woocommerce/woocommerce/releases/latest \ + | grep browser_download_url \ + | grep woocommerce \ + | cut -d '"' -f 4) + echo "Downloading Woocommerce plugin from $DOWNLOAD_URL" + curl -s -L --create-dirs -o "$WOOCOMMERCE_TARGET_ZIP" "$DOWNLOAD_URL" + fi + + echo "Unzip Woocommerce plugin from $WOOCOMMERCE_TARGET_ZIP" + unzip -q -o "$WOOCOMMERCE_TARGET_ZIP" +fi wp plugin activate woocommerce wp plugin deactivate woocommerce @@ -64,15 +92,6 @@ CONFIG+="if (!isset(\$_SERVER['SERVER_NAME'])) \$_SERVER['SERVER_NAME'] = '';\n" sed -i "s/define( *'WP_DEBUG', false *);/$CONFIG/" ./wp-config.php -# Load Composer dependencies -# Set SKIP_DEPS environment flag to not download them. E.g. you have downloaded them yourself -# Example: docker-compose run -e SKIP_DEPS=1 codeception ... -if [[ -z "${SKIP_DEPS}" ]]; then - cd /project - ./tools/vendor/composer.phar install - cd - >/dev/null -fi - # activate MailPoet wp plugin activate mailpoet/mailpoet.php