@@ -8,6 +8,7 @@ from your test cases. Usually a ``TestResponse`` will be provided for you as a r
88create your own directly using any ``ResponseInterface ``:
99
1010.. literalinclude :: response/001.php
11+ :lines: 2-
1112
1213.. contents ::
1314 :local:
@@ -28,13 +29,15 @@ request()
2829You can access directly the Request object, if it was set during testing:
2930
3031.. literalinclude :: response/002.php
32+ :lines: 2-
3133
3234response()
3335----------
3436
3537This allows you direct access to the response object:
3638
3739.. literalinclude :: response/003.php
40+ :lines: 2-
3841
3942Checking Response Status
4043========================
@@ -46,27 +49,31 @@ Returns a boolean true/false based on whether the response is perceived to be "o
4649a response status code in the 200 or 300's. An empty body is not considered valid, unless in redirects.
4750
4851.. literalinclude :: response/004.php
52+ :lines: 2-
4953
5054assertOK()
5155----------
5256
5357This assertion simply uses the ``isOK() `` method to test a response. ``assertNotOK() `` is the inverse of this assertion.
5458
5559.. literalinclude :: response/005.php
60+ :lines: 2-
5661
5762isRedirect()
5863------------
5964
6065Returns a boolean true/false based on whether the response is a redirected response.
6166
6267.. literalinclude :: response/006.php
68+ :lines: 2-
6369
6470assertRedirect()
6571----------------
6672
6773Asserts that the Response is an instance of RedirectResponse. ``assertNotRedirect() `` is the inverse of this assertion.
6874
6975.. literalinclude :: response/007.php
76+ :lines: 2-
7077
7178assertRedirectTo()
7279------------------
@@ -75,20 +82,23 @@ Asserts that the Response is an instance of RedirectResponse and the destination
7582matches the uri given.
7683
7784.. literalinclude :: response/008.php
85+ :lines: 2-
7886
7987getRedirectUrl()
8088----------------
8189
8290Returns the URL set for a RedirectResponse, or null for failure.
8391
8492.. literalinclude :: response/009.php
93+ :lines: 2-
8594
8695assertStatus(int $code)
8796-----------------------
8897
8998Asserts that the HTTP status code returned matches $code.
9099
91100.. literalinclude :: response/010.php
101+ :lines: 2-
92102
93103Session Assertions
94104==================
@@ -100,13 +110,15 @@ Asserts that a value exists in the resulting session. If $value is passed, will
100110matches what was specified.
101111
102112.. literalinclude :: response/011.php
113+ :lines: 2-
103114
104115assertSessionMissing(string $key)
105116---------------------------------
106117
107118Asserts that the resulting session does not include the specified $key.
108119
109120.. literalinclude :: response/012.php
121+ :lines: 2-
110122
111123Header Assertions
112124=================
@@ -118,13 +130,15 @@ Asserts that a header named ``$key`` exists in the response. If ``$value`` is no
118130the values match.
119131
120132.. literalinclude :: response/013.php
133+ :lines: 2-
121134
122135assertHeaderMissing(string $key)
123136--------------------------------
124137
125138Asserts that a header name ``$key `` does not exist in the response.
126139
127140.. literalinclude :: response/014.php
141+ :lines: 2-
128142
129143Cookie Assertions
130144=================
@@ -136,13 +150,15 @@ Asserts that a cookie named ``$key`` exists in the response. If ``$value`` is no
136150the values match. You can set the cookie prefix, if needed, by passing it in as the third parameter.
137151
138152.. literalinclude :: response/015.php
153+ :lines: 2-
139154
140155assertCookieMissing(string $key)
141156--------------------------------
142157
143158Asserts that a cookie named ``$key `` does not exist in the response.
144159
145160.. literalinclude :: response/016.php
161+ :lines: 2-
146162
147163assertCookieExpired(string $key, string $prefix = '')
148164-----------------------------------------------------
@@ -151,6 +167,7 @@ Asserts that a cookie named ``$key`` exists, but has expired. You can set the co
151167in as the second parameter.
152168
153169.. literalinclude :: response/017.php
170+ :lines: 2-
154171
155172DOM Helpers
156173===========
@@ -161,14 +178,17 @@ are useful for using within assertions in your tests.
161178see()
162179-----
163180
164- The ``see() `` method checks the text on the page to see if it exists either by itself, or more specifically within
181+ Returns a boolean true/false based on whether the text on the page exists either
182+ by itself, or more specifically within
165183a tag, as specified by type, class, or id:
166184
167185.. literalinclude :: response/018.php
186+ :lines: 2-
168187
169188The ``dontSee() `` method is the exact opposite:
170189
171190.. literalinclude :: response/019.php
191+ :lines: 2-
172192
173193seeElement()
174194------------
@@ -177,27 +197,31 @@ The ``seeElement()`` and ``dontSeeElement()`` are very similar to the previous m
177197values of the elements. Instead, they simply check that the elements exist on the page:
178198
179199.. literalinclude :: response/020.php
200+ :lines: 2-
180201
181202seeLink()
182203---------
183204
184205You can use ``seeLink() `` to ensure that a link appears on the page with the specified text:
185206
186207.. literalinclude :: response/021.php
208+ :lines: 2-
187209
188210seeInField()
189211------------
190212
191213The ``seeInField() `` method checks for any input tags exist with the name and value:
192214
193215.. literalinclude :: response/022.php
216+ :lines: 2-
194217
195218seeCheckboxIsChecked()
196219----------------------
197220
198221Finally, you can check if a checkbox exists and is checked with the ``seeCheckboxIsChecked() `` method:
199222
200223.. literalinclude :: response/023.php
224+ :lines: 2-
201225
202226DOM Assertions
203227==============
@@ -212,20 +236,23 @@ Asserts that text/HTML is on the page, either by itself or - more specifically -
212236a tag, as specified by type, class, or id:
213237
214238.. literalinclude :: response/024.php
239+ :lines: 2-
215240
216241assertDontSee(string $search = null, string $element = null)
217242------------------------------------------------------------
218243
219244Asserts the exact opposite of the ``assertSee() `` method:
220245
221246.. literalinclude :: response/025.php
247+ :lines: 2-
222248
223249assertSeeElement(string $search)
224250--------------------------------
225251
226252Similar to ``assertSee() ``, however this only checks for an existing element. It does not check for specific text:
227253
228254.. literalinclude :: response/026.php
255+ :lines: 2-
229256
230257assertDontSeeElement(string $search)
231258------------------------------------
@@ -234,20 +261,23 @@ Similar to ``assertSee()``, however this only checks for an existing element tha
234261specific text:
235262
236263.. literalinclude :: response/027.php
264+ :lines: 2-
237265
238266assertSeeLink(string $text, string $details = null)
239267---------------------------------------------------
240268
241269Asserts that an anchor tag is found with matching ``$text `` as the body of the tag:
242270
243271.. literalinclude :: response/028.php
272+ :lines: 2-
244273
245274assertSeeInField(string $field, string $value = null)
246275-----------------------------------------------------
247276
248277Asserts that an input tag exists with the name and value:
249278
250279.. literalinclude :: response/029.php
280+ :lines: 2-
251281
252282Working with JSON
253283=================
@@ -261,19 +291,22 @@ getJSON()
261291This method will return the body of the response as a JSON string:
262292
263293.. literalinclude :: response/030.php
294+ :lines: 2-
264295
265296You can use this method to determine if ``$response `` actually holds JSON content:
266297
267298.. literalinclude :: response/031.php
299+ :lines: 2-
268300
269301.. note :: Be aware that the JSON string will be pretty-printed in the result.
270302
271303assertJSONFragment(array $fragment)
272304-----------------------------------
273305
274- Asserts that $fragment is found within the JSON response. It does not need to match the entire JSON value.
306+ Asserts that `` $fragment `` is found within the JSON response. It does not need to match the entire JSON value.
275307
276308.. literalinclude :: response/032.php
309+ :lines: 2-
277310
278311assertJSONExact($test)
279312----------------------
0 commit comments