Skip to content

Commit

Permalink
Merge pull request #337 from kidunot89/feature/some-node-interfaces-s…
Browse files Browse the repository at this point in the history
…upport

Support for some node interfaces added to the product and order models.
  • Loading branch information
kidunot89 authored Oct 3, 2020
2 parents 531fac9 + e708346 commit d063337
Show file tree
Hide file tree
Showing 78 changed files with 2,228 additions and 1,412 deletions.
7 changes: 3 additions & 4 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ TESTS_DATA=tests/_data
TESTS_SUPPORT=tests/_support
TESTS_ENVS=tests/_envs

CORE_BRANCH=master
JWT_AUTH_BRANCH=master
CORE_BRANCH=develop
JWT_AUTH_BRANCH=develop
STRIPE_GATEWAY=1
GRAPHQL_JWT_AUTH_SECRET_KEY=testingtesting123
STRIPE_API_PUBLISHABLE_KEY=test_key
STRIPE_API_SECRET_KEY=test_secret
SKIP_TESTS_CLEANUP=1
8 changes: 2 additions & 6 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ jobs:

- name: Install dependencies
run: |
composer require \
squizlabs/php_codesniffer \
phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
dealerdirect/phpcodesniffer-composer-installer
composer install --no-dev
composer install
- name: Cache dependencies
uses: actions/cache@v1
Expand All @@ -49,4 +45,4 @@ jobs:
restore-keys: ${{ runner.os }}-composer

- name: Run PHP CodeSniffer
run: vendor/bin/phpcs
run: composer lint
8 changes: 5 additions & 3 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs" />
<description>Generally-applicable sniffs for WordPress plugins.</description>

<!-- What to scan -->
Expand All @@ -19,15 +20,16 @@
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->

<!-- Rules: Check PHP version compatibility -->
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.0-"/>
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>

<!-- Rules: WordPress Coding Standards -->
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
<rule ref="WordPress-Extra" />

<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="4.9"/>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
Expand Down
27 changes: 18 additions & 9 deletions bin/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
set -eu

print_usage_instructions() {
echo "Usage: $0 build|run [-a|-t]";
echo "Usage: $0 build|run [-e=env-file ] [-a|-t]";
exit 1
}

if [ -z "$1" ]; then
print_usage_instructions
fi

env_file=".env.dist";

subcommand=$1; shift
case "$subcommand" in
"build" )
Expand All @@ -35,17 +37,24 @@ case "$subcommand" in
--build-arg USE_XDEBUG=${USE_XDEBUG-} \
.
;;
\? ) echo "Usage: $0 build [-a|-t]";;
* ) echo "Usage: $0 build [-a|-t]";;
\? ) print_usage_instructions;;
* ) print_usage_instructions;;
esac
done
shift $((OPTIND -1))
;;
"run" )
while getopts ":at" opt; do
while getopts "e:at" opt; do
case ${opt} in
a ) docker-compose up --scale testing=0 --build;;
e )
env_file=${OPTARG};
if [ ! -f $env_file ]; then
echo "No file found at $env_file"
fi
;;
a ) docker-compose up --scale testing=0;;
t )
source ${env_file}
docker-compose run --rm \
-e STRIPE_API_PUBLISHABLE_KEY=${STRIPE_API_PUBLISHABLE_KEY-} \
-e STRIPE_API_SECRET_KEY=${STRIPE_API_SECRET_KEY-} \
Expand All @@ -55,13 +64,13 @@ case "$subcommand" in
-e SKIP_TESTS_CLEANUP=${SKIP_TESTS_CLEANUP-} \
testing --scale app=0
;;
\? ) echo "Usage: $0 run [-a|-t]";;
* ) echo "Usage: $0 run [-a|-t]";;
\? ) print_usage_instructions;;
* ) print_usage_instructions;;
esac
done
shift $((OPTIND -1))
;;

\? ) echo "Usage: $0 <build|run> [-a|-t]";;
* ) echo "Usage: $0 <build|run> [-a|-t]";;
\? ) print_usage_instructions;;
* ) print_usage_instructions;;
esac
163 changes: 82 additions & 81 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,89 @@
paths:
tests: '%TESTS_DIR%'
output: '%TESTS_OUTPUT%'
data: '%TESTS_DATA%'
support: '%TESTS_SUPPORT%'
envs: '%TESTS_ENVS%'
tests: '%TESTS_DIR%'
output: '%TESTS_OUTPUT%'
data: '%TESTS_DATA%'
support: '%TESTS_SUPPORT%'
envs: '%TESTS_ENVS%'
params:
- env
- .env.dist
- env
- .env.dist
actor_suffix: Tester
settings:
colors: true
memory_limit: 1024M
colors: true
memory_limit: 1024M
coverage:
enabled: true
remote: false
c3_url: '%WP_URL%/wp-content/plugins/wp-graphql-woocommerce/wp-graphql-woocommerce.php'
include:
- includes/*
exclude:
- wp-graphql-woocommerce.php
- access-functions.php
- class-inflect.php
- vendor/*
show_only_summary: false
enabled: true
remote: false
c3_url: '%WP_URL%/wp-content/plugins/wp-graphql-woocommerce/wp-graphql-woocommerce.php'
include:
- includes/*
exclude:
- wp-graphql-woocommerce.php
- access-functions.php
- class-inflect.php
- vendor/*
show_only_summary: false
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
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
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:
- woocommerce/woocommerce.php
- woocommerce-gateway-stripe/woocommerce-gateway-stripe.php
- wp-graphql/wp-graphql.php
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
activatePlugins:
- woocommerce/woocommerce.php
- woocommerce-gateway-stripe/woocommerce-gateway-stripe.php
- wp-graphql/wp-graphql.php
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
configFile: 'tests/_data/config.php'
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: false
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'
cookies: false
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:
- woocommerce/woocommerce.php
- woocommerce-gateway-stripe/woocommerce-gateway-stripe.php
- wp-graphql/wp-graphql.php
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
activatePlugins:
- woocommerce/woocommerce.php
- woocommerce-gateway-stripe/woocommerce-gateway-stripe.php
- wp-graphql/wp-graphql.php
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
configFile: 'tests/_data/config.php'
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"require-dev": {
"lucatume/wp-browser": ">=2.2.1 <2.2.8",
"simpod/php-coveralls-mirror": "^3.0",
"stripe/stripe-php": "^7.28"
"stripe/stripe-php": "^7.28",
"wp-coding-standards/wpcs": "^2.3"
},
"config": {
"optimize-autoloader": true
Expand All @@ -51,10 +52,19 @@
},
"scripts": {
"install-test-env": "bash bin/install-test-env.sh",
"test": "vendor/bin/codecept run",
"functional-test": "vendor/bin/codecept run functional",
"acceptance-test": "vendor/bin/codecept run acceptance",
"wpunit-test": "vendor/bin/codecept run wpunit"
"docker-build": "bash bin/run-docker.sh build",
"docker-run": [
"@docker-build",
"bash bin/run-docker.sh run"
],
"docker-destroy": "docker-compose down",
"local-app": "@docker-run -a",
"local-test": "@docker-run -t",
"test": [
"composer install --no-dev",
"@local-test"
],
"lint": "vendor/bin/phpcs"
},
"support" : {
"issues": "https://github.com/wp-graphql/wp-graphql-woocommerce/issues",
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
ADMIN_PASSWORD: password
INCLUDE_WPGRAPHIQL: 1
IMPORT_WC_PRODUCTS: 1
STRIPE_GATEWAY: 1
ports:
- '8091:80'
networks:
Expand Down
4 changes: 2 additions & 2 deletions docker/testing.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN if [ "$PHP_VERSION" != "5.6" ] && [ "$PHP_VERSION" != "7.0" ] && [[ -z "$USI
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini; \
fi
fi

# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1
Expand All @@ -61,4 +61,4 @@ RUN sed -i '$d' /usr/local/bin/app-entrypoint.sh
WORKDIR /var/www/html/wp-content/plugins/wp-graphql-woocommerce
COPY docker/testing.entrypoint.sh /usr/local/bin/testing-entrypoint.sh
RUN chmod 755 /usr/local/bin/testing-entrypoint.sh
ENTRYPOINT ["testing-entrypoint.sh"]
ENTRYPOINT ["testing-entrypoint.sh"]
4 changes: 2 additions & 2 deletions docker/testing.entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fi
if [ -f "${TESTS_OUTPUT}/failed" ]; then
echo "Uh oh, some went wrong."
exit 1
else
else
echo "Woohoo! It's working!"
exit 0
fi
fi
7 changes: 7 additions & 0 deletions includes/class-core-schema-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public static function add_filters() {
10,
3
);

add_filter(
'graphql_dataloader_pre_get_model',
array( '\WPGraphQL\WooCommerce\Data\Loader\WC_CPT_Loader', 'inject_post_loader_models' ),
10,
3
);
}

/**
Expand Down
Loading

0 comments on commit d063337

Please sign in to comment.