From eb10eadd3b5c8b0af002f9641cc045cda453ae21 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 7 May 2020 15:40:58 -0400 Subject: [PATCH] entrypoint script rebuilt --- .env.dist | 1 - .github/workflows/testing-integration.yml | 2 -- bin/testing-entrypoint.sh | 31 ++++++++++++----------- includes/data/class-factory.php | 31 +++++++++++++---------- tests/_support/Helper/GraphQLE2E.php | 5 +++- tests/functional/QLSessionHandlerCest.php | 2 +- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++----- vendor/composer/autoload_static.php | 8 +++--- 9 files changed, 50 insertions(+), 46 deletions(-) diff --git a/.env.dist b/.env.dist index b584292d..144b9530 100644 --- a/.env.dist +++ b/.env.dist @@ -28,7 +28,6 @@ TESTS_ENVS=tests/_envs CORE_BRANCH=develop JWT_AUTH_BRANCH=develop -SKIP_PCOV_CLOBBER_CLEANUP=true STRIPE_GATEWAY=1 GRAPHQL_JWT_AUTH_SECRET_KEY=testingtesting123 STRIPE_API_PUBLISHABLE_KEY=test_key diff --git a/.github/workflows/testing-integration.yml b/.github/workflows/testing-integration.yml index 86ca3517..e1760bcb 100644 --- a/.github/workflows/testing-integration.yml +++ b/.github/workflows/testing-integration.yml @@ -37,8 +37,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: ${{ github.base_ref }} - name: Install PHP if: matrix.coverage == 1 diff --git a/bin/testing-entrypoint.sh b/bin/testing-entrypoint.sh index 6329f583..84c1c9ca 100644 --- a/bin/testing-entrypoint.sh +++ b/bin/testing-entrypoint.sh @@ -3,10 +3,10 @@ # Processes parameters and runs Codeception. run_tests() { echo "Running Tests" - if [ "$COVERAGE" == "1" ]; then + if [[ -n "$COVERAGE" ]]; then local coverage="--coverage --coverage-xml" fi - if [ "$DEBUG" == "1" ]; then + if [[ -n "$DEBUG" ]]; then local debug="--debug" fi @@ -25,8 +25,8 @@ version_gt() { write_htaccess() { echo " RewriteEngine On +RewriteBase / SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=\$1 -RewriteBase /wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d @@ -70,11 +70,11 @@ fi COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-source --no-interaction # Install pcov/clobber if PHP7.1+ -if version_gt $PHP_VERSION 7.0 && [[ "$COVERAGE" == "1" ]] && [[ -z "$USING_XDEBUG" ]]; then +if version_gt $PHP_VERSION 7.0 && [[ -n "$COVERAGE" ]] && [[ -z "$USING_XDEBUG" ]]; then echo "Installing pcov/clobber" COMPOSER_MEMORY_LIMIT=-1 composer require --dev pcov/clobber vendor/bin/pcov clobber -elif [ "$COVERAGE" == "1" ]; then +elif [[ -n "$COVERAGE" ]]; then echo "Using XDebug for codecoverage" fi @@ -92,28 +92,29 @@ if [ -f "$PROJECT_DIR/c3.php" ] && [ "$SKIP_TESTS_CLEANUP" != "1" ]; then fi # Clean coverage.xml and clean up PCOV configurations. -if [ -f "${TESTS_OUTPUT}/coverage.xml" ] && [[ "$COVERAGE" == "1" ]]; then +if [ -f "${TESTS_OUTPUT}/coverage.xml" ] && [[ -n "$COVERAGE" ]]; then echo 'Cleaning coverage.xml for deployment'. pattern="$PROJECT_DIR/" sed -i "s~$pattern~~g" "$TESTS_OUTPUT"/coverage.xml # Remove pcov/clobber - if version_gt $PHP_VERSION 7.0 && [ "$SKIP_TESTS_CLEANUP" != "1" ] && [[ -z "$USING_XDEBUG" ]]; then + if version_gt $PHP_VERSION 7.0 && [[ -z "$SKIP_TESTS_CLEANUP" ]] && [[ -z "$USING_XDEBUG" ]]; then echo 'Removing pcov/clobber.' vendor/bin/pcov unclobber COMPOSER_MEMORY_LIMIT=-1 composer remove --dev pcov/clobber fi - if [ "$SKIP_TESTS_CLEANUP" != "1" ]; then - echo 'Changing composer configuration in container.' - composer config --global discard-changes true +fi - echo 'Removing devDependencies.' - composer install --no-dev -n +if [[ -z "$SKIP_TESTS_CLEANUP" ]]; then + echo 'Changing composer configuration in container.' + composer config --global discard-changes true - echo 'Removing composer.lock' - rm composer.lock - fi + echo 'Removing devDependencies.' + composer install --no-dev -n + + echo 'Removing composer.lock' + rm composer.lock fi # Set public test result files permissions. diff --git a/includes/data/class-factory.php b/includes/data/class-factory.php index c1e2cf84..a0c1e6ca 100644 --- a/includes/data/class-factory.php +++ b/includes/data/class-factory.php @@ -169,24 +169,27 @@ class Factory { * @return bool True if (re)initialized. */ public static function maybe_initialize_session() { - if ( is_null( WC()->customer ) || get_current_user_id() !== WC()->customer->get_id() ) { - if ( is_null( WC()->session ) ) { - WC()->initialize_session(); - } else { - WC()->session->init(); - } + switch ( true ) { + case is_null( WC()->customer ): + case 0 !== get_current_user_id() && get_current_user_id() !== WC()->customer->get_id(): + if ( is_null( WC()->session ) ) { + WC()->initialize_session(); + } else { + WC()->session->init(); + } - // Set customer and cart to null just to be safe. - WC()->customer = null; - WC()->cart = null; + // Set customer and cart to null just to be safe. + WC()->customer = null; + WC()->cart = null; - // (re)initialize cart. - WC()->initialize_cart(); + // (re)initialize cart. + WC()->initialize_cart(); - return true; + return true; + + default: + return false; } - - return false; } /** diff --git a/tests/_support/Helper/GraphQLE2E.php b/tests/_support/Helper/GraphQLE2E.php index 441b29a1..5adf910b 100644 --- a/tests/_support/Helper/GraphQLE2E.php +++ b/tests/_support/Helper/GraphQLE2E.php @@ -782,7 +782,10 @@ class GraphQLE2E extends \Codeception\Module { ) ); update_option( 'woocommerce_free_shipping', array() ); - + + // Set shipping debug mode + update_option( 'woocommerce_shipping_debug_mode', 'yes' ); + // Load shipping methods. \WC_Cache_Helper::get_transient_version( 'shipping', true ); \WC()->shipping()->load_shipping_methods(); diff --git a/tests/functional/QLSessionHandlerCest.php b/tests/functional/QLSessionHandlerCest.php index 64cdf3cb..d17fe27c 100644 --- a/tests/functional/QLSessionHandlerCest.php +++ b/tests/functional/QLSessionHandlerCest.php @@ -6,7 +6,7 @@ class QLSessionHandlerCest { private $product_catalog; public function _before( FunctionalTester $I ) { - // Create Product + // Create Products $this->product_catalog = $I->getCatalog(); } diff --git a/vendor/autoload.php b/vendor/autoload.php index b9ccba5f..627623fd 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36::getLoader(); +return ComposerAutoloaderInitbc545aa56b49b2e3b9e70cbf9ff0dab5::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index d5ab4357..e7c9ea31 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36 +class ComposerAutoloaderInitbc545aa56b49b2e3b9e70cbf9ff0dab5 { private static $loader; @@ -22,15 +22,15 @@ class ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitbc545aa56b49b2e3b9e70cbf9ff0dab5', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitbc545aa56b49b2e3b9e70cbf9ff0dab5', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita58411fdc8450759ac27db2235cc8f36::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -51,19 +51,19 @@ class ComposerAutoloaderInita58411fdc8450759ac27db2235cc8f36 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInita58411fdc8450759ac27db2235cc8f36::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirea58411fdc8450759ac27db2235cc8f36($fileIdentifier, $file); + composerRequirebc545aa56b49b2e3b9e70cbf9ff0dab5($fileIdentifier, $file); } return $loader; } } -function composerRequirea58411fdc8450759ac27db2235cc8f36($fileIdentifier, $file) +function composerRequirebc545aa56b49b2e3b9e70cbf9ff0dab5($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 6ee711c9..7e8650d8 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita58411fdc8450759ac27db2235cc8f36 +class ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5 { public static $files = array ( '944484f100dc1864a5320474d49ebd5a' => __DIR__ . '/../..' . '/includes/connection/wc-cpt-connection-args.php', @@ -177,9 +177,9 @@ class ComposerStaticInita58411fdc8450759ac27db2235cc8f36 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita58411fdc8450759ac27db2235cc8f36::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita58411fdc8450759ac27db2235cc8f36::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita58411fdc8450759ac27db2235cc8f36::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitbc545aa56b49b2e3b9e70cbf9ff0dab5::$classMap; }, null, ClassLoader::class); }