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