test,ci: 建立 phpunit 基建 + 移植 WC 測試 + CI workflow
Tests / PHP Lint (push) Successful in 5s
Tests / Unit Tests (push) Successful in 17s

- composer.json / phpunit.xml / tests/bootstrap.php(比照 HP AddOn,
  直接 require 核心 plugin 的 unit bootstrap)
- tests/unit/WooCommerceIntegrationTest.php(自 A 移植,10 tests)
- .gitea/workflows/test.yml:lint + unit(unit job 會一併 checkout 核心 plugin,
  因為測試 bootstrap 依賴它)

10 tests / 33 assertions GREEN

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
2026-07-31 09:20:07 +08:00
parent 2f9ed57390
commit abe738e900
7 changed files with 926 additions and 58 deletions
+46
View File
@@ -0,0 +1,46 @@
name: Tests
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
jobs:
lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check PHP syntax
run: |
find . -name "*.php" ! -path "./vendor/*" ! -path "./tests/*" -print0 | xargs -0 -n1 php -l
echo "PHP syntax OK"
unit:
name: Unit Tests
runs-on: ubuntu-latest
# The suite boots off the core plugin's test bootstrap, so the core must be
# checked out next to this AddOn under wp-content/plugins/.
steps:
- uses: actions/checkout@v4
with:
path: 2meet-data-optimizer-woocommerce-addon
- name: Checkout core plugin
uses: actions/checkout@v4
with:
repository: wpdev/2meet-data-optimizer
path: 2meet-data-optimizer
- name: Install dependencies
working-directory: 2meet-data-optimizer-woocommerce-addon
run: composer install --no-interaction --prefer-dist
- name: Install core dev dependencies (test bootstrap needs them)
working-directory: 2meet-data-optimizer
run: composer install --no-interaction --prefer-dist
- name: Run unit tests
working-directory: 2meet-data-optimizer-woocommerce-addon
run: php vendor/bin/phpunit --configuration phpunit.xml --testdox