diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 72df2950..6b1f33aa 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -22,12 +22,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4'] - wordpress: ['5.3', '5.0'] + php: ['7.4', '7.3', '7.2', '7.1'] + wordpress: ['5.6', '5.0'] debug: ['--ext DotReporter'] include: - - php: '7.1' - wordpress: '5.0' + - php: '7.4' + wordpress: '5.6' coverage: '--coverage --coverage-xml' - php: '7.3' wordpress: '5.0' @@ -48,6 +48,7 @@ jobs: - name: Install dependencies run: | + echo EMPTY ${{ env.STRIPE_API_PUBLISHABLE_KEY }} cp .env.dist .env SKIP_DB_CREATE=true SKIP_WP_SETUP=true composer require --dev johnpbloch/wordpress:~${{ matrix.wordpress }} composer installTestEnv @@ -59,8 +60,17 @@ jobs: run: FILTER="${{ matrix.coverage }} ${{ matrix.debug }}" composer dRunTestStandalone - name: Push Codecoverage to Coveralls.io - if: ${{ matrix.coverage == 1 && env.STRIPE_API_PUBLISHABLE_KEY != 0 }} + if: ${{ matrix.coverage == '--coverage --coverage-xml' && env.STRIPE_API_PUBLISHABLE_KEY != null }} env: COVERALLS_RUN_LOCALLY: 1 COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: vendor/bin/php-coveralls -v + + - name: Test & publish code coverage + if: ${{ matrix.coverage == '--coverage --coverage-xml' && env.STRIPE_API_PUBLISHABLE_KEY == null }} + uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: 739347fbfc0caa4e7f25069899203df2d4a411b3cbc9c3b1ef28257520c99d31 + with: + coverageLocations: | + ${{github.workspace}}/tests/_output/*.xml:clover diff --git a/README.md b/README.md index 9f354f68..06f4bdd9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ DocsAxisTaylor • Join Slack -[![Automated-Testing](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Automated-Testing/badge.svg)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions?query=workflow%3A%22Automated-Testing%22) [![Coding-Standards](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Coding-Standards/badge.svg)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions?query=workflow%3A%22Coding-Standards%22) [![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop) [![Financial Contributors on Open Collective](https://opencollective.com/woographql/all/badge.svg?label=financial+contributors)](https://opencollective.com/woographql) +[![Automated-Testing](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Automated-Testing/badge.svg?branch=develop)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions?query=workflow%3A%22Automated-Testing%22) [![Coding-Standards](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Coding-Standards/badge.svg?branch=develop)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions?query=workflow%3A%22Coding-Standards%22) [![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop) [![Financial Contributors on Open Collective](https://opencollective.com/woographql/all/badge.svg?label=financial+contributors)](https://opencollective.com/woographql) ## Quick Install diff --git a/access-functions.php b/access-functions.php index 49fe95cb..c31a716a 100644 --- a/access-functions.php +++ b/access-functions.php @@ -156,6 +156,10 @@ function wc_graphql_price( $price, $args = array() ) { * @return string */ function wc_graphql_price_range( $from, $to ) { + if ( $from === $to ) { + return wc_graphql_price( $from ); + } + $price = sprintf( /* translators: 1: price from 2: price to */ _x( '%1$s %2$s %3$s', 'Price range: from-to', 'wp-graphql-woocommerce' ), diff --git a/bin/codecept b/bin/codecept index f9654a53..0e71791c 100644 --- a/bin/codecept +++ b/bin/codecept @@ -20,6 +20,13 @@ if [ 'run' = "$1" ]; then chmod 777 -R ${test_output}/* fi + # Clean coverage.xml and clean up PCOV configurations. + if [ -f "${test_output}/coverage.xml" ]; then + echo 'Cleaning coverage.xml for deployment...' + pattern="$PROJECT_DIR/" + sed -i "s~$pattern~~g" "$test_output"/coverage.xml + fi + # Check results and exit accordingly. if [ -f "$test_output/failed" ]; then echo "Uh oh, some went wrong." >> /dev/stderr diff --git a/docs/package.json b/docs/package.json index fc4c6a9d..e9d6171b 100755 --- a/docs/package.json +++ b/docs/package.json @@ -39,6 +39,7 @@ "graphiql": "^0.17.5", "graphql": "^14.5.8", "is-absolute-url": "^3.0.3", + "isomorphic-fetch": "^3.0.0", "lodash.flatten": "^4.4.0", "lodash.startcase": "^4.4.0", "react": "^16.12.0", diff --git a/includes/model/class-product.php b/includes/model/class-product.php index c99e1af1..01e5bc3b 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -99,27 +99,27 @@ class Product extends WC_Post { if ( empty( $prices['price'] ) || ( 'sale' === $pricing_type && ! $this->wc_data->is_on_sale() ) ) { return null; - } else { - if ( 'regular' === $pricing_type ) { - $min_price = current( $prices['regular_price'] ); - $max_price = end( $prices['regular_price'] ); - } elseif ( 'sale' === $pricing_type ) { - $min_price = current( $prices['sale_price'] ); - $max_price = end( $prices['sale_price'] ); - } else { - $min_price = current( $prices['price'] ); - $max_price = end( $prices['price'] ); - } - - if ( $min_price !== $max_price ) { - wp_send_json( $prices ); - $price = ! $raw ? \wc_graphql_price_range( $min_price, $max_price ) : implode( ', ', $prices["{$pricing_type}_price"] ); - } else { - $price = ! $raw ? \wc_graphql_price( $min_price ) : $min_price; - } } - return apply_filters( 'graphql_get_variation_price', $price, $this ); + switch ( $pricing_type ) { + case 'sale': + $prices = array_values( array_diff( $prices['sale_price'], $prices['regular_price'] ) ); + break; + case 'regular': + $prices = $prices['regular_price']; + break; + default: + $prices = $prices['price']; + break; + } + + sort( $prices, SORT_NUMERIC ); + + if ( $raw ) { + return implode( ', ', $prices['price'] ); + } + + return \wc_graphql_price_range( current( $prices ), end( $prices ) ); } /** @@ -269,7 +269,7 @@ class Product extends WC_Post { if ( apply_filters( "graphql_{$type}_product_model_use_pricing_and_tax_fields", - 'grouped' !== $type + 'grouped' !== $this->wc_data->get_type() ) ) { $fields += array( diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index d9ef1943..3fc60a82 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -24,12 +24,12 @@ class InstalledVersions private static $installed = array ( 'root' => array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', 'aliases' => array ( ), - 'reference' => '2cdd917e80a8fb45fa3bf75eb73fccb4b232fd37', + 'reference' => '6f1105d3c8e1cb8363475e07411b461f151f2a5d', 'name' => 'wp-graphql/wp-graphql-woocommerce', ), 'versions' => @@ -45,12 +45,12 @@ private static $installed = array ( ), 'wp-graphql/wp-graphql-woocommerce' => array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', 'aliases' => array ( ), - 'reference' => '2cdd917e80a8fb45fa3bf75eb73fccb4b232fd37', + 'reference' => '6f1105d3c8e1cb8363475e07411b461f151f2a5d', ), ), ); diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index a4eb4e48..48d28f59 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,12 +1,12 @@ array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', 'aliases' => array ( ), - 'reference' => '2cdd917e80a8fb45fa3bf75eb73fccb4b232fd37', + 'reference' => '6f1105d3c8e1cb8363475e07411b461f151f2a5d', 'name' => 'wp-graphql/wp-graphql-woocommerce', ), 'versions' => @@ -22,12 +22,12 @@ ), 'wp-graphql/wp-graphql-woocommerce' => array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', 'aliases' => array ( ), - 'reference' => '2cdd917e80a8fb45fa3bf75eb73fccb4b232fd37', + 'reference' => '6f1105d3c8e1cb8363475e07411b461f151f2a5d', ), ), );