From df9a5295ce44d3f538b445886cb4fa35b795867f Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Mon, 15 Jul 2024 03:26:28 +0530 Subject: [PATCH] try fixing e2e --- .wp-env.json | 9 +-------- tests/bin/.htaccess | 20 ++++++++++++++++++++ tests/bin/initialize.sh | 40 +++++++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 25 deletions(-) create mode 100755 tests/bin/.htaccess diff --git a/.wp-env.json b/.wp-env.json index 3695c1a0f..b131bfcbc 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -4,12 +4,5 @@ ".", "./tests/Basic-Auth-master" ], - "env": { - "tests": { - "port": 80, - "mappings": { - "wp-cli.yml": "./tests/bin/wp-cli.yml" - } - } - } + "port": 80 } diff --git a/tests/bin/.htaccess b/tests/bin/.htaccess new file mode 100755 index 000000000..6cbc7d8d1 --- /dev/null +++ b/tests/bin/.htaccess @@ -0,0 +1,20 @@ +# BEGIN WordPress +# The directives (lines) between "BEGIN WordPress" and "END WordPress" are +# dynamically generated, and should only be modified via WordPress filters. +# Any changes to the directives between these markers will be overwritten. +RewriteEngine On +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] +RewriteBase / +RewriteRule ^index\.php$ - [L] + +# add a trailing slash to /wp-admin +RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] + +RewriteCond %{REQUEST_FILENAME} -f [OR] +RewriteCond %{REQUEST_FILENAME} -d +RewriteRule ^ - [L] +RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] +RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] +RewriteRule . index.php [L] + +# END WordPress \ No newline at end of file diff --git a/tests/bin/initialize.sh b/tests/bin/initialize.sh index 06c8cae4f..d59c59b43 100755 --- a/tests/bin/initialize.sh +++ b/tests/bin/initialize.sh @@ -1,21 +1,27 @@ #!/bin/bash -set -e +# set -e -npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" -npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" +# npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" +# npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" -status=0 -npm run env run tests-cli "wp site list" || status=$? +# status=0 +# npm run env run tests-cli "wp site list" || status=$? -if [ $status -eq 0 ] -then - echo "Multisite already initialized" -else - echo "Converting to multisite" - npm run env run tests-cli "wp core multisite-convert --title='Distributor Multisite'" - npm run env run tests-cli "wp user create second 'second@admin.local' --user_pass=password --role=administrator" - npm run env run tests-cli "wp site create --slug=second --title='Second Site' --email='second@admin.local'" - npm run env run tests-cli "wp theme enable twentytwentyone --activate" - npm run env run tests-cli "wp theme enable twentytwentyone --url=localhost/second --activate" - npm run env run tests-cli "cp wp-content/plugins/distributor/tests/cypress/.htaccess .htaccess" -fi +# if [ $status -eq 0 ] +# then +# echo "Multisite already initialized" +# else +# echo "Converting to multisite" +# npm run env run tests-cli "wp core multisite-convert --title='Distributor Multisite'" +# npm run env run tests-cli "wp user create second 'second@admin.local' --user_pass=password --role=administrator" +# npm run env run tests-cli "wp site create --slug=second --title='Second Site' --email='second@admin.local'" +# npm run env run tests-cli "wp theme enable twentytwentyone --activate" +# npm run env run tests-cli "wp theme enable twentytwentyone --url=localhost/second --activate" +# npm run env run tests-cli "cp wp-content/plugins/distributor/tests/cypress/.htaccess .htaccess" +# fi + +wp-env run cli wp core multisite-convert +HTACCESS_PATH="$(wp-env install-path)/WordPress/.htaccess" +cp ./tests/bin/.htaccess $HTACCESS_PATH; +wp-env run cli wp user create second 'second@admin.local' --user_pass=password --role=administrator +wp-env run cli wp site create --slug=second --title='Second Site' --email='second@admin.local'