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: CONTRIBUTING.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,3 +106,51 @@ Using [robiningelbrecht/phpunit-coverage-tools](https://github.com/robiningelbre
106
106
This percentage should be increased over time to just below whatever the current coverage is.
107
107
108
108
To run a code coverage test, use the same procedure for phpunit but add this argument: `--coverage-text=/dev/stdout`
109
+
110
+
### LDAP cleanliness
111
+
112
+
Any test that makes changes to LDAP must clean up after itself using `try`/`finally`.
113
+
When a test fails to clean up after itself, it can cause other tests to fail or become otherwise un-useful.
114
+
Because LDAP may not always be clean, any test that relies on a certain LDAP state should `assert` everything about that state.
115
+
To reset LDAP to a clean slate, just re-run the `build.sh` script.
116
+
117
+
Note: `phpunit` can misbehave when using `expectException` and `try`/`finally`, see https://github.com/UnityHPC/unity-web-portal/issues/258.
118
+
119
+
### creating the conditions for a test
120
+
121
+
Selecting users for tests happens with the `get...User...` family of functions from `phpunit-bootstrap.php`.
122
+
Since this family of functions is growing large and their names long and complicated, it is better to start with a simpler state and create the desired conditions manually.
123
+
For example, rather than using `getUserWithOneKey`, use `getUserHasNoSSHKeys` and add one key for them.
124
+
125
+
The LDAP entries available in the dev environment are defined in `tools/docker-dev/identity/bootstrap.ldif`.
126
+
These entries may be subject to change.
127
+
Only `phpunit-bootstrap.php` should have hard-coded references to these entries.
128
+
129
+
### testing the HTTP API
130
+
131
+
When writing a test, it may be tempting to use the PHP API directly, but the HTTP API must also be tested.
0 commit comments