Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Add the Give donation plugin #115

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
b9fd01e
Install the give and gutenberg plugins
ataylorme Oct 2, 2018
93a4b15
Add file to run Behat locally
ataylorme Oct 2, 2018
fc43350
Update site name and description to be more Give and Behat oriented
ataylorme Oct 2, 2018
df8d362
Run the local Behat script straight from Lando
ataylorme Oct 2, 2018
067e42f
Audit vulnerabilities
ataylorme Oct 2, 2018
8ef9617
Remove featured image banner on pages and give forms
ataylorme Oct 2, 2018
7fab7f5
Add code sniffing and unit-testing to Lando
ataylorme Oct 2, 2018
a815b36
Correct code sniff violations
ataylorme Oct 3, 2018
0822f5f
Export and restore the DB before/after Behat tests
ataylorme Oct 3, 2018
658a51d
Don't ignore lh-hsts in code sniffing
ataylorme Oct 3, 2018
5edc6e4
Command updates
ataylorme Oct 3, 2018
c87559b
Don't code sniff and unit test on asset build
ataylorme Oct 3, 2018
fd44ebf
Delete extra newline
ataylorme Oct 3, 2018
f6054cb
Correct bash formatting
ataylorme Oct 3, 2018
be7296c
Store WordHat command list
ataylorme Oct 3, 2018
8182b4a
Remove documentation coming
ataylorme Oct 3, 2018
4323dc8
First pass at Give tests with custom steps
ataylorme Oct 3, 2018
815c245
Add script for behat locally w/ headless chrome
ataylorme Oct 4, 2018
c1706ed
Update Give test steps
ataylorme Oct 4, 2018
130ddbc
Swap the Selenium2 driver for headless Chrome
ataylorme Oct 4, 2018
7129d19
Run Behat tests with headless Chrome
ataylorme Oct 4, 2018
987b85e
Use a custom Docker image with headless Chrome
ataylorme Oct 4, 2018
f328318
headless Chrome
ataylorme Oct 4, 2018
f43e6f3
More custom steps and debugging
ataylorme Oct 4, 2018
e637a3b
Give should already be active
ataylorme Oct 4, 2018
7e0654a
Don't run scripts with sh
ataylorme Oct 4, 2018
1bff689
echo -e to get newlines to print
ataylorme Oct 4, 2018
908e3fb
Remove non Give tests
ataylorme Oct 4, 2018
134ecbc
Cleanup Give test and custom steps
ataylorme Oct 4, 2018
de7d24a
Simplify step declarations
ataylorme Oct 4, 2018
671de18
Move debugging snippet to README
ataylorme Oct 4, 2018
acb9c74
Test changing the default donation amount
ataylorme Oct 5, 2018
b7b867d
Make the Give steps more human readable
ataylorme Oct 5, 2018
b7f9119
Update function name
ataylorme Oct 8, 2018
6999ae2
Move DB import and export to separate files
ataylorme Oct 22, 2018
9900d1b
Update dependencies
ataylorme Oct 22, 2018
b962fec
Move DB import and export to separate scripts
ataylorme Oct 22, 2018
985261b
Add test for front-end form submission
ataylorme Oct 24, 2018
5d5ab4a
Add custom give donation form step
ataylorme Oct 24, 2018
afa24c0
Add steps for front-end Give form fields
ataylorme Oct 24, 2018
5697503
Split admin and front-end tests
ataylorme Oct 24, 2018
89c24c6
Confirm donation post exists
ataylorme Oct 24, 2018
9b0c23b
Ignore sticky posts
ataylorme Oct 25, 2018
be494b8
Add a context for editing the latest post of a specific type and status
ataylorme Oct 25, 2018
343ffd4
Update the Give plugin to version 2.3.0
ataylorme Oct 25, 2018
e9a6506
Update the Gutenberg plugin to version 4.1.0
ataylorme Oct 25, 2018
ed104b2
Remove paths from local Behat output
ataylorme Oct 25, 2018
43f9500
Upgrade Gutenberg to 4.1.1
ataylorme Oct 27, 2018
b5ad71a
Code sniff tests
ataylorme Nov 6, 2018
49933fb
Update secret set
ataylorme Nov 28, 2018
9aa781a
WordPress 5.0.2 and twentynineteen theme
ataylorme Dec 21, 2018
7ab7bcb
Custom Pantheon context
Feb 26, 2019
81e0274
Update WordPress DB after deployment
Feb 26, 2019
be82c69
Check for latests articles on /blog
Feb 26, 2019
80dbb9e
Header updates
Feb 26, 2019
101b9bd
Always run Behat cleanup
Feb 26, 2019
e9f30bd
Don't need to deactivate lh-hsts
Feb 26, 2019
20af36d
WordHat in Lando appserver
Feb 26, 2019
d2479e4
WordHat 3.1.1
Feb 26, 2019
69ef555
Better local Behat w/ Lando appserver
Feb 27, 2019
589467e
Separate service for PHP CI tasks
Feb 27, 2019
ad265e1
Add give_wp tag to give tests
Feb 27, 2019
5c92c0f
Remove CSS selector
ataylorme Mar 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/behat-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ terminus -n env:wake $TERMINUS_SITE.$TERMINUS_ENV
# Ping wp-cli to start ssh with the app server
terminus -n wp $TERMINUS_SITE.$TERMINUS_ENV -- cli version

# Start headless Chrome
echo "\n Starting Chrome in headless mode ..."
google-chrome-unstable --disable-gpu --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --no-sandbox </dev/null &>/dev/null &

# Run the Behat tests
./vendor/bin/behat --config=tests/behat/behat-pantheon.yml --strict "$@"

Expand Down
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ jobs:

behat_test:
<<: *defaults
docker:
- image: ataylorme/docker-php-advanced-wordpress-on-pantheon:headless-chrome
steps:
- checkout

Expand Down
27 changes: 23 additions & 4 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ services:
# use a custom Docker image
image: ataylorme/docker-node-advanced-wordpress-on-pantheon:latest

# Use a custom appserver with headless Chrome
appserver:
type: php:custom
overrides:
services:
image: ataylorme/docker-php-advanced-wordpress-on-pantheon:headless-chrome-lando

# Additional "lando" commands
tooling:
npm:
Expand All @@ -53,18 +60,30 @@ tooling:
description: Install npm dependencies and run gulp
cmd: ./.circleci/build-gulp-assets.sh
service: node
code-sniff:
description: Run Code Sniffing
cmd: ./vendor/bin/phpcs --extensions=php --runtime-set ignore_warnings_on_exit true ./web/wp-content/themes/twentyseventeen-child/*
service: appserver
code-sniff-fix:
description: Fix Code Sniffing
cmd: ./vendor/bin/phpcbf --ignore=*/.git*/*,*/node_modules/* --extensions=php ./web/wp-content/themes/twentyseventeen-child/*
service: appserver
unit-test:
description: Run unit tests
cmd: composer -n unit-test
service: appserver
wordhat:
description: Run WordHat
cmd: ./vendor/bin/behat --config=tests/behat/behat-lando.yml --strict
cmd: ./bin/local-behat-headless-chrome.sh
service: appserver
wordhat-commands:
description: List WordHat commands
cmd: ./vendor/bin/behat -dl --config=tests/behat/behat-lando.yml --strict
cmd: composer -n wordhat-scenarios
service: appserver

# Automate build steps after every start
# Automate startup tasks
#events:
# post-start:
#post-start:
# # Run gulp every time node is started
# - node: "cd $LANDO_MOUNT && ./.circleci/build-gulp-assets.sh"
# # Run composer every time appserver is started
Expand Down
2 changes: 1 addition & 1 deletion bin/install-composer-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ fi
# Remove wp-content and wp-config from wp subdirectory
echo -e "\nRemoving wp-content and wp-config from wp subdirectory"
[ -f 'web/wp/wp-config.php' ] && rm -rf ./web/wp/wp-config.php
[ -d 'web/wp/wp-content' ] && rm -rf ./web/wp/wp-content
[ -d 'web/wp/wp-content' ] && rm -rf ./web/wp/wp-content
81 changes: 81 additions & 0 deletions bin/local-behat-headless-chrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# Start headless Chrome if needed
if [[ $(jobs | grep chrome) ]]
then
jobs | grep chrome
echo -e "\n Headless Chrome is already running ..."
else
echo -e "\n Starting Chrome in headless mode ..."
google-chrome-unstable --disable-gpu --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --no-sandbox </dev/null &>/dev/null &
jobs | grep chrome
echo -e "\n Chrome started in headless mode ..."
fi

# Stash DB credentials
DB_USER=pantheon
DB_PASSWORD=pantheon
DB_HOST=database
DB_PORT=3306
DB_NAME=pantheon
DB_FILE_NAME="pre-behat-tests"

# Export the DB

# Remove old DB export files if they exists
if [ -f $DB_FILE_NAME.sql ]
then
rm $DB_FILE_NAME.sql
fi

if [ -f $DB_FILE_NAME.sql.gz ]
then
rm $DB_FILE_NAME.sql.gz
fi

# Dump the current DB
echo -e "\nExporting the $DB_NAME database to $DB_FILE_NAME.sql ..."
mysqldump --opt --user=$DB_USER --host=$DB_HOST --port=$DB_PORT --password=$DB_PASSWORD $DB_NAME > $DB_FILE_NAME.sql

# gzip the backup file
echo -e "\nGzipping $DB_FILE_NAME.sql ..."
gzip $DB_FILE_NAME.sql

# Create the WordPress admin user
echo -e "\nCreating the WordPress admin user ..."
wp user create admin no-reply@pantheon.io --user_pass=admin --role=administrator

# Disable the lh-hsts plugin as it causes a redirect loop
echo -e "\nDeactivating the lh-hsts plugin ..."
wp plugin deactivate lh-hsts

# Run WordHat
./vendor/bin/behat --config=tests/behat/behat-lando.yml --strict

# Restore the DB

# Un-gzip the backup
gunzip $DB_FILE_NAME.sql.gz

# Build the SQL prefix
SQLSTART="mysql --user=$DB_USER --host=$DB_HOST --port=$DB_PORT --password=$DB_PASSWORD $DB_NAME"

# Get all the tables
DB_TABLES=$($SQLSTART -e 'SHOW TABLES' | awk '{ print $1}' | grep -v '^Tables' )

# Drop each tables
echo -e "\nDropping all the tables in the $DB_NAME database..."
for DB_TABLE in $DB_TABLES; do
$SQLSTART -e "DROP TABLE $DB_TABLE"
done

# Import the DB
echo -e "\nImporting the $DB_NAME database..."
cat $DB_FILE_NAME.sql | $SQLSTART

# Remove the DB export file
echo -e "\nCleaning up the leftover $DB_FILE_NAME.sql ..."
if [ -f $DB_FILE_NAME.sql ]
then
rm $DB_FILE_NAME.sql
fi
68 changes: 68 additions & 0 deletions bin/local-behat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Stash DB credentials
DB_USER=pantheon
DB_PASSWORD=pantheon
DB_HOST=database
DB_PORT=3306
DB_NAME=pantheon
DB_FILE_NAME="pre-behat-tests"

# Export the DB

# Remove old DB export files if they exists
if [ -f $DB_FILE_NAME.sql ]
then
rm $DB_FILE_NAME.sql
fi

if [ -f $DB_FILE_NAME.sql.gz ]
then
rm $DB_FILE_NAME.sql.gz
fi

# Dump the current DB
echo "\nExporting the $DB_NAME database to $DB_FILE_NAME.sql ..."
mysqldump --opt --user=$DB_USER --host=$DB_HOST --port=$DB_PORT --password=$DB_PASSWORD $DB_NAME > $DB_FILE_NAME.sql

# gzip the backup file
echo "\nGzipping $DB_FILE_NAME.sql ..."
gzip $DB_FILE_NAME.sql

# Create the WordPress admin user
echo "\nCreating the WordPress admin user ..."
wp user create admin no-reply@pantheon.io --user_pass=admin --role=administrator

# Disable the lh-hsts plugin as it causes a redirect loop
wp plugin deactivate lh-hsts

# Run WordHat
./vendor/bin/behat --config=tests/behat/behat-lando.yml --strict

# Restore the DB

# Un-gzip the backup
gunzip $DB_FILE_NAME.sql.gz

# Build the SQL prefix
SQLSTART="mysql --user=$DB_USER --host=$DB_HOST --port=$DB_PORT --password=$DB_PASSWORD $DB_NAME"

# Get all the tables
DB_TABLES=$($SQLSTART -e 'SHOW TABLES' | awk '{ print $1}' | grep -v '^Tables' )

# Drop each tables
echo "\nDropping all the tables in the $DB_NAME database..."
for DB_TABLE in $DB_TABLES; do
$SQLSTART -e "DROP TABLE $DB_TABLE"
done

# Import the DB
echo "\nImporting the $DB_NAME database..."
cat $DB_FILE_NAME.sql | $SQLSTART

# Remove the DB export file
echo "\nCleaning up the leftover $DB_FILE_NAME.sql ..."
if [ -f $DB_FILE_NAME.sql ]
then
rm $DB_FILE_NAME.sql
fi
9 changes: 1 addition & 8 deletions bin/local-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,4 @@
./bin/install-composer-dependencies.sh

# Build assets with gulp
./.circleci/build-gulp-assets.sh

# Test WordPress coding standards
./vendor/bin/phpcs --config-set installed_paths ./vendor/wp-coding-standards/wpcs
./vendor/bin/phpcs --ignore=*/.git*/*,*/node_modules/* --extensions=php ./web/wp-content/themes/twentyseventeen-child

# Run unit tests
composer -n unit-test
./.circleci/build-gulp-assets.sh
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pantheon-systems/example-wordpress-composer",
"name": "ataylorme/advanced-wordpress-on-pantheon",
"description": "",
"version": "0.1.0",
"type": "project",
Expand All @@ -11,7 +11,7 @@
},
{
"type": "vcs",
"url": "https://github.com/pantheon-systems/wordpress-composer"
"url": "https://github.com/ataylorme/Advanced-WordPress-on-Pantheon"
}
],
"require": {
Expand All @@ -21,16 +21,18 @@
"roots/wp-password-bcrypt": "^1.0.0",
"rvtraveller/qs-composer-installer": "^1.1",
"vlucas/phpdotenv": "2.*",
"wpackagist-plugin/give": "^2.2",
"wpackagist-plugin/gutenberg": "^3.9",
"wpackagist-plugin/lh-hsts": "^1.24",
"wpackagist-plugin/pantheon-advanced-page-cache": "*",
"wpackagist-plugin/wp-native-php-sessions": "0.*",
"wpackagist-theme/twentyseventeen": "1.*"
},
"require-dev": {
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"brain/monkey": "~2.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "~0.4.4",
"dmore/behat-chrome-extension": "^1.2",
"pantheon-systems/quicksilver-pushback": "~1",
"paulgibbs/behat-wordpress-extension": "3.*",
"phpunit/phpunit": "~6.5.4",
Expand Down Expand Up @@ -61,7 +63,8 @@
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
],
"psr-4": { "PantheonSystems\\WordHatHelpers\\": "tests/behat/helper_classes/" }
},
"scripts": {
"build-assets": [
Expand All @@ -85,7 +88,7 @@
"WordPressProject\\composer\\ScriptHandler::createRequiredFiles"
],
"code-sniff": [
"./vendor/bin/phpcs --extensions=php --runtime-set ignore_warnings_on_exit true --ignore=./web/wp-content/plugins/lh-hsts/* ./web/wp-content"
"./vendor/bin/phpcs --extensions=php --runtime-set ignore_warnings_on_exit true ./web/wp-content"
],
"unit-test": [
"./vendor/bin/phpunit tests/unit/*"
Expand Down
Loading