Skip to content

Commit e4ecc70

Browse files
authored
GH#940: docs(agents): expand bash:other guidance for WP test suite, npm build, and PHP one-liners (#941)
1 parent 97fd08b commit e4ecc70

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,40 @@ If `php` is not available, omit the `php -d ...` prefix and call `vendor/bin/php
308308
**Syntax error in one-liner** — when constructing a PHP or bash one-liner, test with `bash -n`
309309
(syntax check) or `php -l` before running. A typo in a bash heredoc or PHP string will cause
310310
`bash:other`.
311+
312+
**WordPress test suite not installed**`vendor/bin/phpunit` requires a WordPress test
313+
environment. Without it, it fails with database connection errors or missing `bootstrap.php`
314+
messages. Install it once with:
315+
316+
```bash
317+
bash bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host]
318+
# Example: bash bin/install-wp-tests.sh wordpress_test root root localhost
319+
```
320+
321+
The test environment is installed to `/tmp/wordpress-tests-lib` and `/tmp/wordpress` by default.
322+
Check it exists before running the test suite:
323+
324+
```bash
325+
ls /tmp/wordpress-tests-lib/includes/bootstrap.php 2>/dev/null || echo "WP test suite not installed — run bin/install-wp-tests.sh first"
326+
```
327+
328+
**`npm run build` is a release command, not a dev command** — the `build` script runs
329+
minification, pot-file generation, and an encryption step (`encrypt-secrets.php`). Running it
330+
outside a release context will fail or produce unexpected output. For routine development
331+
quality checks, use:
332+
333+
```bash
334+
npm run check # lint (phpcs + eslint + stylelint) + phpstan + phpunit
335+
npm run lint # lint only
336+
npm run stan # phpstan only
337+
npm test # phpunit only (equivalent to vendor/bin/phpunit)
338+
```
339+
340+
**PHP functions unavailable in one-liners** — WordPress functions (`add_filter`, `apply_filters`,
341+
`get_option`, etc.) are not available in bare `php -r` one-liners. They require WordPress to be
342+
bootstrapped. Use WP-CLI for WordPress-context commands instead:
343+
344+
```bash
345+
wp eval 'echo get_option("blogname");' # correct — WP context available
346+
php -r 'echo get_option("blogname");' # wrong — fatal: Call to undefined function
347+
```

0 commit comments

Comments
 (0)