-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-old-api #49 - use register_graphql_mutation
- Loading branch information
Showing
16 changed files
with
277 additions
and
6,733 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Shared | ||
TEST_DB_NAME="wptests" | ||
TEST_DB_HOST="127.0.0.1" | ||
TEST_DB_USER="root" | ||
TEST_DB_PASSWORD="" | ||
|
||
# Install script | ||
WP_VERSION=latest | ||
SKIP_DB_CREATE=false | ||
|
||
# Codeception | ||
WP_ROOT_FOLDER="/tmp/wp-graphql-jwt-authentication/wordpress" | ||
WP_ADMIN_PATH="/wp-admin" | ||
DB_NAME="wptests" | ||
DB_HOST="127.0.0.1" | ||
DB_USER="root" | ||
DB_PASSWORD="" | ||
WP_TABLE_PREFIX="wp_" | ||
WP_URL="http://wp.test" | ||
WP_DOMAIN="wp.test" | ||
ADMIN_EMAIL="[email protected]" | ||
ADMIN_USERNAME="admin" | ||
ADMIN_PASSWORD="password" |
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 |
---|---|---|
@@ -1,21 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ $# -lt 3 ]; then | ||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]" | ||
source .env | ||
|
||
print_usage_instruction() { | ||
echo "Ensure that .env file exist in project root directory exists." | ||
echo "And run the following 'composer install-wp-tests' in the project root directory" | ||
exit 1 | ||
fi | ||
} | ||
|
||
DB_NAME=$1 | ||
DB_USER=$2 | ||
DB_PASS=$3 | ||
DB_HOST=${4-localhost} | ||
WP_VERSION=${5-latest} | ||
SKIP_DB_CREATE=${6-false} | ||
if [[ -z "$TEST_DB_NAME" ]]; then | ||
echo "TEST_DB_NAME not found" | ||
print_usage_instruction | ||
else | ||
DB_NAME=$TEST_DB_NAME | ||
fi | ||
if [[ -z "$TEST_DB_USER" ]]; then | ||
echo "TEST_DB_USER not found" | ||
print_usage_instruction | ||
else | ||
DB_USER=$TEST_DB_USER | ||
fi | ||
if [[ -z "$TEST_DB_PASSWORD" ]]; then | ||
DB_PASS="" | ||
else | ||
DB_PASS=$TEST_DB_PASSWORD | ||
fi | ||
if [[ -z "$TEST_DB_HOST" ]]; then | ||
DB_HOST=localhost | ||
else | ||
DB_HOST=$TEST_DB_HOST | ||
fi | ||
if [ -z "$SKIP_DB_CREATE" ]; then | ||
SKIP_DB_CREATE=false | ||
fi | ||
|
||
PLUGIN_DIR=$(pwd) | ||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wp-graphql-jwt-authentication} | ||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wp-graphql-jwt-authentication/} | ||
DB_SERVE_NAME=${DB_SERVE_NAME-wpgraphql_jwt_auth_serve} | ||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wp-graphql-jwt-authentication/wordpress-tests-lib} | ||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wp-graphql-jwt-authentication/wordpress/} | ||
|
||
download() { | ||
if [ `which curl` ]; then | ||
|
@@ -93,7 +114,7 @@ install_test_suite() { | |
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/yourusernamehere/$DB_USER/" "$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 | ||
|
||
} | ||
|
@@ -120,43 +141,36 @@ install_db() { | |
fi | ||
fi | ||
|
||
|
||
RESULT=`mysql -u $DB_USER --password="$DB_PASS" --skip-column-names -e "SHOW DATABASES LIKE '$DB_NAME'"` | ||
if [ "$RESULT" != $DB_NAME ]; then | ||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
fi | ||
|
||
RESULT_2=`mysql -u $DB_USER --password="$DB_PASS" --skip-column-names -e "SHOW DATABASES LIKE '$DB_SERVE_NAME'"` | ||
if [ "$RESULT_2" != $DB_SERVE_NAME ]; then | ||
mysqladmin create $DB_SERVE_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
fi | ||
|
||
# create database | ||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
} | ||
|
||
configure_wordpress() { | ||
|
||
cd $WP_CORE_DIR | ||
wp config create --dbname="$DB_SERVE_NAME" --dbuser=root --dbpass="$DB_PASS" --dbhost="$DB_HOST" --skip-check --force=true | ||
wp core install --url=wpgraphql.test --title="WPGraphQL Tests" --admin_user=admin --admin_password=password [email protected] | ||
wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASS" --dbhost="$DB_HOST" --skip-check --force=true | ||
wp core install --url=wpgraphql.test --title="WPGraphQL jwt-authentication Tests" --admin_user=admin --admin_password=password [email protected] | ||
wp rewrite structure '/%year%/%monthnum%/%postname%/' | ||
} | ||
|
||
install_wpgraphql() { | ||
echo "Cloning WPGraphQL" | ||
git clone https://github.com/wp-graphql/wp-graphql.git $WP_CORE_DIR/wp-content/plugins/wp-graphql | ||
if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql ]; then | ||
echo "Cloning WPGraphQL" | ||
git clone https://github.com/wp-graphql/wp-graphql.git $WP_CORE_DIR/wp-content/plugins/wp-graphql | ||
fi | ||
echo "Activating WPGraphQL" | ||
wp plugin activate wp-graphql | ||
} | ||
|
||
activate_plugins() { | ||
|
||
# Add this repo as a plugin to the repo | ||
ln -s $PLUGIN_DIR $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication | ||
if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication ]; then | ||
ln -s $PLUGIN_DIR $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication | ||
fi | ||
|
||
cd $WP_CORE_DIR | ||
|
||
# activate the plugin | ||
wp plugin activate wp-graphql | ||
wp plugin activate wp-graphql-jwt-authentication | ||
|
||
# Flush the permalinks | ||
wp rewrite flush | ||
|
||
|
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,72 @@ | ||
paths: | ||
tests: tests | ||
output: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
envs: tests/_envs | ||
actor_suffix: Tester | ||
settings: | ||
colors: true | ||
memory_limit: 1024M | ||
coverage: | ||
enabled: true | ||
whitelist: | ||
include: | ||
- wp-graphql-acf.php | ||
- access-functions.php | ||
- src/*.php | ||
extensions: | ||
enabled: | ||
- Codeception\Extension\RunFailed | ||
commands: | ||
- Codeception\Command\GenerateWPUnit | ||
- Codeception\Command\GenerateWPRestApi | ||
- Codeception\Command\GenerateWPRestController | ||
- Codeception\Command\GenerateWPRestPostTypeController | ||
- Codeception\Command\GenerateWPAjax | ||
- Codeception\Command\GenerateWPCanonical | ||
- Codeception\Command\GenerateWPXMLRPC | ||
params: | ||
- .env.dist | ||
modules: | ||
config: | ||
WPDb: | ||
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' | ||
user: '%DB_USER%' | ||
password: '%DB_PASSWORD%' | ||
populator: 'mysql -u $user -p$password -h $host $dbname < $dump' | ||
dump: 'tests/_data/dump.sql' | ||
populate: true | ||
cleanup: true | ||
waitlock: 0 | ||
url: '%WP_URL%' | ||
urlReplacement: true | ||
tablePrefix: '%WP_TABLE_PREFIX%' | ||
WPBrowser: | ||
url: '%WP_URL%' | ||
wpRootFolder: '%WP_ROOT_FOLDER%' | ||
adminUsername: '%ADMIN_USERNAME%' | ||
adminPassword: '%ADMIN_PASSWORD%' | ||
adminPath: '/wp-admin' | ||
REST: | ||
depends: WPBrowser | ||
url: '%WP_URL%' | ||
WPFilesystem: | ||
wpRootFolder: '%WP_ROOT_FOLDER%' | ||
plugins: '/wp-content/plugins' | ||
mu-plugins: '/wp-content/mu-plugins' | ||
themes: '/wp-content/themes' | ||
uploads: '/wp-content/uploads' | ||
WPLoader: | ||
wpRootFolder: '%WP_ROOT_FOLDER%' | ||
dbName: '%DB_NAME%' | ||
dbHost: '%DB_HOST%' | ||
dbUser: '%DB_USER%' | ||
dbPassword: '%DB_PASSWORD%' | ||
tablePrefix: '%WP_TABLE_PREFIX%' | ||
domain: '%WP_DOMAIN%' | ||
adminEmail: '%ADMIN_EMAIL%' | ||
title: 'Test' | ||
plugins: ['wp-graphql/wp-graphql.php', 'wp-graphql/wp-graphql-jwt-authentication.php'] | ||
activatePlugins: ['wp-graphql/wp-graphql.php', 'wp-graphql/wp-graphql-jwt-authentication.php', ] | ||
configFile: 'tests/_data/config.php' |
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
Oops, something went wrong.