@@ -25,6 +25,11 @@ trait BrowserAssertionsTrait
2525{
2626 /**
2727 * 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+ * ```
2833 */
2934 public function assertBrowserCookieValueSame (string $ name , string $ expectedValue , bool $ raw = false , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
3035 {
@@ -35,6 +40,11 @@ public function assertBrowserCookieValueSame(string $name, string $expectedValue
3540 /**
3641 * Asserts that the test client has the specified cookie set.
3742 * This indicates that the cookie was set by any response during the test.
43+ *
44+ * ```
45+ * <?php
46+ * $I->assertBrowserHasCookie('cookie_name');
47+ * ```
3848 */
3949 public function assertBrowserHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
4050 {
@@ -44,6 +54,11 @@ public function assertBrowserHasCookie(string $name, string $path = '/', ?string
4454 /**
4555 * Asserts that the test client does not have the specified cookie set.
4656 * 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+ * ```
4762 */
4863 public function assertBrowserNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
4964 {
@@ -52,6 +67,11 @@ public function assertBrowserNotHasCookie(string $name, string $path = '/', ?str
5267
5368 /**
5469 * Asserts that the specified request attribute matches the expected value.
70+ *
71+ * ```php
72+ * <?php
73+ * $I->assertRequestAttributeValueSame('attribute_name', 'expected_value');
74+ * ```
5575 */
5676 public function assertRequestAttributeValueSame (string $ name , string $ expectedValue , string $ message = '' ): void
5777 {
@@ -60,6 +80,11 @@ public function assertRequestAttributeValueSame(string $name, string $expectedVa
6080
6181 /**
6282 * 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+ * ```
6388 */
6489 public function assertResponseCookieValueSame (string $ name , string $ expectedValue , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
6590 {
@@ -69,6 +94,11 @@ public function assertResponseCookieValueSame(string $name, string $expectedValu
6994
7095 /**
7196 * 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+ * ```
72102 */
73103 public function assertResponseFormatSame (?string $ expectedFormat , string $ message = '' ): void
74104 {
@@ -77,6 +107,11 @@ public function assertResponseFormatSame(?string $expectedFormat, string $messag
77107
78108 /**
79109 * 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+ * ```
80115 */
81116 public function assertResponseHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
82117 {
@@ -86,6 +121,11 @@ public function assertResponseHasCookie(string $name, string $path = '/', ?strin
86121 /**
87122 * Asserts that the specified header is available in the response.
88123 * For example, use `assertResponseHasHeader('content-type');`.
124+ *
125+ * ```php
126+ * <?php
127+ * $I->assertResponseHasHeader('content-type');
128+ * ```
89129 */
90130 public function assertResponseHasHeader (string $ headerName , string $ message = '' ): void
91131 {
@@ -95,6 +135,11 @@ public function assertResponseHasHeader(string $headerName, string $message = ''
95135 /**
96136 * Asserts that the specified header does not contain the expected value in the response.
97137 * For example, use `assertResponseHeaderNotSame('content-type', 'application/octet-stream');`.
138+ *
139+ * ```php
140+ * <?php
141+ * $I->assertResponseHeaderNotSame('content-type', 'application/json');
142+ * ```
98143 */
99144 public function assertResponseHeaderNotSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
100145 {
@@ -104,6 +149,11 @@ public function assertResponseHeaderNotSame(string $headerName, string $expected
104149 /**
105150 * Asserts that the specified header contains the expected value in the response.
106151 * For example, use `assertResponseHeaderSame('content-type', 'application/octet-stream');`.
152+ *
153+ * ```php
154+ * <?php
155+ * $I->assertResponseHeaderSame('content-type', 'application/json');
156+ * ```
107157 */
108158 public function assertResponseHeaderSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
109159 {
@@ -112,6 +162,11 @@ public function assertResponseHeaderSame(string $headerName, string $expectedVal
112162
113163 /**
114164 * Asserts that the response was successful (HTTP status code is in the 2xx range).
165+ *
166+ * ```php
167+ * <?php
168+ * $I->assertResponseIsSuccessful();
169+ * ```
115170 */
116171 public function assertResponseIsSuccessful (string $ message = '' , bool $ verbose = true ): void
117172 {
@@ -120,6 +175,11 @@ public function assertResponseIsSuccessful(string $message = '', bool $verbose =
120175
121176 /**
122177 * Asserts that the response is unprocessable (HTTP status code is 422).
178+ *
179+ * ```php
180+ * <?php
181+ * $I->assertResponseIsUnprocessable();
182+ * ```
123183 */
124184 public function assertResponseIsUnprocessable (string $ message = '' , bool $ verbose = true ): void
125185 {
@@ -128,6 +188,11 @@ public function assertResponseIsUnprocessable(string $message = '', bool $verbos
128188
129189 /**
130190 * 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+ * ```
131196 */
132197 public function assertResponseNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
133198 {
@@ -136,7 +201,11 @@ public function assertResponseNotHasCookie(string $name, string $path = '/', ?st
136201
137202 /**
138203 * 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+ * ```
140209 */
141210 public function assertResponseNotHasHeader (string $ headerName , string $ message = '' ): void
142211 {
@@ -146,6 +215,12 @@ public function assertResponseNotHasHeader(string $headerName, string $message =
146215 /**
147216 * Asserts that the response is a redirect. Optionally, you can check the target location and status code.
148217 * 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+ * ```
149224 */
150225 public function assertResponseRedirects (?string $ expectedLocation = null , ?int $ expectedCode = null , string $ message = '' , bool $ verbose = true ): void
151226 {
@@ -165,6 +240,11 @@ public function assertResponseRedirects(?string $expectedLocation = null, ?int $
165240
166241 /**
167242 * Asserts that the response status code matches the expected code.
243+ *
244+ * ```php
245+ * <?php
246+ * $I->assertResponseStatusCodeSame(200);
247+ * ```
168248 */
169249 public function assertResponseStatusCodeSame (int $ expectedCode , string $ message = '' , bool $ verbose = true ): void
170250 {
@@ -173,6 +253,11 @@ public function assertResponseStatusCodeSame(int $expectedCode, string $message
173253
174254 /**
175255 * Asserts the request matches the given route and optionally route parameters.
256+ *
257+ * ```php
258+ * <?php
259+ * $I->assertRouteSame('profile', ['id' => 123]);
260+ * ```
176261 */
177262 public function assertRouteSame (string $ expectedRoute , array $ parameters = [], string $ message = '' ): void {
178263 $ request = $ this ->getClient ()->getRequest ();
0 commit comments