-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from wp-graphql/feat/wp-graphql-codeception-mo…
…dule feat: WPGraphQL Codeception Module for E2E testing implemented and tested
- Loading branch information
Showing
26 changed files
with
1,296 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
TEST_SITE_DB_DSN=mysql:host=mysql;dbname=wordpress | ||
TEST_SITE_DB_HOST=mysql | ||
TEST_SITE_DB_DSN=mysql:host=codecept_db;dbname=wordpress | ||
TEST_SITE_DB_HOST=codecept_db | ||
TEST_SITE_DB_PORT=3306 | ||
TEST_SITE_DB_NAME=wordpress | ||
TEST_SITE_DB_USER=wordpress | ||
TEST_SITE_DB_PASSWORD=password | ||
|
@@ -9,10 +10,10 @@ TEST_SITE_ADMIN_PASSWORD=password | |
TEST_SITE_WP_ADMIN_PATH=/wp-admin | ||
WP_ROOT_FOLDER=/var/www/html | ||
TEST_DB_NAME=wordpress | ||
TEST_DB_HOST=mysql | ||
TEST_DB_HOST=codecept_db | ||
TEST_DB_USER=wordpress | ||
TEST_DB_PASSWORD=password | ||
TEST_TABLE_PREFIX=wp_ | ||
TEST_SITE_WP_URL=localhost:8080 | ||
TEST_SITE_WP_DOMAIN=localhost:8080 | ||
TEST_SITE_WP_URL=http://localhost | ||
TEST_SITE_WP_DOMAIN=localhost | ||
TEST_SITE_ADMIN_EMAIL=[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
ARG PHP_VERSION=8.1 | ||
|
||
FROM wordpress:php${PHP_VERSION}-apache | ||
|
||
# See: https://xdebug.org/docs/compat to match the Xdebug version with the PHP version. | ||
ARG XDEBUG_VERSION=3.3.1 | ||
|
||
RUN apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
# WP-CLI dependencies. | ||
bash less default-mysql-client git \ | ||
# MailHog dependencies. | ||
msmtp; | ||
|
||
COPY php.ini /usr/local/etc/php/php.ini | ||
|
||
RUN pecl install "xdebug-${XDEBUG_VERSION}"; \ | ||
docker-php-ext-enable xdebug | ||
|
||
ENV XDEBUG_MODE=coverage | ||
|
||
# Install PDO MySQL driver. | ||
RUN docker-php-ext-install \ | ||
pdo_mysql | ||
|
||
ENV WP_ROOT_FOLDER="/var/www/html" | ||
ENV WORDPRESS_DB_HOST=${TEST_SITE_DB_HOST} | ||
ENV WORDPRESS_DB_PORT=${TEST_SITE_DB_PORT} | ||
ENV WORDPRESS_DB_USER=${TEST_SITE_DB_USER} | ||
ENV WORDPRESS_DB_PASSWORD=${TEST_SITE_DB_PASSWORD} | ||
ENV WORDPRESS_DB_NAME=${TEST_SITE_DB_NAME} | ||
ENV PLUGINS_DIR="${WP_ROOT_FOLDER}/wp-content/plugins" | ||
ENV PROJECT_DIR="${PLUGINS_DIR}/wp-graphql-testcase" | ||
|
||
WORKDIR $PROJECT_DIR | ||
|
||
# Set up Apache | ||
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf | ||
RUN a2enmod rewrite | ||
|
||
ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /usr/local/bin/wait-for-it | ||
RUN chmod 755 /usr/local/bin/wait-for-it | ||
|
||
ADD https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar /usr/local/bin/wp | ||
RUN chmod 755 /usr/local/bin/wp | ||
|
||
# Remove exec statement from base entrypoint script. | ||
RUN sed -i '$d' /usr/local/bin/docker-entrypoint.sh | ||
|
||
# Set up entrypoint | ||
COPY entrypoint.sh /usr/local/bin/app-entrypoint.sh | ||
RUN chmod 755 /usr/local/bin/app-entrypoint.sh | ||
ENTRYPOINT ["app-entrypoint.sh"] | ||
CMD ["apache2-foreground"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
|
||
|
||
work_dir=$(pwd) | ||
|
||
cd "${WP_ROOT_FOLDER}" || exit | ||
|
||
# Run WordPress docker entrypoint. | ||
# shellcheck disable=SC1091 | ||
. docker-entrypoint.sh 'apache2' | ||
|
||
set +u | ||
|
||
# Ensure mysql is loaded | ||
wait-for-it -s -t 300 "${TEST_SITE_DB_HOST}:${TEST_SITE_DB_PORT:-3306}" -- echo "Application database is operationally..." | ||
|
||
if [ -f "${WP_ROOT_FOLDER}/wp-config.php" ]; then | ||
echo "Deleting old wp-config.php" | ||
rm -rf "${WP_ROOT_FOLDER}/wp-config.php" | ||
fi | ||
|
||
echo "Creating wp-config.php..." | ||
wp config create \ | ||
--path="${WP_ROOT_FOLDER}" \ | ||
--dbname="${TEST_SITE_DB_NAME}" \ | ||
--dbuser="${TEST_SITE_DB_USER}" \ | ||
--dbpass="${TEST_SITE_DB_PASSWORD}" \ | ||
--dbhost="${TEST_SITE_DB_HOST}" \ | ||
--dbprefix="${TEST_TABLE_PREFIX}" \ | ||
--skip-check \ | ||
--quiet \ | ||
--allow-root | ||
|
||
# Install WP if not yet installed | ||
echo "Installing WordPress..." | ||
wp core install \ | ||
--path="${WP_ROOT_FOLDER}" \ | ||
--url="${TEST_SITE_WP_URL}" \ | ||
--title='Test' \ | ||
--admin_user="${TEST_SITE_ADMIN_USERNAME}" \ | ||
--admin_password="${TEST_SITE_ADMIN_PASSWORD}" \ | ||
--admin_email="${TEST_SITE_ADMIN_EMAIL}" \ | ||
--allow-root | ||
|
||
wp plugin activate wp-graphql --allow-root | ||
|
||
if [ -f "${PROJECT_DIR}/tests/codeception/_data/dump.sql" ]; then | ||
rm -rf "${PROJECT_DIR}/tests/codeception/_data/dump.sql" | ||
fi | ||
|
||
wp user application-password delete 1 --all --allow-root | ||
|
||
app_user="admin" | ||
app_password=$(wp user application-password create 1 testing --porcelain --allow-root) | ||
|
||
echo "Creating .env.docker file..." | ||
echo TEST_SITE_ADMIN_APP_PASSWORD="$(echo -n "${app_user}:${app_password}" | base64)" > "$PROJECT_DIR/.env.docker" | ||
echo TEST_SITE_WP_DOMAIN="${TEST_SITE_WP_DOMAIN}" >> "$PROJECT_DIR/.env.docker" | ||
echo TEST_SITE_WP_URL="${TEST_SITE_WP_URL}" >> "$PROJECT_DIR/.env.docker" | ||
|
||
echo "Dumping app database..." | ||
wp db export "${PROJECT_DIR}/tests/codeception/_data/dump.sql" \ | ||
--dbuser="${TEST_SITE_DB_USER}" \ | ||
--dbpass="${TEST_SITE_DB_PASSWORD}" \ | ||
--skip-plugins \ | ||
--skip-themes \ | ||
--allow-root | ||
|
||
wp config set WP_SITEURL "${TEST_SITE_WP_URL}" --allow-root | ||
wp config set WP_HOME "${TEST_SITE_WP_URL}" --allow-root | ||
|
||
echo "Setting pretty permalinks..." | ||
wp rewrite structure '/%year%/%monthnum%/%postname%/' --allow-root | ||
|
||
service apache2 start | ||
|
||
echo "Running WordPress version: $(wp core version --allow-root) at $(wp option get home --allow-root)" | ||
|
||
cd "${work_dir}" || exit | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.