@@ -22,13 +22,15 @@ there are a number of new assertions that you can use in your tests.
2222Accessing Request/Response
2323==========================
2424
25- **request() **
25+ request()
26+ ---------
2627
2728You can access directly the Request object, if it was set during testing:
2829
2930.. literalinclude :: response/002.php
3031
31- **response() **
32+ response()
33+ ----------
3234
3335This allows you direct access to the response object:
3436
@@ -37,45 +39,52 @@ This allows you direct access to the response object:
3739Checking Response Status
3840========================
3941
40- **isOK() **
42+ isOK()
43+ ------
4144
4245Returns a boolean true/false based on whether the response is perceived to be "ok". This is primarily determined by
4346a response status code in the 200 or 300's. An empty body is not considered valid, unless in redirects.
4447
4548.. literalinclude :: response/004.php
4649
47- **assertOK() **
50+ assertOK()
51+ ----------
4852
4953This assertion simply uses the **isOK() ** method to test a response. **assertNotOK ** is the inverse of this assertion.
5054
5155.. literalinclude :: response/005.php
5256
53- **isRedirect() **
57+ isRedirect()
58+ ------------
5459
5560Returns a boolean true/false based on whether the response is a redirected response.
5661
5762.. literalinclude :: response/006.php
5863
59- **assertRedirect() **
64+ assertRedirect()
65+ ----------------
6066
6167Asserts that the Response is an instance of RedirectResponse. **assertNotRedirect ** is the inverse of this assertion.
6268
6369.. literalinclude :: response/007.php
6470
65- **assertRedirectTo() **
71+ assertRedirectTo()
72+ ------------------
6673
6774Asserts that the Response is an instance of RedirectResponse and the destination
6875matches the uri given.
6976
7077.. literalinclude :: response/008.php
7178
72- **getRedirectUrl() **
79+ getRedirectUrl()
80+ ----------------
7381
7482Returns the URL set for a RedirectResponse, or null for failure.
7583
7684.. literalinclude :: response/009.php
7785
78- **assertStatus(int $code) **
86+ assertStatus(int $code)
87+ -----------------------
7988
8089Asserts that the HTTP status code returned matches $code.
8190
@@ -84,14 +93,16 @@ Asserts that the HTTP status code returned matches $code.
8493Session Assertions
8594==================
8695
87- **assertSessionHas(string $key, $value = null) **
96+ assertSessionHas(string $key, $value = null)
97+ --------------------------------------------
8898
8999Asserts that a value exists in the resulting session. If $value is passed, will also assert that the variable's value
90100matches what was specified.
91101
92102.. literalinclude :: response/011.php
93103
94- **assertSessionMissing(string $key) **
104+ assertSessionMissing(string $key)
105+ ---------------------------------
95106
96107Asserts that the resulting session does not include the specified $key.
97108
@@ -100,14 +111,16 @@ Asserts that the resulting session does not include the specified $key.
100111Header Assertions
101112=================
102113
103- **assertHeader(string $key, $value = null) **
114+ assertHeader(string $key, $value = null)
115+ ----------------------------------------
104116
105117Asserts that a header named **$key ** exists in the response. If **$value ** is not empty, will also assert that
106118the values match.
107119
108120.. literalinclude :: response/013.php
109121
110- **assertHeaderMissing(string $key) **
122+ assertHeaderMissing(string $key)
123+ --------------------------------
111124
112125Asserts that a header name **$key ** does not exist in the response.
113126
@@ -116,20 +129,23 @@ Asserts that a header name **$key** does not exist in the response.
116129Cookie Assertions
117130=================
118131
119- **assertCookie(string $key, $value = null, string $prefix = '') **
132+ assertCookie(string $key, $value = null, string $prefix = '')
133+ -------------------------------------------------------------
120134
121135Asserts that a cookie named **$key ** exists in the response. If **$value ** is not empty, will also assert that
122136the values match. You can set the cookie prefix, if needed, by passing it in as the third parameter.
123137
124138.. literalinclude :: response/015.php
125139
126- **assertCookieMissing(string $key) **
140+ assertCookieMissing(string $key)
141+ --------------------------------
127142
128143Asserts that a cookie named **$key ** does not exist in the response.
129144
130145.. literalinclude :: response/016.php
131146
132- **assertCookieExpired(string $key, string $prefix = '') **
147+ assertCookieExpired(string $key, string $prefix = '')
148+ -----------------------------------------------------
133149
134150Asserts that a cookie named **$key ** exists, but has expired. You can set the cookie prefix, if needed, by passing it
135151in as the second parameter.
@@ -189,39 +205,45 @@ DOM Assertions
189205You can perform tests to see if specific elements/text/etc exist with the body of the response with the following
190206assertions.
191207
192- **assertSee(string $search = null, string $element = null) **
208+ assertSee(string $search = null, string $element = null)
209+ --------------------------------------------------------
193210
194211Asserts that text/HTML is on the page, either by itself or - more specifically - within
195212a tag, as specified by type, class, or id:
196213
197214.. literalinclude :: response/024.php
198215
199- **assertDontSee(string $search = null, string $element = null) **
216+ assertDontSee(string $search = null, string $element = null)
217+ ------------------------------------------------------------
200218
201219Asserts the exact opposite of the **assertSee() ** method:
202220
203221.. literalinclude :: response/025.php
204222
205- **assertSeeElement(string $search) **
223+ assertSeeElement(string $search)
224+ --------------------------------
206225
207226Similar to **assertSee() **, however this only checks for an existing element. It does not check for specific text:
208227
209228.. literalinclude :: response/026.php
210229
211- **assertDontSeeElement(string $search) **
230+ assertDontSeeElement(string $search)
231+ ------------------------------------
212232
213233Similar to **assertSee() **, however this only checks for an existing element that is missing. It does not check for
214234specific text:
215235
216236.. literalinclude :: response/027.php
217237
218- **assertSeeLink(string $text, string $details=null) **
238+ assertSeeLink(string $text, string $details = null)
239+ ---------------------------------------------------
219240
220241Asserts that an anchor tag is found with matching **$text ** as the body of the tag:
221242
222243.. literalinclude :: response/028.php
223244
224- **assertSeeInField(string $field, string $value=null) **
245+ assertSeeInField(string $field, string $value = null)
246+ -----------------------------------------------------
225247
226248Asserts that an input tag exists with the name and value:
227249
@@ -233,7 +255,8 @@ Working With JSON
233255Responses will frequently contain JSON responses, especially when working with API methods. The following methods
234256can help to test the responses.
235257
236- **getJSON() **
258+ getJSON()
259+ ---------
237260
238261This method will return the body of the response as a JSON string:
239262
@@ -245,19 +268,22 @@ You can use this method to determine if ``$response`` actually holds JSON conten
245268
246269.. note :: Be aware that the JSON string will be pretty-printed in the result.
247270
248- **assertJSONFragment(array $fragment) **
271+ assertJSONFragment(array $fragment)
272+ -----------------------------------
249273
250274Asserts that $fragment is found within the JSON response. It does not need to match the entire JSON value.
251275
252276.. literalinclude :: response/032.php
253277
254- **assertJSONExact($test) **
278+ assertJSONExact($test)
279+ ----------------------
255280
256281Similar to **assertJSONFragment() **, but checks the entire JSON response to ensure exact matches.
257282
258283Working With XML
259284================
260285
261- **getXML() **
286+ getXML()
287+ --------
262288
263289If your application returns XML, you can retrieve it through this method.
0 commit comments