Skip to content

Commit 44adae3

Browse files
authored
Merge pull request #245 from stellarwp/2.2.0
Release 2.2.0
2 parents 34a8b73 + e7342c3 commit 44adae3

29 files changed

Lines changed: 2992 additions & 71 deletions

.env.slic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ CLI_VERBOSITY=0
1616
# This will force the cli tool to use a specific project to run the tests.
1717
# You should use the `use` command usually.
1818
# SLIC_CURRENT_PROJECT=the-events-calendar
19+
# The container path for the current project. This is managed by the `use` command.
20+
# SLIC_CURRENT_PROJECT_CONTAINER_PATH=/var/www/html/wp-content/plugins/the-events-calendar
1921
# When you `here` at the site level, all selected targets via `use` will have a relative path set.
2022
# SLIC_CURRENT_PROJECT_RELATIVE_PATH=
2123
# When you `use` on a supported subdirectory of a plugin, this stores the subdirectory name.

.github/workflows/publish-slic-docker-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
# The php_version is the docker tag from https://hub.docker.com/_/php/tags
20-
php_version: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
20+
php_version: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
2121
arch: [ 'amd64', 'arm64' ]
2222
# Add runner and platform info for each architecture
2323
include:
@@ -86,7 +86,7 @@ jobs:
8686
packages: write
8787
strategy:
8888
matrix:
89-
php_version: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
89+
php_version: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
9090
steps:
9191
- name: Log in to the Container registry
9292
uses: docker/login-action@v3

.github/workflows/publish-wordpress-docker-image.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,39 @@ jobs:
7070
runner: ubuntu-24.04-arm
7171
platform: linux/arm64
7272
arch: arm64
73-
# WordPress 6.5 with PHP 8.3 - both architectures
74-
- wp_version: '6.5'
73+
# WordPress 7.0.0 with PHP 8.3 - both architectures
74+
- wp_version: '7.0.0'
7575
php_version: '8.3'
7676
runner: ubuntu-latest
7777
platform: linux/amd64
7878
arch: amd64
79-
- wp_version: '6.5'
79+
- wp_version: '7.0.0'
8080
php_version: '8.3'
8181
runner: ubuntu-24.04-arm
8282
platform: linux/arm64
8383
arch: arm64
84+
# WordPress 7.0.0 with PHP 8.4 - both architectures
85+
- wp_version: '7.0.0'
86+
php_version: '8.4'
87+
runner: ubuntu-latest
88+
platform: linux/amd64
89+
arch: amd64
90+
- wp_version: '7.0.0'
91+
php_version: '8.4'
92+
runner: ubuntu-24.04-arm
93+
platform: linux/arm64
94+
arch: arm64
95+
# WordPress 7.0.0 with PHP 8.5 - both architectures
96+
- wp_version: '7.0.0'
97+
php_version: '8.5'
98+
runner: ubuntu-latest
99+
platform: linux/amd64
100+
arch: amd64
101+
- wp_version: '7.0.0'
102+
php_version: '8.5'
103+
runner: ubuntu-24.04-arm
104+
platform: linux/arm64
105+
arch: arm64
84106

85107
steps:
86108
- name: Checkout repository
@@ -147,6 +169,8 @@ jobs:
147169
- php_version: '7.3'
148170
- php_version: '7.4'
149171
- php_version: '8.3'
172+
- php_version: '8.4'
173+
- php_version: '8.5'
150174
steps:
151175
- name: Log in to the Container registry
152176
uses: docker/login-action@v3

README.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The slic (**S**tellarWP **L**ocal **I**nteractive **C**ontainers) CLI command pr
2424
* [Xdebug and `slic`](#xdebug-and-slic)
2525
* [Configuring IDEs for Xdebug](/docs/xdebug.md)
2626
* [Releasing a new version of `slic`](/CONTRIBUTING.md)
27+
* [Agent Skills (AI-assisted testing)](#agent-skills-ai-assisted-testing)
2728
* [Update guide](#update-guide)
2829
* [From 1.0 to 2.0](#from-10-to-20)
2930

@@ -118,9 +119,41 @@ slic here
118119

119120
![slic here](docs/images/slic-here.gif)
120121

121-
#### 2. WordPress Directory
122+
#### 2. Themes Directory
122123

123-
The second option is to navigate to the root of your site (likely where `wp-config.php` lives) and run the `slic here`
124+
If you are developing a **theme**, run `slic here` from your themes directory. `slic` will detect that it is pointed at a themes directory and correctly:
125+
126+
- Mount the directory as `wp-content/themes/` in the Docker stack so your theme is available to WordPress as a real theme.
127+
- Keep a separate plugins directory (`SLIC_PLUGINS_DIR`) so dependencies like WooCommerce install into `wp-content/plugins/` and not into your themes directory.
128+
- Run Codeception from within the correct `wp-content/themes/<theme>` path inside the container.
129+
130+
Example:
131+
132+
```bash
133+
# Change to your themes directory
134+
cd /path/to/your/wp-content/themes
135+
136+
slic here
137+
slic use my-theme
138+
slic run wpunit
139+
```
140+
141+
> **WPLoader suite config:** When testing a theme, activate it via the WPLoader `theme:` key rather than listing it under `plugins`/`activatePlugins`. WordPress will then load the theme (including its `functions.php`) automatically.
142+
>
143+
> ```yaml
144+
> modules:
145+
> config:
146+
> WPLoader:
147+
> plugins:
148+
> - woocommerce/woocommerce.php
149+
> activatePlugins:
150+
> - woocommerce/woocommerce.php
151+
> theme: my-theme # ← activates the theme under test
152+
> ```
153+
154+
#### 3. WordPress Directory
155+
156+
The third option is to navigate to the root of your site (likely where `wp-config.php` lives) and run the `slic here`
124157
command.
125158
126159
> Note: This is an opinionated option and there are some assumptions that are made:
@@ -359,6 +392,42 @@ When using these commands, `slic` will prompt you to restart the containers.
359392
- `xon` - Enable Xdebug
360393
- `xoff` - Disable Xdebug
361394
395+
## Agent Skills (AI-assisted testing)
396+
397+
This repository includes an [Agent Skill](https://agentskills.io) in `skills/slic/` that teaches AI coding assistants (Claude Code, Cursor, Copilot, Gemini CLI, and [30+ other tools](https://agentskills.io)) how to create and run WordPress integration tests with slic.
398+
399+
### What it provides
400+
401+
The skill gives agents structured context about:
402+
403+
- The slic CLI workflow (`here`, `use`, `init`, `run`, `shell`)
404+
- WPUnit test structure, naming conventions, and namespaces
405+
- `setUp()` / `tearDown()` environment tiers (minimal, standard, full isolation)
406+
- HTTP mocking patterns for WordPress (`pre_http_request` filter)
407+
- Assertion helpers and WordPress test factories
408+
- Advanced patterns (REST API dispatch, Reflection, custom tables)
409+
- An 11-item test isolation checklist for preventing flaky tests
410+
411+
### How agents discover it
412+
413+
Agent Skills-compatible tools discover the skill automatically when working inside this repository or any project that references it. The entry point is `skills/slic/SKILL.md`, which links to detailed sub-documents that agents load on demand.
414+
415+
For manual installation in other projects, use the [skills CLI](https://agentskills.io):
416+
417+
```bash
418+
# Install globally (available to all projects):
419+
npx skills add stellarwp/slic -g
420+
421+
# Install for a specific project:
422+
npx skills add stellarwp/slic
423+
424+
# Install for a specific agent:
425+
npx skills add stellarwp/slic --agent cursor
426+
427+
# List available skills before installing:
428+
npx skills add stellarwp/slic --list
429+
```
430+
362431
## Update Guide
363432
364433
This guide covers the steps needed when upgrading `slic` between major versions.

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [2.2.0] - 2026-05-29
8+
- Added - First-class theme support for `slic here`, `slic use`, `slic using`, and `slic run`, including auto-detection when running `slic here` from a `themes` directory with a sibling `plugins` directory.
9+
- Added - Agent Skills documentation in `skills/slic/` for AI-assisted WordPress integration test creation, debugging, and slic workflow guidance.
10+
- Added - PHP 8.4 and 8.5 Docker image support for slic and WordPress 7.0, compiling `uopz` from source for PHP 8.4+ because the PECL release does not build against PHP 8.4.
11+
- Changed - PHP 8.3 WordPress images now use WordPress 7.0.0.
12+
- Changed - Docker builds now resolve upstream official PHP and WordPress base images from Amazon ECR Public by default to avoid Docker Hub pull rate limits.
13+
- Fixed - Theme targets now resolve to `SLIC_THEMES_DIR` when running tests and build/install prompts instead of assuming all targets live in `SLIC_PLUGINS_DIR`.
14+
- Fixed - `slic run` now repairs stale or incomplete WordPress `.htaccess` rewrite blocks in the configured `SLIC_WP_DIR`, preventing Apache-level 404s for pretty REST API URLs.
15+
716
# [2.1.8] - 2026-03-11
817
- Fixed - Add missing `igbinary` and `redis` PHP extensions to the slic and WordPress Dockerfiles.
918

containers/slic/Dockerfile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
ARG PHP_VERSION=7.4
2+
ARG PHP_IMAGE_REPOSITORY=public.ecr.aws/docker/library/php
23

34
# Source Composer 1 and 2 from the respective images, multi-stage builds.
45
FROM ghcr.io/composer/docker:1 AS composer1
56
FROM ghcr.io/composer/docker:2 AS composer2
67

7-
FROM php:${PHP_VERSION}
8+
FROM ${PHP_IMAGE_REPOSITORY}:${PHP_VERSION}
89

910
ARG NODE_VERSION=18.17.0
1011
ARG NVM_VERSION=v0.40.1
1112
ARG IPE_GD_WITHOUTAVIF=1
13+
ARG UOPZ_SOURCE_REF=14c8fc2d6eff14ec9acd926b9cab85d6961c64ac
1214
ARG TARGETPLATFORM
1315

1416
SHELL ["/bin/bash", "-eou", "pipefail", "-c"]
@@ -30,12 +32,6 @@ ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/do
3032

3133
RUN chmod a+rx /usr/local/bin/wp /usr/local/bin/install-php-extensions
3234

33-
# -------------------------------
34-
# PHP extensions (heavy compilation step with cache mount)
35-
# -------------------------------
36-
RUN --mount=type=cache,target=/tmp/ipe-cache,sharing=locked \
37-
install-php-extensions xdebug pdo pdo_mysql mysqli zip uopz pcntl sockets intl exif gd igbinary redis
38-
3935
# -------------------------------
4036
# System dependencies (with cache mount for speed)
4137
# -------------------------------
@@ -52,6 +48,25 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
5248
mkdir -p $NVM_DIR/cache /cache /composer-cache && \
5349
chmod a+rwx $NVM_DIR/cache /cache /composer-cache
5450

51+
# -------------------------------
52+
# PHP extensions (heavy compilation step with cache mount)
53+
# -------------------------------
54+
RUN --mount=type=cache,target=/tmp/ipe-cache,sharing=locked \
55+
install-php-extensions xdebug pdo pdo_mysql mysqli zip pcntl sockets intl exif gd igbinary redis && \
56+
if php -r 'exit(PHP_VERSION_ID >= 80400 ? 0 : 1);'; then \
57+
git clone --depth 1 https://github.com/krakjoe/uopz.git /tmp/uopz-src && \
58+
cd /tmp/uopz-src && \
59+
git fetch --depth 1 origin "${UOPZ_SOURCE_REF}" && \
60+
git checkout --detach FETCH_HEAD && \
61+
phpize && \
62+
./configure && \
63+
make -j"$(nproc)" && \
64+
make install && \
65+
rm -rf /tmp/uopz-src; \
66+
else \
67+
install-php-extensions uopz; \
68+
fi
69+
5570
# -------------------------------
5671
# Install NVM
5772
# -------------------------------

containers/wordpress/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
ARG WORDPRESS_IMAGE_VERSION=wordpress/apache
1+
ARG WORDPRESS_IMAGE_REPOSITORY=public.ecr.aws/docker/library/wordpress
22
ARG PHP_VERSION=7.4
33
ARG WP_VERSION=6.1
44

5-
FROM wordpress:${WP_VERSION}-php${PHP_VERSION}-apache
5+
FROM ${WORDPRESS_IMAGE_REPOSITORY}:${WP_VERSION}-php${PHP_VERSION}-apache
66

77
# -------------------------------
88
# Environment variables

skills/slic/SKILL.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: slic
3+
description: >-
4+
Guide for creating, modifying, and running WPUnit integration tests with
5+
slic (StellarWP Local Interactive Containers). Covers slic workflow, test
6+
structure, environment setup, HTTP mocking, WordPress factories, assertions,
7+
and Codeception/wp-browser patterns. Use when writing or debugging WordPress
8+
plugin integration tests.
9+
license: MIT
10+
compatibility: Requires Docker and slic CLI on PATH
11+
metadata:
12+
author: stellarwp
13+
version: "1.0"
14+
---
15+
16+
# slic — WPUnit Integration Testing Guide
17+
18+
## When to use this skill
19+
20+
Activate this skill when:
21+
22+
- Writing new WPUnit integration tests for a WordPress plugin or theme
23+
- Modifying or debugging existing Codeception/wp-browser tests
24+
- Running test suites through slic (the `slic run` workflow)
25+
- Setting up a project for slic-based testing for the first time
26+
- Diagnosing flaky or order-dependent test failures
27+
28+
## Quick-start workflow
29+
30+
slic orchestrates Docker containers (MariaDB, Redis, WordPress, Chrome, and a Codeception runner) so you never configure a local test environment manually.
31+
32+
### 1. Point slic at your code
33+
34+
```bash
35+
# From a plugins directory (e.g. wp-content/plugins):
36+
slic here
37+
38+
# Or from a full WordPress root (where wp-config.php lives):
39+
slic here
40+
```
41+
42+
### 2. Select the target project
43+
44+
```bash
45+
slic use my-plugin
46+
47+
# Subdirectory targets are supported:
48+
slic use event-tickets/common
49+
```
50+
51+
### 3. Initialize (first time only)
52+
53+
```bash
54+
slic init my-plugin
55+
```
56+
57+
This generates three files in the plugin root:
58+
59+
| File | Purpose |
60+
|------|---------|
61+
| `.env.testing.slic` | Database credentials, WordPress URL, container paths |
62+
| `codeception.slic.yml` | Loads `.env.testing.slic` as Codeception params |
63+
| `test-config.slic.php` | Optional WPLoader custom configuration |
64+
65+
### 4. Run tests
66+
67+
```bash
68+
slic run # all suites, sequentially
69+
slic run wpunit # one suite
70+
slic run tests/wpunit/FooTest.php # one file
71+
slic run tests/wpunit/FooTest::test_something # one method
72+
```
73+
74+
### 5. Interactive shell (optional)
75+
76+
```bash
77+
slic shell
78+
# Inside the container:
79+
> cr wpunit # shorthand for codecept run
80+
```
81+
82+
## Test creation rules
83+
84+
When creating or modifying a test file, follow these rules:
85+
86+
1. **Extend `WPTestCase`** — every WPUnit test class extends `\Codeception\TestCase\WPTestCase` (wp-browser v3) or `lucatume\WPBrowser\TestCase\WPTestCase` (wp-browser v4).
87+
2. **Use the AAA pattern** — Arrange, Act, Assert. Keep each section visually distinct.
88+
3. **Name clearly** — file: `<DescriptiveName>Test.php`; methods: `test_<what_it_verifies>` (preferred over `@test` annotations).
89+
4. **Isolate** — every test must pass in any order. Clean up in `tearDown()`.
90+
5. **Use factories** — prefer `$this->factory()->post->create()` over raw SQL or `wp_insert_post()` in test setup.
91+
6. **Follow WordPress coding standards** — tabs for indentation, spaces inside parentheses.
92+
93+
See [test-anatomy.md](test-anatomy.md) for the complete file skeleton and naming rules.
94+
95+
## Environment setup tiers
96+
97+
Choose the right level of setUp/tearDown for your test:
98+
99+
| Tier | When to use | Guide |
100+
|------|------------|-------|
101+
| Minimal | Tests that only need WordPress loaded | [environment-setup.md](environment-setup.md#tier-1-minimal) |
102+
| Standard | Tests that create posts, users, or terms | [environment-setup.md](environment-setup.md#tier-2-standard-with-factories) |
103+
| Full isolation | Tests that mock HTTP, change globals, or modify options | [environment-setup.md](environment-setup.md#tier-3-full-isolation) |
104+
105+
## Testing patterns
106+
107+
| Pattern | Guide |
108+
|---------|-------|
109+
| HTTP mocking (3 approaches) | [http-mocking.md](http-mocking.md) |
110+
| Assertions and WordPress factories | [assertions.md](assertions.md) |
111+
| REST dispatch, Reflection, custom tables | [advanced-patterns.md](advanced-patterns.md) |
112+
| Test isolation checklist (11 items) | [test-isolation-checklist.md](test-isolation-checklist.md) |
113+
114+
## Verification workflow
115+
116+
After writing or modifying tests, follow this sequence:
117+
118+
1. **Write the code** under test (or confirm it exists).
119+
2. **Create or update tests** following the patterns above.
120+
3. **Run the targeted test**`slic run tests/wpunit/YourTest.php`.
121+
4. **Run the full suite**`slic run wpunit` — to catch side effects.
122+
5. **Fix any failures** and re-run.
123+
6. **Verify isolation** — run the single test again to confirm it passes independently.
124+
7. **Check the [isolation checklist](test-isolation-checklist.md)** before committing.
125+
126+
## Reference material
127+
128+
| Topic | File |
129+
|-------|------|
130+
| Complete slic CLI command reference | [references/slic-commands.md](references/slic-commands.md) |
131+
| Installation, setup, env files, CI | [references/slic-setup.md](references/slic-setup.md) |
132+
| WPLoader config and WPTestCase API | [references/wp-browser-wploader.md](references/wp-browser-wploader.md) |
133+
134+
## External resources
135+
136+
- [slic repository](https://github.com/stellarwp/slic)
137+
- [wp-browser documentation](https://wpbrowser.wptestkit.dev/)
138+
- [Codeception documentation](https://codeception.com/docs/Introduction)
139+
- [WordPress PHPUnit test utilities](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/)

0 commit comments

Comments
 (0)