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
**Warning: This package checks all routes by making real requests.**
43
43
**It is important not to execute it on production data.**
44
44
**You may unknowingly delete or modify your data or real requests on 3rd party services.**
45
-
Even if you implement some way of protecting the application from side-effect (eg. database transaction wrapping) you should never execute tests on production data.
45
+
Even if you implement some way of protecting the application from sideeffect (e.g., database transaction wrapping) you should never execute tests on production data.
46
46
47
47
### Example test class
48
48
@@ -97,19 +97,19 @@ class SmokeTest extends HttpSmokeTestCase {
97
97
98
98
## Documentation
99
99
100
-
By default the test makes request to every route without using any authentication or providing any parameters and expects the response to have HTTP status code _200 OK_.
100
+
By default, the test makes request to every route without using any authentication or providing any parameters and expects the response to have HTTP status code _200 OK_.
101
101
102
102
To change this behavior you must implement method `customizeRouteConfigs(RouteConfigCustomizer $routeConfigCustomizer)` in your test.
103
103
104
104
[`RouteConfigCustomizer`](./src/RouteConfigCustomizer.php) provides two methods for customizing individual route requests:
105
105
106
106
-`customize` accepts callback `function (RouteConfig $config, RouteInfo $info) {...}` as the only argument.
107
107
This is called with each [`RouteConfig`](./src/RouteConfig.php) along with [`RouteInfo`](./src/RouteInfo.php) collected from your router.
108
-
This method is useful when you want to define general rules for multiple routes (eg. skip all routes with name starting with underscore).
108
+
This method is useful when you want to define general rules for multiple routes (e.g., skip all routes with name starting with underscore).
109
109
-`customizeByRouteName` accepts a single route name or an array of route names as the first argument and same callback as `customize` as the second argument.
110
110
This is called with each [`RouteConfig`](./src/RouteConfig.php) along with [`RouteInfo`](./src/RouteInfo.php) with matching route name.
111
111
If matching route config is not found a [`RouteNameNotFoundException`](./src/Exception/RouteNameNotFoundException.php) is thrown.
112
-
This method is useful when you want to define rules for specific routes (eg. logging in to some secured route).
112
+
This method is useful when you want to define rules for specific routes (e.g., logging in to some secured route).
113
113
114
114
In your customizing callback you can call three methods on [`RouteConfig`](./src/RouteConfig.php) to change the tested behavior:
115
115
@@ -122,33 +122,31 @@ In your customizing callback you can call three methods on [`RouteConfig`](./src
122
122
or implement your own method using [`AuthInterface`](./src/Auth/AuthInterface.php).)
123
123
-`setParameter` specifies value of a route parameter by name.
124
124
-`addCallDuringTestExecution` adds a callback `function (RequestDataSet $requestDataSet, ContainerInterface $container) { ... }` to be called before test execution.
125
-
(Useful for code that needs to access the same instance of container as the test method, eg. adding CSRF token as a route parameter)
126
-
-`addExtraRequestDataSet` can be used to test more requests on the same route (eg. test a secured route as both logged in and anonymous user).
125
+
(Useful for code that needs to access the same instance of container as the test method, e.g., adding CSRF token as a route parameter)
126
+
-`addExtraRequestDataSet` can be used to test more requests on the same route (e.g., test a secured route as both logged in and anonymous user).
127
127
Returns [`RequestDataSet`](./src/RequestDataSet.php) that you can use the same way as the result from `changeDefaultRequestDataSet`.
128
128
All configured options will extend the values from default request data set (even when you change the default [`RequestDataSet`](./src/RequestDataSet.php) after you add the extra [`RequestDataSet`](./src/RequestDataSet.php)).
129
129
130
130
_Note: All three methods of [`RouteConfigCustomizer`](./src/RouteConfigCustomizer.php) accept `string $debugNote` as an argument._
131
131
_It is useful for describing the reasons of your configuration change because it may help you with debugging when the test fails._
132
132
133
-
Additionally you can override these methods in your implementation of [`HttpSmokeTestCase`](./src/HttpSmokeTestCase.php) to further change the test behavior:
133
+
Additionally, you can override these methods in your implementation of [`HttpSmokeTestCase`](./src/HttpSmokeTestCase.php) to further change the test behavior:
134
134
135
-
-`setUp` to change the way your kernel is booted (eg. boot it with different options).
135
+
-`setUp` to change the way your kernel is booted (e.g., boot it with different options).
136
136
-`getRouterAdapter` to change the object responsible for collecting routes from your application and generating urls.
137
137
-`createRequest` if you have specific needs about the way `Request` is created from [`RequestDataSet`](./src/RequestDataSet.php).
138
-
-`handleRequest` to customize handling `Request` in your application (eg. you can wrap it in database transaction to roll it back into original state).
138
+
-`handleRequest` to customize handling `Request` in your application (e.g., you can wrap it in database transaction to roll it back into original state).
139
139
140
-
### Annotations
140
+
### Attributes
141
141
142
-
To make smoke test configuration a little easier, you can use the annotations:
142
+
To make smoke test configuration a little easier, you can use the PHP attributes:
143
143
144
144
#### DataSet
145
145
146
-
Used for setting expected status code based on provided paramteters.
146
+
Used for setting expected status code based on provided parameters.
@@ -160,7 +158,7 @@ Used for setting expected status code based on provided paramteters.
160
158
Parameter defines value for specified parameter.
161
159
162
160
```
163
-
@Parameter(name="name", value="Batman")
161
+
new Parameter(name: 'name', value: 'Batman')
164
162
```
165
163
166
164
- arguments:
@@ -172,7 +170,7 @@ Parameter defines value for specified parameter.
172
170
Mark test as skipped
173
171
174
172
```
175
-
@Skipped()
173
+
#[Skipped]
176
174
```
177
175
178
176
You can add them directly to your controller methods. See the example in [`Shopsys\HttpSmokeTesting\Test\TestController`](./src/Test/TestController.php).
0 commit comments