Refactoring of the starting local tests
This commit is contained in:
parent
4b074a464b
commit
f4c44d486c
15
.github/workflows/woo.yml
vendored
15
.github/workflows/woo.yml
vendored
@ -424,21 +424,6 @@ jobs:
|
|||||||
wp: '5.8'
|
wp: '5.8'
|
||||||
wc: '5.8.0'
|
wc: '5.8.0'
|
||||||
|
|
||||||
## WordPress 5.8 and last WooCommerce NEED DELETE , TEST WC 5.9.0 !!!
|
|
||||||
|
|
||||||
- php-version: '7.0'
|
|
||||||
wp: '5.8'
|
|
||||||
wc: '5.8.0'
|
|
||||||
- php-version: '7.1'
|
|
||||||
wp: '5.8'
|
|
||||||
wc: '5.8.0'
|
|
||||||
- php-version: '7.2'
|
|
||||||
wp: '5.8'
|
|
||||||
wc: '5.8.0'
|
|
||||||
- php-version: '7.3'
|
|
||||||
wp: '5.8'
|
|
||||||
wc: '5.8.0'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
|
4
Makefile
4
Makefile
@ -28,13 +28,13 @@ compile_pot:
|
|||||||
|
|
||||||
install:
|
install:
|
||||||
mkdir coverage
|
mkdir coverage
|
||||||
bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(DB_PASS) $(SKIP_DB_CREATE)
|
bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_HOST) $(DB_PASS) $(WP_VERSION) $(WC_VERSION)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
phpunit -c phpunit.xml.dist
|
phpunit -c phpunit.xml.dist
|
||||||
|
|
||||||
local_test:
|
local_test:
|
||||||
bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(DB_PASS) $(SKIP_DB_CREATE)
|
bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_HOST) $(DB_PASS) $(WP_VERSION) $(WC_VERSION)
|
||||||
phpunit -c phpunit.xml.dist
|
phpunit -c phpunit.xml.dist
|
||||||
|
|
||||||
run_tests:
|
run_tests:
|
||||||
|
@ -1,30 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# See https://raw.githubusercontent.com/wp-cli/scaffold-command/master/templates/install-wp-tests.sh
|
# Example https://raw.githubusercontent.com/wp-cli/scaffold-command/master/templates/install-wp-tests.sh
|
||||||
|
|
||||||
if [ $# -lt 3 ]; then
|
|
||||||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
DB_NAME=$1
|
DB_NAME=$1
|
||||||
DB_USER=$2
|
DB_USER=$2
|
||||||
DB_HOST=${3-localhost}
|
DB_HOST=$3
|
||||||
WP_VERSION=${4-latest}
|
DB_PASS=$4
|
||||||
WC_VERSION=${5-3.9.0}
|
WP_VERSION=$5
|
||||||
DB_PASS=${6-''}
|
WC_VERSION=$6
|
||||||
SKIP_DB_CREATE=${7-false}
|
|
||||||
|
|
||||||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
||||||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
|
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
|
||||||
|
|
||||||
download() {
|
|
||||||
if [ `which curl` ]; then
|
|
||||||
curl -s "$1" > "$2";
|
|
||||||
elif [ `which wget` ]; then
|
|
||||||
wget -nv -O "$2" "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
|
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
|
||||||
WP_TESTS_TAG="tags/$WP_VERSION"
|
WP_TESTS_TAG="tags/$WP_VERSION"
|
||||||
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
||||||
@ -43,35 +29,30 @@ fi
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
install_wp() {
|
download() {
|
||||||
|
if [ `which curl` ]; then
|
||||||
|
curl -s "$1" > "$2";
|
||||||
|
elif [ `which wget` ]; then
|
||||||
|
wget -nv -O "$2" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_wp() {
|
||||||
if [ -d $WP_CORE_DIR ]; then
|
if [ -d $WP_CORE_DIR ]; then
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $WP_CORE_DIR
|
mkdir -p $WP_CORE_DIR
|
||||||
|
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||||
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
|
||||||
mkdir -p /tmp/wordpress-nightly
|
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
||||||
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
|
|
||||||
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
|
|
||||||
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
|
|
||||||
else
|
|
||||||
if [ $WP_VERSION == 'latest' ]; then
|
|
||||||
local ARCHIVE_NAME='latest'
|
|
||||||
else
|
|
||||||
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
|
||||||
fi
|
|
||||||
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
|
|
||||||
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
||||||
}
|
}
|
||||||
|
|
||||||
install_woocommerce() {
|
install_woocommerce() {
|
||||||
if [[ ! -d "/tmp/woocommerce" ]]
|
if [[ ! -d "/tmp/woocommerce" ]]
|
||||||
then
|
then
|
||||||
|
echo $WC_VERSION;
|
||||||
cd /tmp
|
cd /tmp
|
||||||
git clone https://github.com/woocommerce/woocommerce.git
|
git clone https://github.com/woocommerce/woocommerce.git
|
||||||
cd woocommerce
|
cd woocommerce
|
||||||
@ -107,34 +88,11 @@ install_test_suite() {
|
|||||||
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_db() {
|
install_db() {
|
||||||
|
|
||||||
if [ ${SKIP_DB_CREATE} = "true" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# parse DB_HOST for port or socket references
|
|
||||||
local PARTS=(${DB_HOST//\:/ })
|
|
||||||
local DB_HOSTNAME=${PARTS[0]};
|
|
||||||
local DB_SOCK_OR_PORT=${PARTS[1]};
|
|
||||||
local EXTRA=""
|
|
||||||
|
|
||||||
if ! [ -z $DB_HOSTNAME ] ; then
|
|
||||||
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
|
|
||||||
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
|
||||||
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
|
||||||
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
|
||||||
elif ! [ -z $DB_HOSTNAME ] ; then
|
|
||||||
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${DB_HOST} == "localhost" ]; then
|
if [ ${DB_HOST} == "localhost" ]; then
|
||||||
# create database
|
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS" --host=$DB_HOST
|
||||||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA --host=$DB_HOST
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user