From 129eec6baa241ab33891d41ec26ff4b41edb8466 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Wed, 12 Mar 2025 18:14:01 +0100 Subject: [PATCH] Rename e2e to integration --- .env.integration | 40 +++++++++++++++++++ .env.e2e.example => .env.integration.example | 2 +- .../workflows/{e2e.yml => integration.yml} | 8 ++-- composer.json | 2 +- tests/e2e/PHPUnit/bootstrap.php | 23 ----------- .../PHPUnit/Order/PurchaseUnitTest.php | 4 +- .../PHPUnit/OrdersTest.php | 2 +- .../PayPalSubscriptionsRenewalTest.php | 2 +- .../PHPUnit/RealTimeAccountUpdaterTest.php | 2 +- .../PHPUnit/SettingsTest.php | 2 +- .../{e2e => integration}/PHPUnit/TestCase.php | 2 +- .../PHPUnit/Validation/ValidationTest.php | 4 +- tests/integration/PHPUnit/bootstrap.php | 23 +++++++++++ tests/{e2e => integration}/PHPUnit/setup.php | 2 +- tests/{e2e => integration}/data/tax_rates.csv | 0 tests/{e2e => integration}/phpunit.xml.dist | 0 16 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 .env.integration rename .env.e2e.example => .env.integration.example (93%) rename .github/workflows/{e2e.yml => integration.yml} (78%) delete mode 100644 tests/e2e/PHPUnit/bootstrap.php rename tests/{e2e => integration}/PHPUnit/Order/PurchaseUnitTest.php (98%) rename tests/{e2e => integration}/PHPUnit/OrdersTest.php (94%) rename tests/{e2e => integration}/PHPUnit/PayPalSubscriptionsRenewalTest.php (97%) rename tests/{e2e => integration}/PHPUnit/RealTimeAccountUpdaterTest.php (96%) rename tests/{e2e => integration}/PHPUnit/SettingsTest.php (97%) rename tests/{e2e => integration}/PHPUnit/TestCase.php (90%) rename tests/{e2e => integration}/PHPUnit/Validation/ValidationTest.php (92%) create mode 100644 tests/integration/PHPUnit/bootstrap.php rename tests/{e2e => integration}/PHPUnit/setup.php (93%) rename tests/{e2e => integration}/data/tax_rates.csv (100%) rename tests/{e2e => integration}/phpunit.xml.dist (100%) diff --git a/.env.integration b/.env.integration new file mode 100644 index 000000000..8ed93a99d --- /dev/null +++ b/.env.integration @@ -0,0 +1,40 @@ +PPCP_INTEGRATION_WP_DIR=${ROOT_DIR}/.ddev/wordpress + +BASEURL="https://woocommerce-paypal-payments.ddev.site" +AUTHORIZATION="Bearer ABC123" + +CHECKOUT_URL="/checkout" +CHECKOUT_PAGE_ID=7 +CART_URL="/cart" +BLOCK_CHECKOUT_URL="/checkout-block" +BLOCK_CHECKOUT_PAGE_ID=22 +BLOCK_CART_URL="/cart-block" + +PRODUCT_URL="/product/prod" +PRODUCT_ID=123 + +SUBSCRIPTION_URL="/product/sub" + +PAYPAL_SUBSCRIPTIONS_PRODUCT_ID=252 + +APM_ID="sofort" + +WP_MERCHANT_USER="admin" +WP_MERCHANT_PASSWORD="admin" + +WP_CUSTOMER_USER="customer" +WP_CUSTOMER_PASSWORD="password" + +CUSTOMER_EMAIL="customer@example.com" +CUSTOMER_PASSWORD="password" +CUSTOMER_FIRST_NAME="John" +CUSTOMER_LAST_NAME="Doe" +CUSTOMER_COUNTRY="DE" +CUSTOMER_ADDRESS="street 1" +CUSTOMER_POSTCODE="12345" +CUSTOMER_CITY="city" +CUSTOMER_PHONE="1234567890" + +CREDIT_CARD_NUMBER="1234567890" +CREDIT_CARD_EXPIRATION="01/2042" +CREDIT_CARD_CVV="123" diff --git a/.env.e2e.example b/.env.integration.example similarity index 93% rename from .env.e2e.example rename to .env.integration.example index 98ad27c23..d4d541f6a 100644 --- a/.env.e2e.example +++ b/.env.integration.example @@ -1,4 +1,4 @@ -PPCP_E2E_WP_DIR=${ROOT_DIR}/.ddev/wordpress +PPCP_INTEGRATION_WP_DIR=${ROOT_DIR}/.ddev/wordpress BASEURL="https://woocommerce-paypal-payments.ddev.site" AUTHORIZATION="Bearer ABC123" diff --git a/.github/workflows/e2e.yml b/.github/workflows/integration.yml similarity index 78% rename from .github/workflows/e2e.yml rename to .github/workflows/integration.yml index 71b4cb8ae..716a4a0b7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/integration.yml @@ -1,4 +1,4 @@ -name: e2e tests +name: Integration tests on: workflow_dispatch @@ -30,10 +30,10 @@ jobs: run: ddev orchestrate -f - name: Create config - run: cp -n .env.e2e.example .env.e2e + run: cp -n .env.integration.example .env.integration - name: Setup tests - run: ddev php tests/e2e/PHPUnit/setup.php + run: ddev php tests/integration/PHPUnit/setup.php - name: Run PHPUnit - run: ddev exec phpunit -c tests/e2e/phpunit.xml.dist + run: ddev exec phpunit -c tests/integration/phpunit.xml.dist diff --git a/composer.json b/composer.json index 17ecd3eda..8443e53f1 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "autoload-dev": { "psr-4": { "WooCommerce\\PayPalCommerce\\": "tests/PHPUnit/", - "WooCommerce\\PayPalCommerce\\Tests\\E2e\\": "tests/e2e/PHPUnit/" + "WooCommerce\\PayPalCommerce\\Tests\\Integration\\": "tests/integration/PHPUnit/" } }, "minimum-stability": "dev", diff --git a/tests/e2e/PHPUnit/bootstrap.php b/tests/e2e/PHPUnit/bootstrap.php deleted file mode 100644 index 506b55676..000000000 --- a/tests/e2e/PHPUnit/bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -load(); -} - -if (!isset($_ENV['PPCP_E2E_WP_DIR'])) { - exit('Copy .env.e2e.example to .env.e2e or define the environment variables.' . PHP_EOL); -} -$wpRootDir = str_replace('${ROOT_DIR}', ROOT_DIR, $_ENV['PPCP_E2E_WP_DIR']); - -define('WP_ROOT_DIR', $wpRootDir); - -$_SERVER['HTTP_HOST'] = ''; // just to avoid a warning - -require_once WP_ROOT_DIR . '/wp-load.php'; diff --git a/tests/e2e/PHPUnit/Order/PurchaseUnitTest.php b/tests/integration/PHPUnit/Order/PurchaseUnitTest.php similarity index 98% rename from tests/e2e/PHPUnit/Order/PurchaseUnitTest.php rename to tests/integration/PHPUnit/Order/PurchaseUnitTest.php index 6a72c4255..80f44e409 100644 --- a/tests/e2e/PHPUnit/Order/PurchaseUnitTest.php +++ b/tests/integration/PHPUnit/Order/PurchaseUnitTest.php @@ -1,7 +1,7 @@ load(); +} + +if (!isset($_ENV['PPCP_INTEGRATION_WP_DIR'])) { + exit('Copy .env.integration.example to .env.integration or define the environment variables.' . PHP_EOL); +} +$wpRootDir = str_replace('${ROOT_DIR}', ROOT_DIR, $_ENV['PPCP_INTEGRATION_WP_DIR']); + +define('WP_ROOT_DIR', $wpRootDir); + +$_SERVER['HTTP_HOST'] = ''; // just to avoid a warning + +require_once WP_ROOT_DIR . '/wp-load.php'; diff --git a/tests/e2e/PHPUnit/setup.php b/tests/integration/PHPUnit/setup.php similarity index 93% rename from tests/e2e/PHPUnit/setup.php rename to tests/integration/PHPUnit/setup.php index b727f83b8..042d41ca4 100644 --- a/tests/e2e/PHPUnit/setup.php +++ b/tests/integration/PHPUnit/setup.php @@ -32,6 +32,6 @@ require WP_ROOT_DIR . '/wp-admin/includes/class-wp-importer.php'; require WP_ROOT_DIR . '/wp-content/plugins/woocommerce/includes/admin/importers/class-wc-tax-rate-importer.php'; $taxImporter = new WC_Tax_Rate_Importer(); -$taxImporter->import(E2E_TESTS_ROOT_DIR . '/data/tax_rates.csv'); +$taxImporter->import(INTEGRATION_TESTS_ROOT_DIR . '/data/tax_rates.csv'); echo PHP_EOL; diff --git a/tests/e2e/data/tax_rates.csv b/tests/integration/data/tax_rates.csv similarity index 100% rename from tests/e2e/data/tax_rates.csv rename to tests/integration/data/tax_rates.csv diff --git a/tests/e2e/phpunit.xml.dist b/tests/integration/phpunit.xml.dist similarity index 100% rename from tests/e2e/phpunit.xml.dist rename to tests/integration/phpunit.xml.dist