Skip to content

Commit f47f3f6

Browse files
committed
docs: make method names linkable
1 parent a127fb8 commit f47f3f6

1 file changed

Lines changed: 52 additions & 26 deletions

File tree

user_guide_src/source/testing/response.rst

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ there are a number of new assertions that you can use in your tests.
2222
Accessing Request/Response
2323
==========================
2424

25-
**request()**
25+
request()
26+
---------
2627

2728
You 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

3335
This allows you direct access to the response object:
3436

@@ -37,45 +39,52 @@ This allows you direct access to the response object:
3739
Checking Response Status
3840
========================
3941

40-
**isOK()**
42+
isOK()
43+
------
4144

4245
Returns a boolean true/false based on whether the response is perceived to be "ok". This is primarily determined by
4346
a 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

4953
This 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

5560
Returns 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

6167
Asserts 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

6774
Asserts that the Response is an instance of RedirectResponse and the destination
6875
matches the uri given.
6976

7077
.. literalinclude:: response/008.php
7178

72-
**getRedirectUrl()**
79+
getRedirectUrl()
80+
----------------
7381

7482
Returns 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

8089
Asserts that the HTTP status code returned matches $code.
8190

@@ -84,14 +93,16 @@ Asserts that the HTTP status code returned matches $code.
8493
Session Assertions
8594
==================
8695

87-
**assertSessionHas(string $key, $value = null)**
96+
assertSessionHas(string $key, $value = null)
97+
--------------------------------------------
8898

8999
Asserts that a value exists in the resulting session. If $value is passed, will also assert that the variable's value
90100
matches what was specified.
91101

92102
.. literalinclude:: response/011.php
93103

94-
**assertSessionMissing(string $key)**
104+
assertSessionMissing(string $key)
105+
---------------------------------
95106

96107
Asserts 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.
100111
Header Assertions
101112
=================
102113

103-
**assertHeader(string $key, $value = null)**
114+
assertHeader(string $key, $value = null)
115+
----------------------------------------
104116

105117
Asserts that a header named **$key** exists in the response. If **$value** is not empty, will also assert that
106118
the values match.
107119

108120
.. literalinclude:: response/013.php
109121

110-
**assertHeaderMissing(string $key)**
122+
assertHeaderMissing(string $key)
123+
--------------------------------
111124

112125
Asserts 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.
116129
Cookie Assertions
117130
=================
118131

119-
**assertCookie(string $key, $value = null, string $prefix = '')**
132+
assertCookie(string $key, $value = null, string $prefix = '')
133+
-------------------------------------------------------------
120134

121135
Asserts that a cookie named **$key** exists in the response. If **$value** is not empty, will also assert that
122136
the 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

128143
Asserts 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

134150
Asserts that a cookie named **$key** exists, but has expired. You can set the cookie prefix, if needed, by passing it
135151
in as the second parameter.
@@ -189,39 +205,45 @@ DOM Assertions
189205
You can perform tests to see if specific elements/text/etc exist with the body of the response with the following
190206
assertions.
191207

192-
**assertSee(string $search = null, string $element = null)**
208+
assertSee(string $search = null, string $element = null)
209+
--------------------------------------------------------
193210

194211
Asserts that text/HTML is on the page, either by itself or - more specifically - within
195212
a 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

201219
Asserts the exact opposite of the **assertSee()** method:
202220

203221
.. literalinclude:: response/025.php
204222

205-
**assertSeeElement(string $search)**
223+
assertSeeElement(string $search)
224+
--------------------------------
206225

207226
Similar 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

213233
Similar to **assertSee()**, however this only checks for an existing element that is missing. It does not check for
214234
specific text:
215235

216236
.. literalinclude:: response/027.php
217237

218-
**assertSeeLink(string $text, string $details=null)**
238+
assertSeeLink(string $text, string $details = null)
239+
---------------------------------------------------
219240

220241
Asserts 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

226248
Asserts that an input tag exists with the name and value:
227249

@@ -233,7 +255,8 @@ Working With JSON
233255
Responses will frequently contain JSON responses, especially when working with API methods. The following methods
234256
can help to test the responses.
235257

236-
**getJSON()**
258+
getJSON()
259+
---------
237260

238261
This 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

250274
Asserts 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

256281
Similar to **assertJSONFragment()**, but checks the entire JSON response to ensure exact matches.
257282

258283
Working With XML
259284
================
260285

261-
**getXML()**
286+
getXML()
287+
--------
262288

263289
If your application returns XML, you can retrieve it through this method.

0 commit comments

Comments
 (0)