@@ -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===========
@@ -165,10 +182,12 @@ The ``see()`` method checks the text on the page to see if it exists either by i
165182a tag, as specified by type, class, or id:
166183
167184.. literalinclude :: response/018.php
185+ :lines: 2-
168186
169187The ``dontSee() `` method is the exact opposite:
170188
171189.. literalinclude :: response/019.php
190+ :lines: 2-
172191
173192seeElement()
174193------------
@@ -177,27 +196,31 @@ The ``seeElement()`` and ``dontSeeElement()`` are very similar to the previous m
177196values of the elements. Instead, they simply check that the elements exist on the page:
178197
179198.. literalinclude :: response/020.php
199+ :lines: 2-
180200
181201seeLink()
182202---------
183203
184204You can use ``seeLink() `` to ensure that a link appears on the page with the specified text:
185205
186206.. literalinclude :: response/021.php
207+ :lines: 2-
187208
188209seeInField()
189210------------
190211
191212The ``seeInField() `` method checks for any input tags exist with the name and value:
192213
193214.. literalinclude :: response/022.php
215+ :lines: 2-
194216
195217seeCheckboxIsChecked()
196218----------------------
197219
198220Finally, you can check if a checkbox exists and is checked with the ``seeCheckboxIsChecked() `` method:
199221
200222.. literalinclude :: response/023.php
223+ :lines: 2-
201224
202225DOM Assertions
203226==============
@@ -212,20 +235,23 @@ Asserts that text/HTML is on the page, either by itself or - more specifically -
212235a tag, as specified by type, class, or id:
213236
214237.. literalinclude :: response/024.php
238+ :lines: 2-
215239
216240assertDontSee(string $search = null, string $element = null)
217241------------------------------------------------------------
218242
219243Asserts the exact opposite of the ``assertSee() `` method:
220244
221245.. literalinclude :: response/025.php
246+ :lines: 2-
222247
223248assertSeeElement(string $search)
224249--------------------------------
225250
226251Similar to ``assertSee() ``, however this only checks for an existing element. It does not check for specific text:
227252
228253.. literalinclude :: response/026.php
254+ :lines: 2-
229255
230256assertDontSeeElement(string $search)
231257------------------------------------
@@ -234,20 +260,23 @@ Similar to ``assertSee()``, however this only checks for an existing element tha
234260specific text:
235261
236262.. literalinclude :: response/027.php
263+ :lines: 2-
237264
238265assertSeeLink(string $text, string $details = null)
239266---------------------------------------------------
240267
241268Asserts that an anchor tag is found with matching ``$text `` as the body of the tag:
242269
243270.. literalinclude :: response/028.php
271+ :lines: 2-
244272
245273assertSeeInField(string $field, string $value = null)
246274-----------------------------------------------------
247275
248276Asserts that an input tag exists with the name and value:
249277
250278.. literalinclude :: response/029.php
279+ :lines: 2-
251280
252281Working with JSON
253282=================
@@ -261,10 +290,12 @@ getJSON()
261290This method will return the body of the response as a JSON string:
262291
263292.. literalinclude :: response/030.php
293+ :lines: 2-
264294
265295You can use this method to determine if ``$response `` actually holds JSON content:
266296
267297.. literalinclude :: response/031.php
298+ :lines: 2-
268299
269300.. note :: Be aware that the JSON string will be pretty-printed in the result.
270301
@@ -274,6 +305,7 @@ assertJSONFragment(array $fragment)
274305Asserts that $fragment is found within the JSON response. It does not need to match the entire JSON value.
275306
276307.. literalinclude :: response/032.php
308+ :lines: 2-
277309
278310assertJSONExact($test)
279311----------------------
0 commit comments