Skip to content

Commit 73260cd

Browse files
committed
Run WordPress E2E tests with SQLite
1 parent 024a8eb commit 73260cd

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@
4747
],
4848
"wp-test-start": [
4949
"npm --prefix wordpress run env:start",
50-
"npm --prefix wordpress run env:install"
50+
"npm --prefix wordpress run env:install",
51+
"npm --prefix wordpress run env:cli -- plugin install gutenberg",
52+
"npm --prefix wordpress run env:cli -- plugin install query-monitor"
5153
],
5254
"wp-test-php": [
5355
"rm -rf wordpress/src/wp-content/database && npm --prefix wordpress run test:php --"
5456
],
57+
"wp-test-e2e": [
58+
"npm --prefix wordpress run test:e2e --"
59+
],
5560
"wp-test-clean": [
5661
"npm --prefix wordpress run env:clean"
5762
]

integrations/query-monitor/boot.php

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

7070
$query_monitor_active = false;
7171
try {
72+
$show_errors = $wpdb->hide_errors();
73+
7274
$value = $wpdb->get_row(
7375
$wpdb->prepare(
7476
"SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1",
7577
'active_plugins'
7678
)
7779
);
80+
81+
$wpdb->show_errors( $show_errors );
82+
7883
/**
7984
* $value may be null during WordPress Playground multisite setup.
8085
* @see https://github.com/WordPress/sqlite-database-integration/pull/219.

wp-setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ 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

0 commit comments

Comments
 (0)