@@ -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,10 @@ 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+ * $I->assertBrowserHasCookie('cookie_name');
46+ * ```
3847 */
3948 public function assertBrowserHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
4049 {
@@ -44,6 +53,11 @@ public function assertBrowserHasCookie(string $name, string $path = '/', ?string
4453 /**
4554 * Asserts that the test client does not have the specified cookie set.
4655 * 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+ * ```
4761 */
4862 public function assertBrowserNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
4963 {
@@ -52,6 +66,11 @@ public function assertBrowserNotHasCookie(string $name, string $path = '/', ?str
5266
5367 /**
5468 * Asserts that the specified request attribute matches the expected value.
69+ *
70+ * ```php
71+ * <?php
72+ * $I->assertRequestAttributeValueSame('attribute_name', 'expected_value');
73+ * ```
5574 */
5675 public function assertRequestAttributeValueSame (string $ name , string $ expectedValue , string $ message = '' ): void
5776 {
@@ -60,6 +79,11 @@ public function assertRequestAttributeValueSame(string $name, string $expectedVa
6079
6180 /**
6281 * 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+ * ```
6387 */
6488 public function assertResponseCookieValueSame (string $ name , string $ expectedValue , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
6589 {
@@ -69,6 +93,11 @@ public function assertResponseCookieValueSame(string $name, string $expectedValu
6993
7094 /**
7195 * 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+ * ```
72101 */
73102 public function assertResponseFormatSame (?string $ expectedFormat , string $ message = '' ): void
74103 {
@@ -77,6 +106,11 @@ public function assertResponseFormatSame(?string $expectedFormat, string $messag
77106
78107 /**
79108 * 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+ * ```
80114 */
81115 public function assertResponseHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
82116 {
@@ -86,6 +120,11 @@ public function assertResponseHasCookie(string $name, string $path = '/', ?strin
86120 /**
87121 * Asserts that the specified header is available in the response.
88122 * For example, use `assertResponseHasHeader('content-type');`.
123+ *
124+ * ```php
125+ * <?php
126+ * $I->assertResponseHasHeader('content-type');
127+ * ```
89128 */
90129 public function assertResponseHasHeader (string $ headerName , string $ message = '' ): void
91130 {
@@ -95,6 +134,11 @@ public function assertResponseHasHeader(string $headerName, string $message = ''
95134 /**
96135 * Asserts that the specified header does not contain the expected value in the response.
97136 * For example, use `assertResponseHeaderNotSame('content-type', 'application/octet-stream');`.
137+ *
138+ * ```php
139+ * <?php
140+ * $I->assertResponseHeaderNotSame('content-type', 'application/json');
141+ * ```
98142 */
99143 public function assertResponseHeaderNotSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
100144 {
@@ -104,6 +148,11 @@ public function assertResponseHeaderNotSame(string $headerName, string $expected
104148 /**
105149 * Asserts that the specified header contains the expected value in the response.
106150 * For example, use `assertResponseHeaderSame('content-type', 'application/octet-stream');`.
151+ *
152+ * ```php
153+ * <?php
154+ * $I->assertResponseHeaderSame('content-type', 'application/json');
155+ * ```
107156 */
108157 public function assertResponseHeaderSame (string $ headerName , string $ expectedValue , string $ message = '' ): void
109158 {
@@ -112,6 +161,11 @@ public function assertResponseHeaderSame(string $headerName, string $expectedVal
112161
113162 /**
114163 * Asserts that the response was successful (HTTP status code is in the 2xx range).
164+ *
165+ * ```php
166+ * <?php
167+ * $I->assertResponseIsSuccessful();
168+ * ```
115169 */
116170 public function assertResponseIsSuccessful (string $ message = '' , bool $ verbose = true ): void
117171 {
@@ -120,6 +174,11 @@ public function assertResponseIsSuccessful(string $message = '', bool $verbose =
120174
121175 /**
122176 * Asserts that the response is unprocessable (HTTP status code is 422).
177+ *
178+ * ```php
179+ * <?php
180+ * $I->assertResponseIsUnprocessable();
181+ * ```
123182 */
124183 public function assertResponseIsUnprocessable (string $ message = '' , bool $ verbose = true ): void
125184 {
@@ -128,6 +187,11 @@ public function assertResponseIsUnprocessable(string $message = '', bool $verbos
128187
129188 /**
130189 * 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+ * ```
131195 */
132196 public function assertResponseNotHasCookie (string $ name , string $ path = '/ ' , ?string $ domain = null , string $ message = '' ): void
133197 {
@@ -136,7 +200,11 @@ public function assertResponseNotHasCookie(string $name, string $path = '/', ?st
136200
137201 /**
138202 * 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+ * ```
140208 */
141209 public function assertResponseNotHasHeader (string $ headerName , string $ message = '' ): void
142210 {
@@ -146,6 +214,12 @@ public function assertResponseNotHasHeader(string $headerName, string $message =
146214 /**
147215 * Asserts that the response is a redirect. Optionally, you can check the target location and status code.
148216 * 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+ * ```
149223 */
150224 public function assertResponseRedirects (?string $ expectedLocation = null , ?int $ expectedCode = null , string $ message = '' , bool $ verbose = true ): void
151225 {
@@ -165,6 +239,11 @@ public function assertResponseRedirects(?string $expectedLocation = null, ?int $
165239
166240 /**
167241 * Asserts that the response status code matches the expected code.
242+ *
243+ * ```php
244+ * <?php
245+ * $I->assertResponseStatusCodeSame(200);
246+ * ```
168247 */
169248 public function assertResponseStatusCodeSame (int $ expectedCode , string $ message = '' , bool $ verbose = true ): void
170249 {
@@ -173,6 +252,11 @@ public function assertResponseStatusCodeSame(int $expectedCode, string $message
173252
174253 /**
175254 * Asserts the request matches the given route and optionally route parameters.
255+ *
256+ * ```php
257+ * <?php
258+ * $I->assertRouteSame('profile', ['id' => 123]);
259+ * ```
176260 */
177261 public function assertRouteSame (string $ expectedRoute , array $ parameters = [], string $ message = '' ): void {
178262 $ request = $ this ->getClient ()->getRequest ();
0 commit comments