Skip to content

Commit 52f4a57

Browse files
committed
docs: remove <?php in sample code
1 parent 6dfc38b commit 52f4a57

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

user_guide_src/source/testing/response.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from your test cases. Usually a ``TestResponse`` will be provided for you as a r
88
create 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()
2829
You can access directly the Request object, if it was set during testing:
2930

3031
.. literalinclude:: response/002.php
32+
:lines: 2-
3133

3234
response()
3335
----------
3436

3537
This allows you direct access to the response object:
3638

3739
.. literalinclude:: response/003.php
40+
:lines: 2-
3841

3942
Checking Response Status
4043
========================
@@ -46,27 +49,31 @@ Returns a boolean true/false based on whether the response is perceived to be "o
4649
a 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

5054
assertOK()
5155
----------
5256

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

5762
isRedirect()
5863
------------
5964

6065
Returns a boolean true/false based on whether the response is a redirected response.
6166

6267
.. literalinclude:: response/006.php
68+
:lines: 2-
6369

6470
assertRedirect()
6571
----------------
6672

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

7178
assertRedirectTo()
7279
------------------
@@ -75,20 +82,23 @@ Asserts that the Response is an instance of RedirectResponse and the destination
7582
matches the uri given.
7683

7784
.. literalinclude:: response/008.php
85+
:lines: 2-
7886

7987
getRedirectUrl()
8088
----------------
8189

8290
Returns the URL set for a RedirectResponse, or null for failure.
8391

8492
.. literalinclude:: response/009.php
93+
:lines: 2-
8594

8695
assertStatus(int $code)
8796
-----------------------
8897

8998
Asserts that the HTTP status code returned matches $code.
9099

91100
.. literalinclude:: response/010.php
101+
:lines: 2-
92102

93103
Session Assertions
94104
==================
@@ -100,13 +110,15 @@ Asserts that a value exists in the resulting session. If $value is passed, will
100110
matches what was specified.
101111

102112
.. literalinclude:: response/011.php
113+
:lines: 2-
103114

104115
assertSessionMissing(string $key)
105116
---------------------------------
106117

107118
Asserts that the resulting session does not include the specified $key.
108119

109120
.. literalinclude:: response/012.php
121+
:lines: 2-
110122

111123
Header Assertions
112124
=================
@@ -118,13 +130,15 @@ Asserts that a header named ``$key`` exists in the response. If ``$value`` is no
118130
the values match.
119131

120132
.. literalinclude:: response/013.php
133+
:lines: 2-
121134

122135
assertHeaderMissing(string $key)
123136
--------------------------------
124137

125138
Asserts that a header name ``$key`` does not exist in the response.
126139

127140
.. literalinclude:: response/014.php
141+
:lines: 2-
128142

129143
Cookie Assertions
130144
=================
@@ -136,13 +150,15 @@ Asserts that a cookie named ``$key`` exists in the response. If ``$value`` is no
136150
the 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

140155
assertCookieMissing(string $key)
141156
--------------------------------
142157

143158
Asserts that a cookie named ``$key`` does not exist in the response.
144159

145160
.. literalinclude:: response/016.php
161+
:lines: 2-
146162

147163
assertCookieExpired(string $key, string $prefix = '')
148164
-----------------------------------------------------
@@ -151,6 +167,7 @@ Asserts that a cookie named ``$key`` exists, but has expired. You can set the co
151167
in as the second parameter.
152168

153169
.. literalinclude:: response/017.php
170+
:lines: 2-
154171

155172
DOM Helpers
156173
===========
@@ -165,10 +182,12 @@ The ``see()`` method checks the text on the page to see if it exists either by i
165182
a tag, as specified by type, class, or id:
166183

167184
.. literalinclude:: response/018.php
185+
:lines: 2-
168186

169187
The ``dontSee()`` method is the exact opposite:
170188

171189
.. literalinclude:: response/019.php
190+
:lines: 2-
172191

173192
seeElement()
174193
------------
@@ -177,27 +196,31 @@ The ``seeElement()`` and ``dontSeeElement()`` are very similar to the previous m
177196
values of the elements. Instead, they simply check that the elements exist on the page:
178197

179198
.. literalinclude:: response/020.php
199+
:lines: 2-
180200

181201
seeLink()
182202
---------
183203

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

188209
seeInField()
189210
------------
190211

191212
The ``seeInField()`` method checks for any input tags exist with the name and value:
192213

193214
.. literalinclude:: response/022.php
215+
:lines: 2-
194216

195217
seeCheckboxIsChecked()
196218
----------------------
197219

198220
Finally, you can check if a checkbox exists and is checked with the ``seeCheckboxIsChecked()`` method:
199221

200222
.. literalinclude:: response/023.php
223+
:lines: 2-
201224

202225
DOM Assertions
203226
==============
@@ -212,20 +235,23 @@ Asserts that text/HTML is on the page, either by itself or - more specifically -
212235
a tag, as specified by type, class, or id:
213236

214237
.. literalinclude:: response/024.php
238+
:lines: 2-
215239

216240
assertDontSee(string $search = null, string $element = null)
217241
------------------------------------------------------------
218242

219243
Asserts the exact opposite of the ``assertSee()`` method:
220244

221245
.. literalinclude:: response/025.php
246+
:lines: 2-
222247

223248
assertSeeElement(string $search)
224249
--------------------------------
225250

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

230256
assertDontSeeElement(string $search)
231257
------------------------------------
@@ -234,20 +260,23 @@ Similar to ``assertSee()``, however this only checks for an existing element tha
234260
specific text:
235261

236262
.. literalinclude:: response/027.php
263+
:lines: 2-
237264

238265
assertSeeLink(string $text, string $details = null)
239266
---------------------------------------------------
240267

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

245273
assertSeeInField(string $field, string $value = null)
246274
-----------------------------------------------------
247275

248276
Asserts that an input tag exists with the name and value:
249277

250278
.. literalinclude:: response/029.php
279+
:lines: 2-
251280

252281
Working with JSON
253282
=================
@@ -261,10 +290,12 @@ getJSON()
261290
This method will return the body of the response as a JSON string:
262291

263292
.. literalinclude:: response/030.php
293+
:lines: 2-
264294

265295
You 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)
274305
Asserts 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

278310
assertJSONExact($test)
279311
----------------------

0 commit comments

Comments
 (0)