@@ -25,6 +25,11 @@ trait BrowserAssertionsTrait
25
25
{
26
26
/**
27
27
* Asserts that the given cookie in the test client is set to the expected value.
28
+ *
29
+ * ```php
30
+ * <?php
31
+ * $I->assertBrowserCookieValueSame('cookie_name', 'expected_value');
32
+ * ```
28
33
*/
29
34
public function assertBrowserCookieValueSame (string $ name , string $ expectedValue , bool $ raw = false , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
30
35
{
@@ -35,6 +40,11 @@ public function assertBrowserCookieValueSame(string $name, string $expectedValue
35
40
/**
36
41
* Asserts that the test client has the specified cookie set.
37
42
* This indicates that the cookie was set by any response during the test.
43
+ *
44
+ * ```
45
+ * <?php
46
+ * $I->assertBrowserHasCookie('cookie_name');
47
+ * ```
38
48
*/
39
49
public function assertBrowserHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
40
50
{
@@ -44,6 +54,11 @@ public function assertBrowserHasCookie(string $name, string $path = '/', ?string
44
54
/**
45
55
* Asserts that the test client does not have the specified cookie set.
46
56
* This indicates that the cookie was not set by any response during the test.
57
+ *
58
+ * ```php
59
+ * <?php
60
+ * $I->assertBrowserNotHasCookie('cookie_name');
61
+ * ```
47
62
*/
48
63
public function assertBrowserNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
49
64
{
@@ -52,6 +67,11 @@ public function assertBrowserNotHasCookie(string $name, string $path = '/', ?str
52
67
53
68
/**
54
69
* Asserts that the specified request attribute matches the expected value.
70
+ *
71
+ * ```php
72
+ * <?php
73
+ * $I->assertRequestAttributeValueSame('attribute_name', 'expected_value');
74
+ * ```
55
75
*/
56
76
public function assertRequestAttributeValueSame (string $ name , string $ expectedValue , string $ message = '' ): void
57
77
{
@@ -60,6 +80,11 @@ public function assertRequestAttributeValueSame(string $name, string $expectedVa
60
80
61
81
/**
62
82
* Asserts that the specified response cookie is present and matches the expected value.
83
+ *
84
+ * ```php
85
+ * <?php
86
+ * $I->assertResponseCookieValueSame('cookie_name', 'expected_value');
87
+ * ```
63
88
*/
64
89
public function assertResponseCookieValueSame (string $ name , string $ expectedValue , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
65
90
{
@@ -69,6 +94,11 @@ public function assertResponseCookieValueSame(string $name, string $expectedValu
69
94
70
95
/**
71
96
* Asserts that the response format matches the expected format. This checks the format returned by the `Response::getFormat()` method.
97
+ *
98
+ * ```php
99
+ * <?php
100
+ * $I->assertResponseFormatSame('json');
101
+ * ```
72
102
*/
73
103
public function assertResponseFormatSame (?string $ expectedFormat , string $ message = '' ): void
74
104
{
@@ -77,6 +107,11 @@ public function assertResponseFormatSame(?string $expectedFormat, string $messag
77
107
78
108
/**
79
109
* Asserts that the specified cookie is present in the response. Optionally, it can check for a specific cookie path or domain.
110
+ *
111
+ * ```php
112
+ * <?php
113
+ * $I->assertResponseHasCookie('cookie_name');
114
+ * ```
80
115
*/
81
116
public function assertResponseHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
82
117
{
@@ -86,6 +121,11 @@ public function assertResponseHasCookie(string $name, string $path = '/', ?strin
86
121
/**
87
122
* Asserts that the specified header is available in the response.
88
123
* For example, use `assertResponseHasHeader('content-type');`.
124
+ *
125
+ * ```php
126
+ * <?php
127
+ * $I->assertResponseHasHeader('content-type');
128
+ * ```
89
129
*/
90
130
public function assertResponseHasHeader (string $ headerName , string $ message = '' ): void
91
131
{
@@ -95,6 +135,11 @@ public function assertResponseHasHeader(string $headerName, string $message = ''
95
135
/**
96
136
* Asserts that the specified header does not contain the expected value in the response.
97
137
* For example, use `assertResponseHeaderNotSame('content-type', 'application/octet-stream');`.
138
+ *
139
+ * ```php
140
+ * <?php
141
+ * $I->assertResponseHeaderNotSame('content-type', 'application/json');
142
+ * ```
98
143
*/
99
144
public function assertResponseHeaderNotSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
100
145
{
@@ -104,6 +149,11 @@ public function assertResponseHeaderNotSame(string $headerName, string $expected
104
149
/**
105
150
* Asserts that the specified header contains the expected value in the response.
106
151
* For example, use `assertResponseHeaderSame('content-type', 'application/octet-stream');`.
152
+ *
153
+ * ```php
154
+ * <?php
155
+ * $I->assertResponseHeaderSame('content-type', 'application/json');
156
+ * ```
107
157
*/
108
158
public function assertResponseHeaderSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
109
159
{
@@ -112,6 +162,11 @@ public function assertResponseHeaderSame(string $headerName, string $expectedVal
112
162
113
163
/**
114
164
* Asserts that the response was successful (HTTP status code is in the 2xx range).
165
+ *
166
+ * ```php
167
+ * <?php
168
+ * $I->assertResponseIsSuccessful();
169
+ * ```
115
170
*/
116
171
public function assertResponseIsSuccessful (string $ message = '' , bool $ verbose = true ): void
117
172
{
@@ -120,6 +175,11 @@ public function assertResponseIsSuccessful(string $message = '', bool $verbose =
120
175
121
176
/**
122
177
* Asserts that the response is unprocessable (HTTP status code is 422).
178
+ *
179
+ * ```php
180
+ * <?php
181
+ * $I->assertResponseIsUnprocessable();
182
+ * ```
123
183
*/
124
184
public function assertResponseIsUnprocessable (string $ message = '' , bool $ verbose = true ): void
125
185
{
@@ -128,6 +188,11 @@ public function assertResponseIsUnprocessable(string $message = '', bool $verbos
128
188
129
189
/**
130
190
* Asserts that the specified cookie is not present in the response. Optionally, it can check for a specific cookie path or domain.
191
+ *
192
+ * ```php
193
+ * <?php
194
+ * $I->assertResponseNotHasCookie('cookie_name');
195
+ * ```
131
196
*/
132
197
public function assertResponseNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
133
198
{
@@ -136,7 +201,11 @@ public function assertResponseNotHasCookie(string $name, string $path = '/', ?st
136
201
137
202
/**
138
203
* Asserts that the specified header is not available in the response.
139
- * For example, use `assertResponseNotHasHeader('content-type');`.
204
+ *
205
+ * ```php
206
+ * <?php
207
+ * $I->assertResponseNotHasHeader('content-type');
208
+ * ```
140
209
*/
141
210
public function assertResponseNotHasHeader (string $ headerName , string $ message = '' ): void
142
211
{
@@ -146,6 +215,12 @@ public function assertResponseNotHasHeader(string $headerName, string $message =
146
215
/**
147
216
* Asserts that the response is a redirect. Optionally, you can check the target location and status code.
148
217
* The expected location can be either an absolute or a relative path.
218
+ *
219
+ * ```php
220
+ * <?php
221
+ * // Check that '/admin' redirects to '/login' with status code 302
222
+ * $I->assertResponseRedirects('/login', 302);
223
+ * ```
149
224
*/
150
225
public function assertResponseRedirects (?string $ expectedLocation = null , ?int $ expectedCode = null , string $ message = '' , bool $ verbose = true ): void
151
226
{
@@ -165,6 +240,11 @@ public function assertResponseRedirects(?string $expectedLocation = null, ?int $
165
240
166
241
/**
167
242
* Asserts that the response status code matches the expected code.
243
+ *
244
+ * ```php
245
+ * <?php
246
+ * $I->assertResponseStatusCodeSame(200);
247
+ * ```
168
248
*/
169
249
public function assertResponseStatusCodeSame (int $ expectedCode , string $ message = '' , bool $ verbose = true ): void
170
250
{
@@ -173,6 +253,11 @@ public function assertResponseStatusCodeSame(int $expectedCode, string $message
173
253
174
254
/**
175
255
* Asserts the request matches the given route and optionally route parameters.
256
+ *
257
+ * ```php
258
+ * <?php
259
+ * $I->assertRouteSame('profile', ['id' => 123]);
260
+ * ```
176
261
*/
177
262
public function assertRouteSame (string $ expectedRoute , array $ parameters = [], string $ message = '' ): void {
178
263
$ request = $ this ->getClient ()->getRequest ();
0 commit comments