Skip to content

Commit fc17c65

Browse files
committed
Run WordPress E2E tests with SQLite
1 parent ef4a7c7 commit fc17c65

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: WordPress End-to-end Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: WordPress End-to-end Tests
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 20
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Set UID and GID for PHP in WordPress images
23+
run: |
24+
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
25+
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
26+
27+
- name: Setup WordPress test environment
28+
run: composer run wp-setup
29+
30+
- name: Start WordPress test environment
31+
run: composer run wp-test-start
32+
33+
- name: Run WordPress end-to-end tests
34+
run: composer run wp-test-e2e
35+
36+
- name: Stop Docker containers
37+
if: always()
38+
run: composer run wp-test-clean

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
"wp-test-php": [
5353
"rm -rf wordpress/src/wp-content/database && npm --prefix wordpress run test:php --"
5454
],
55+
"wp-test-e2e": [
56+
"npm --prefix wordpress run test:e2e --"
57+
],
5558
"wp-test-clean": [
5659
"npm --prefix wordpress run env:clean"
5760
]

integrations/query-monitor/boot.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@
6969

7070
$query_monitor_active = false;
7171
try {
72+
$show_errors = $wpdb->hide_errors();
7273
$value = $wpdb->get_row(
7374
$wpdb->prepare(
7475
"SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1",
7576
'active_plugins'
7677
)
7778
);
79+
$wpdb->show_errors( $show_errors );
80+
7881
/**
7982
* $value may be null during WordPress Playground multisite setup.
8083
* @see https://github.com/WordPress/sqlite-database-integration/pull/219.

wp-setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ sed -i.bak "s#class WpdbExposedMethodsForTesting extends wpdb {#class WpdbExpose
6565
# 6. Install dependencies.
6666
echo "Installing dependencies..."
6767
npm --prefix "$WP_DIR" install
68+
npm --prefix "$WP_DIR" run build:dev
69+
70+
# 7. Add plugins for E2E tests.
71+
echo "Adding plugins for E2E tests..."
72+
npm --prefix "$WP_DIR" run env:cli -- plugin install gutenberg
73+
npm --prefix "$WP_DIR" run env:cli -- plugin install query-monitor

0 commit comments

Comments
 (0)