Skip to content

Commit

Permalink
Merge pull request #696 from godaddy-wordpress/mwc-17264/t-c-checkout…
Browse files Browse the repository at this point in the history
…-page

Set the payment form context in the session
  • Loading branch information
nmolham-godaddy authored Aug 21, 2024
2 parents 4894dd8 + 8cbb255 commit 54e2799
Show file tree
Hide file tree
Showing 19 changed files with 1,082 additions and 328 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
workflow_dispatch: # Can manually run from any branch
push:
branches:
- main
pull_request:

# Cancel previous jobs before starting this one. Works on pull_request event only due to use of head_ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
php-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- php: '8.3'
os: 'ubuntu-24.04'
- php: '8.2'
os: 'ubuntu-20.04'
- php: '8.1'
os: 'ubuntu-latest'
- php: '8.0'
os: 'ubuntu-20.04'
- php: '7.4'
os: 'ubuntu-20.04'
fail-fast: false
env:
COVERAGE_CACHE_PATH: phpunit-coverage-cache
PHP_VERSION: ${{ matrix.php }}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Switch to PHP ${{ env.PHP_VERSION }}
run: |
sudo update-alternatives --set php /usr/bin/php$PHP_VERSION
sudo update-alternatives --set phar /usr/bin/phar$PHP_VERSION
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$PHP_VERSION
sudo update-alternatives --set phpize /usr/bin/phpize$PHP_VERSION
sudo update-alternatives --set php-config /usr/bin/php-config$PHP_VERSION
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: |
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Check platform requirements on PHP ${{ env.PHP_VERSION }}
run: |
composer check-platform-reqs --no-dev --no-interaction --no-scripts
- name: Execute tests via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: |
vendor/bin/phpunit --order-by="random" --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ npm-debug.log
codeception.yml
.env
/tests/_data/dump.sql
.phpunit.cache/
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@
"phpcompatibility/php-compatibility": "9.3.5",
"codeception/module-db": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-asserts": "^1.3"
"codeception/module-asserts": "^1.3",
"10up/wp_mock": "^1.0"
},
"autoload-dev": {
"psr-4": {
"SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Tests\\": "tests/"
}
},
"config": {
"platform": {
"php": "7.4"
},
"allow-plugins": {
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
190 changes: 189 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/unit</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
disableCodeCoverageIgnore="true"
includeUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true"
processUncoveredFiles="false">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Tests;

use WP_Mock\Tools\TestCase as WpMockTestCase;

class TestCase extends WpMockTestCase
{
}
16 changes: 16 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

const ABSPATH = 'foo/bar';

define('PLUGIN_ROOT_DIR', dirname(__DIR__));

require_once PLUGIN_ROOT_DIR.'/vendor/autoload.php';
require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin.php';
require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php';
require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php';
require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php';

WP_Mock::setUsePatchwork(true);
WP_Mock::bootstrap();

require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-helper.php';
Loading

0 comments on commit 54e2799

Please sign in to comment.