Skip to content

Commit 6ac72bc

Browse files
committed
tests updated.
1 parent a4f2769 commit 6ac72bc

File tree

9 files changed

+41
-61
lines changed

9 files changed

+41
-61
lines changed

.github/workflows/testing-integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
5656
COVERAGE: ${{ matrix.coverage }}
5757
DEBUG: ${{ matrix.debug }}
58+
SKIP_TESTS_CLEANUP: ${{ matrix.coverage }}
5859
run: bin/run-docker.sh run -t
5960

6061
- name: Push Codecoverage to Coveralls.io

bin/run-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ case "$subcommand" in
4343
-e SUITES=${SUITES-} \
4444
-e COVERAGE=${COVERAGE-} \
4545
-e DEBUG=${DEBUG-} \
46-
-e SKIP_TESTS_CLEANUP=${COVERAGE-} \
46+
-e SKIP_TESTS_CLEANUP=${SKIP_TESTS_CLEANUP-} \
4747
testing --scale app=0
4848
;;
4949
\? ) echo "Usage: $0 run [-a|-t]";;

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ services:
4444
# Volumes for local in-depth development only
4545
# Clone the WooCommerce & WPGraphQL repositories into the same directory
4646
# as this WooGraphQL repository
47-
# - '../woocommerce:/var/www/html/wp-content/plugins/woocommerce'
48-
# - '../wp-graphql:/var/www/html/wp-content/plugins/wp-graphql'
47+
- '../woocommerce:/var/www/html/wp-content/plugins/woocommerce'
48+
- '../wp-graphql:/var/www/html/wp-content/plugins/wp-graphql'
4949
env_file: .env.dist
5050
environment:
5151
XDEBUG_CONFIG: remote_host=host.docker.internal remote_port=9000 remote_enable=1

includes/type/object/class-cart-type.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ public static function register_cart() {
136136
'description' => __( 'Available shipping methods for this order.', 'wp-graphql-woocommerce' ),
137137
'resolve' => function( $source ) {
138138
$packages = array();
139-
140-
foreach ( \WC()->shipping()->calculate_shipping( $source->get_shipping_packages() ) as $index => $package ) {
139+
140+
$shipping_methods = $source->needs_shipping()
141+
? \WC()->shipping()->calculate_shipping( $source->get_shipping_packages() )
142+
: array();
143+
144+
foreach ( $shipping_methods as $index => $package ) {
141145
$package['index'] = $index;
142146
$packages[] = $package;
143147
}

tests/_support/Helper/GraphQLE2E.php

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -756,65 +756,40 @@ function() {
756756
\WC()->cart->add_fee( 'Surcharge', $surcharge, true, '' );
757757
}
758758
);
759-
760-
// Create legacy flat rate shipping method.
761-
update_option(
762-
'woocommerce_flat_rate_settings',
763-
array(
764-
'enabled' => 'yes',
765-
'title' => 'Flat rate',
766-
'availability' => 'all',
767-
'countries' => '',
768-
'tax_status' => 'taxable',
769-
'cost' => '10',
770-
)
771-
);
772-
update_option( 'woocommerce_flat_rate', array() );
773-
774-
// Create legacy free shipping method.
775-
update_option(
776-
'woocommerce_free_shipping_settings',
777-
array(
778-
'enabled' => 'yes',
779-
'title' => 'Free shipping',
780-
'availability' => 'all',
781-
'countries' => '',
782-
)
783-
);
784-
update_option( 'woocommerce_free_shipping', array() );
785-
786-
// Set shipping debug mode
787-
update_option( 'woocommerce_shipping_debug_mode', 'yes' );
788-
789-
// Load shipping methods.
790-
\WC_Cache_Helper::get_transient_version( 'shipping', true );
791-
\WC()->shipping()->load_shipping_methods();
792759

793760
// Create Shipping Zones.
794761
$zone = new \WC_Shipping_Zone();
795762
$zone->set_zone_name( 'Local' );
796763
$zone->set_zone_order( 1 );
797764
$zone->add_location( 'GB', 'country' );
798765
$zone->add_location( 'CB*', 'postcode' );
799-
$zone->save();
766+
$zone->save();
767+
$zone->add_shipping_method( 'flat_rate' );
768+
$zone->add_shipping_method( 'free_shipping' );
800769

801770
$zone = new \WC_Shipping_Zone();
802771
$zone->set_zone_name( 'Europe' );
803772
$zone->set_zone_order( 2 );
804773
$zone->add_location( 'EU', 'continent' );
805-
$zone->save();
774+
$zone->save();
775+
$zone->add_shipping_method( 'flat_rate' );
776+
$zone->add_shipping_method( 'free_shipping' );
806777

807778
$zone = new \WC_Shipping_Zone();
808779
$zone->set_zone_name( 'California' );
809780
$zone->set_zone_order( 3 );
810781
$zone->add_location( 'US:CA', 'state' );
811-
$zone->save();
782+
$zone->save();
783+
$zone->add_shipping_method( 'flat_rate' );
784+
$zone->add_shipping_method( 'free_shipping' );
812785

813786
$zone = new \WC_Shipping_Zone();
814787
$zone->set_zone_name( 'US' );
815788
$zone->set_zone_order( 4 );
816789
$zone->add_location( 'US', 'country' );
817-
$zone->save();
790+
$zone->save();
791+
$zone->add_shipping_method( 'flat_rate' );
792+
$zone->add_shipping_method( 'free_shipping' );
818793
}
819794

820795
/**

tests/functional/QLSessionHandlerCest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,13 @@ public function testCartSessionDataMutations( FunctionalTester $I ) {
510510
'supportsShippingCalculator' => true,
511511
'rates' => array(
512512
array(
513-
'id' => 'legacy_flat_rate',
514-
'cost' => 10.00,
513+
'id' => 'flat_rate:7',
514+
'cost' => '0.00',
515515
'label' => 'Flat rate'
516516
),
517517
array(
518-
'id' => 'legacy_free_shipping',
519-
'cost' => 0,
518+
'id' => 'free_shipping:8',
519+
'cost' => '0.00',
520520
'label' => 'Free shipping'
521521
),
522522
)
@@ -529,7 +529,7 @@ public function testCartSessionDataMutations( FunctionalTester $I ) {
529529
$I->assertEquals( $expected, $actual );
530530

531531
/**
532-
* Update shipping method to 'legacy_flat_rate' shipping.
532+
* Update shipping method to 'flat_rate' shipping.
533533
*/
534534
$mutation = '
535535
mutation ($input: UpdateShippingMethodInput!){
@@ -559,7 +559,7 @@ public function testCartSessionDataMutations( FunctionalTester $I ) {
559559
$mutation,
560560
array(
561561
'clientMutationId' => 'someId',
562-
'shippingMethods' => array( 'legacy_free_shipping' ),
562+
'shippingMethods' => array( 'flat_rate:7' ),
563563
),
564564
array( 'woocommerce-session' => "Session {$session_token}" )
565565
);
@@ -570,6 +570,6 @@ public function testCartSessionDataMutations( FunctionalTester $I ) {
570570
$I->assertNotEmpty( $success['data']['updateShippingMethod']['cart'] );
571571
$cart = $success['data']['updateShippingMethod']['cart'];
572572
$I->assertNotEmpty( $cart['availableShippingMethods'] );
573-
$I->assertEquals( 'legacy_free_shipping', $cart['chosenShippingMethod'] );
573+
$I->assertEquals( 'flat_rate:7', $cart['chosenShippingMethod'] );
574574
}
575575
}

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit9cf37f8331a60b0395d2b6ea64d329f7::getLoader();
7+
return ComposerAutoloaderInit6ecb3b3e822b795cab805ed5884032b2::getLoader();

vendor/composer/autoload_real.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit9cf37f8331a60b0395d2b6ea64d329f7
5+
class ComposerAutoloaderInit6ecb3b3e822b795cab805ed5884032b2
66
{
77
private static $loader;
88

@@ -22,15 +22,15 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInit9cf37f8331a60b0395d2b6ea64d329f7', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInit6ecb3b3e822b795cab805ed5884032b2', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27-
spl_autoload_unregister(array('ComposerAutoloaderInit9cf37f8331a60b0395d2b6ea64d329f7', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInit6ecb3b3e822b795cab805ed5884032b2', 'loadClassLoader'));
2828

2929
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
3030
if ($useStaticLoader) {
3131
require_once __DIR__ . '/autoload_static.php';
3232

33-
call_user_func(\Composer\Autoload\ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7::getInitializer($loader));
33+
call_user_func(\Composer\Autoload\ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2::getInitializer($loader));
3434
} else {
3535
$map = require __DIR__ . '/autoload_namespaces.php';
3636
foreach ($map as $namespace => $path) {
@@ -51,19 +51,19 @@ public static function getLoader()
5151
$loader->register(true);
5252

5353
if ($useStaticLoader) {
54-
$includeFiles = Composer\Autoload\ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7::$files;
54+
$includeFiles = Composer\Autoload\ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2::$files;
5555
} else {
5656
$includeFiles = require __DIR__ . '/autoload_files.php';
5757
}
5858
foreach ($includeFiles as $fileIdentifier => $file) {
59-
composerRequire9cf37f8331a60b0395d2b6ea64d329f7($fileIdentifier, $file);
59+
composerRequire6ecb3b3e822b795cab805ed5884032b2($fileIdentifier, $file);
6060
}
6161

6262
return $loader;
6363
}
6464
}
6565

66-
function composerRequire9cf37f8331a60b0395d2b6ea64d329f7($fileIdentifier, $file)
66+
function composerRequire6ecb3b3e822b795cab805ed5884032b2($fileIdentifier, $file)
6767
{
6868
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
6969
require $file;

vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7
7+
class ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2
88
{
99
public static $files = array (
1010
'944484f100dc1864a5320474d49ebd5a' => __DIR__ . '/../..' . '/includes/connection/wc-cpt-connection-args.php',
@@ -177,9 +177,9 @@ class ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7
177177
public static function getInitializer(ClassLoader $loader)
178178
{
179179
return \Closure::bind(function () use ($loader) {
180-
$loader->prefixLengthsPsr4 = ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7::$prefixLengthsPsr4;
181-
$loader->prefixDirsPsr4 = ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7::$prefixDirsPsr4;
182-
$loader->classMap = ComposerStaticInit9cf37f8331a60b0395d2b6ea64d329f7::$classMap;
180+
$loader->prefixLengthsPsr4 = ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2::$prefixLengthsPsr4;
181+
$loader->prefixDirsPsr4 = ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2::$prefixDirsPsr4;
182+
$loader->classMap = ComposerStaticInit6ecb3b3e822b795cab805ed5884032b2::$classMap;
183183

184184
}, null, ClassLoader::class);
185185
}

0 commit comments

Comments
 (0)