Skip to content

Commit c0b6917

Browse files
committed
Minor tweaks
1 parent 05f6035 commit c0b6917

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

AGENTS.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,59 @@ When contributing to this package, please adhere to the following guidelines:
1111
* **Write Tests:** All new features and bug fixes must be accompanied by acceptance tests using Behat. You can find the existing tests in the `features/` directory. There may be PHPUnit unit tests as well in the `tests/` directory.
1212
* **Update Documentation:** If your changes affect the user-facing functionality, please update the relevant inline code documentation.
1313

14-
## Building and running
14+
### Building and running
1515

1616
Before submitting any changes, it is crucial to validate them by running the full suite of static code analysis and tests. Tu run the full suite of checks, execute the following command: `composer test`.
1717

1818
This single command ensures that your changes meet all the quality gates of the project. While you can run the individual steps separately, it is highly recommended to use this single command to ensure a comprehensive validation.
1919

20-
## Writing Tests
20+
### Useful Composer Commands
2121

22-
When writing tests, aim to follow existing patterns. Key conventions include:
22+
The project uses Composer to manage dependencies and run scripts. The following commands are available:
2323

24-
* When adding tests, first examine existing tests to understand and conform to established conventions.
25-
* For unit tests, extend the base `WP_CLI\Tests\TestCase` test class.
24+
* `composer install`: Install dependencies.
25+
* `composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
26+
* `composer lint`: Check for syntax errors.
27+
* `composer phpcs`: Check for code style violations.
28+
* `composer phpcbf`: Automatically fix code style violations.
29+
* `composer phpstan`: Run static analysis.
30+
* `composer phpunit`: Run unit tests.
31+
* `composer behat`: Run behavior-driven tests.
32+
33+
### Coding Style
34+
35+
The project follows the `WP_CLI_CS` coding standard, which is enforced by PHP_CodeSniffer. The configuration can be found in `phpcs.xml.dist`. Before submitting any code, please run `composer phpcs` to check for violations and `composer phpcbf` to automatically fix them.
36+
37+
## Documentation
38+
39+
The `README.md` file might be generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). In that case, changes need to be made against the corresponding part of the codebase.
40+
41+
### Inline Documentation
2642

27-
## Comments policy
2843
Only write high-value comments if at all. Avoid talking to the user through comments.
2944

30-
## Useful Composer Commands
45+
## Testing
46+
47+
The project has a comprehensive test suite that includes unit tests, behavior-driven tests, and static analysis.
3148

32-
Here are some useful Composer commands for this package:
49+
* **Unit tests** are written with PHPUnit and can be found in the `tests/` directory. The configuration is in `phpunit.xml.dist`.
50+
* **Behavior-driven tests** are written with Behat and can be found in the `features/` directory. The configuration is in `behat.yml`.
51+
* **Static analysis** is performed with PHPStan.
3352

34-
* `composer behat`: Run Behat acceptance tests.
35-
* `composer behat-rerun`: Re-run all Behat tests that failed in a previous run.
36-
* `composer lint`: Lint PHP files for syntax errors.
37-
* `composer phpcs`: Run PHP CodeSniffer to ensure adherence to coding style.
38-
* `composer phpcbf`: Try to automatically fix PHPCS errors.
39-
* `composer phpunit`: Run PHPUnit unit tests if there are any in the package.
40-
* `composer test`: Run lint, PHPCS, phpunit, and Behat all at once.
53+
All tests are run on GitHub Actions for every pull request.
54+
55+
When writing tests, aim to follow existing patterns. Key conventions include:
56+
57+
* When adding tests, first examine existing tests to understand and conform to established conventions.
58+
* For unit tests, extend the base `WP_CLI\Tests\TestCase` test class.
4159

42-
## Behat Steps
60+
### Behat Steps
4361

4462
WP-CLI makes use of a Behat-based testing framework and provides a set of custom step definitions to write feature tests.
4563

46-
> **Note:** If you are expecting an error output in a test, you need to use `When I try ...`, because `When I run ...` will assert a successful exit status.
64+
> **Note:** If you are expecting an error output in a test, you need to use `When I try ...` instead of `When I run ...` .
4765
48-
## Given
66+
#### Given
4967

5068
* `Given an empty directory` - Creates an empty directory.
5169
* `Given /^an? (empty|non-existent) ([^\s]+) directory$/` - Creates or deletes a specific directory.
@@ -73,14 +91,14 @@ WP-CLI makes use of a Behat-based testing framework and provides a set of custom
7391
* `Given a PHP built-in web server` - Start a PHP built-in web server in the current directory.
7492
* `Given a PHP built-in web server to serve :subdir` - Start a PHP built-in web server in the given subdirectory.
7593

76-
## When
94+
#### When
7795

7896
* ``When /^I launch in the background `([^`]+)`$/`` - Launch a given command in the background.
7997
* ``When /^I (run|try) `([^`]+)`$/`` - Run or try a given command.
8098
* ``When /^I (run|try) `([^`]+)` from '([^\s]+)'$/`` - Run or try a given command in a subdirectory.
8199
* `When /^I (run|try) the previous command again$/` - Run or try the previous command again.
82100

83-
## Then
101+
#### Then
84102

85103
* `Then /^the return code should( not)? be (\d+)$/` - Expect a specific exit code of the previous command.
86104
* `Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/` - Check the contents of STDOUT or STDERR.

0 commit comments

Comments
 (0)