You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+38-20Lines changed: 38 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,41 +11,59 @@ When contributing to this package, please adhere to the following guidelines:
11
11
***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.
12
12
***Update Documentation:** If your changes affect the user-facing functionality, please update the relevant inline code documentation.
13
13
14
-
## Building and running
14
+
###Building and running
15
15
16
16
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`.
17
17
18
18
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.
19
19
20
-
##Writing Tests
20
+
### Useful Composer Commands
21
21
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:
23
23
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.
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
26
42
27
-
## Comments policy
28
43
Only write high-value comments if at all. Avoid talking to the user through comments.
29
44
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.
31
48
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.
33
52
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.
41
59
42
-
## Behat Steps
60
+
###Behat Steps
43
61
44
62
WP-CLI makes use of a Behat-based testing framework and provides a set of custom step definitions to write feature tests.
45
63
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 ...` .
47
65
48
-
## Given
66
+
####Given
49
67
50
68
*`Given an empty directory` - Creates an empty directory.
51
69
*`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
73
91
*`Given a PHP built-in web server` - Start a PHP built-in web server in the current directory.
74
92
*`Given a PHP built-in web server to serve :subdir` - Start a PHP built-in web server in the given subdirectory.
75
93
76
-
## When
94
+
####When
77
95
78
96
*``When /^I launch in the background `([^`]+)`$/`` - Launch a given command in the background.
79
97
*``When /^I (run|try) `([^`]+)`$/`` - Run or try a given command.
80
98
*``When /^I (run|try) `([^`]+)` from '([^\s]+)'$/`` - Run or try a given command in a subdirectory.
81
99
*`When /^I (run|try) the previous command again$/` - Run or try the previous command again.
82
100
83
-
## Then
101
+
####Then
84
102
85
103
*`Then /^the return code should( not)? be (\d+)$/` - Expect a specific exit code of the previous command.
86
104
*`Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/` - Check the contents of STDOUT or STDERR.
0 commit comments