2018-03-05 19:47:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ $# - lt 2 ]; then
|
|
|
|
echo "usage: $0 [skip-head]"
|
2018-03-06 20:27:41 +00:00
|
|
|
exit 1
|
2018-03-05 19:47:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
SKIP_HEAD=${1-1}
|
|
|
|
|
|
|
|
source build-config.cfg
|
|
|
|
|
|
|
|
./build.sh
|
|
|
|
|
2018-03-22 15:23:54 +00:00
|
|
|
plugin_tainacan=`basename $wp_plugin_dir`
|
|
|
|
plugin_wpclear='wpress-db-cleaner'
|
|
|
|
|
2018-03-05 19:47:45 +00:00
|
|
|
test_db_prefix='wptests_'
|
2018-03-06 20:27:41 +00:00
|
|
|
cy_record_key='a15e6599-d240-4d98-b582-dea93a3008c0'
|
2018-03-05 19:47:45 +00:00
|
|
|
|
2018-03-06 20:27:41 +00:00
|
|
|
################# set up cypress environment
|
2018-03-05 19:47:45 +00:00
|
|
|
# replace table prefix in wp_config
|
|
|
|
echo "Changing DB prefix in wp_config..."
|
|
|
|
sed -i s/"require_once(ABSPATH . 'wp-settings.php');"/"\$table_prefix = '$test_db_prefix';\nrequire_once(ABSPATH . 'wp-settings.php');"/ $wp_base_dir/wp-config.php
|
|
|
|
|
|
|
|
# install WordPress
|
|
|
|
cd $wp_base_dir
|
|
|
|
echo "Installing WordPress..."
|
|
|
|
wp core install --url=$wp_url --title=Test --admin_user=admin --admin_password=admin --admin_email=admin@admin.com
|
|
|
|
|
|
|
|
# Activate Tainacan
|
2018-03-22 15:23:54 +00:00
|
|
|
wp plugin activate $plugin_tainacan $plugin_wpclear
|
2018-03-05 19:47:45 +00:00
|
|
|
|
|
|
|
# back to tainacan dev directory
|
|
|
|
cd -
|
|
|
|
|
|
|
|
# cypress beginning
|
|
|
|
if [ ${SKIP_HEAD} = "0" ]
|
|
|
|
then
|
2018-03-06 20:27:41 +00:00
|
|
|
./node_modules/.bin/cypress run --config baseUrl=$wp_url --record --key $cy_record_key
|
2018-03-05 19:47:45 +00:00
|
|
|
else
|
2018-03-06 20:27:41 +00:00
|
|
|
./node_modules/.bin/cypress open --config baseUrl=$wp_url
|
2018-03-05 19:47:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
################## teardown cypress environment
|
|
|
|
# remove WordPress
|
|
|
|
echo "Removing WordPress..."
|
2018-03-06 20:27:41 +00:00
|
|
|
cd $wp_base_dir/
|
2018-03-05 19:47:45 +00:00
|
|
|
wp db query "DROP TABLES $(wp db tables | paste -s -d, -);"
|
|
|
|
|
|
|
|
# recover table prefix in wp_config
|
|
|
|
echo "Restoring DB prefix in wp_config..."
|
2018-03-06 20:27:41 +00:00
|
|
|
sed -i s/"\$table_prefix = '$test_db_prefix';"/test/ $wp_base_dir/wp-config.php
|
|
|
|
sed -i '/test/d' $wp_base_dir/wp-config.php
|