You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Client.php
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -183,20 +183,28 @@ public function getCookieJar()
183
183
/**
184
184
* Returns the current Crawler instance.
185
185
*
186
-
* @return Crawler|null A Crawler instance
186
+
* @return Crawler A Crawler instance
187
187
*/
188
188
publicfunctiongetCrawler()
189
189
{
190
+
if (null === $this->crawler) {
191
+
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
192
+
}
193
+
190
194
return$this->crawler;
191
195
}
192
196
193
197
/**
194
198
* Returns the current BrowserKit Response instance.
195
199
*
196
-
* @return Response|null A BrowserKit Response instance
200
+
* @return Response A BrowserKit Response instance
197
201
*/
198
202
publicfunctiongetInternalResponse()
199
203
{
204
+
if (null === $this->internalResponse) {
205
+
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
206
+
}
207
+
200
208
return$this->internalResponse;
201
209
}
202
210
@@ -206,22 +214,30 @@ public function getInternalResponse()
206
214
* The origin response is the response instance that is returned
207
215
* by the code that handles requests.
208
216
*
209
-
* @return object|null A response instance
217
+
* @return object A response instance
210
218
*
211
219
* @see doRequest()
212
220
*/
213
221
publicfunctiongetResponse()
214
222
{
223
+
if (null === $this->response) {
224
+
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
225
+
}
226
+
215
227
return$this->response;
216
228
}
217
229
218
230
/**
219
231
* Returns the current BrowserKit Request instance.
220
232
*
221
-
* @return Request|null A BrowserKit Request instance
233
+
* @return Request A BrowserKit Request instance
222
234
*/
223
235
publicfunctiongetInternalRequest()
224
236
{
237
+
if (null === $this->internalRequest) {
238
+
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
239
+
}
240
+
225
241
return$this->internalRequest;
226
242
}
227
243
@@ -231,12 +247,16 @@ public function getInternalRequest()
231
247
* The origin request is the request instance that is sent
232
248
* to the code that handles requests.
233
249
*
234
-
* @return object|null A Request instance
250
+
* @return object A Request instance
235
251
*
236
252
* @see doRequest()
237
253
*/
238
254
publicfunctiongetRequest()
239
255
{
256
+
if (null === $this->request) {
257
+
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', __METHOD__), E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/ClientTest.php
+44Lines changed: 44 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -94,6 +94,16 @@ public function testGetRequest()
94
94
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
95
95
}
96
96
97
+
/**
98
+
* @group legacy
99
+
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Client::getRequest()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
100
+
*/
101
+
publicfunctiontestGetRequestNull()
102
+
{
103
+
$client = newTestClient();
104
+
$this->assertNull($client->getRequest());
105
+
}
106
+
97
107
publicfunctiontestGetRequestWithXHR()
98
108
{
99
109
$client = newTestClient();
@@ -124,6 +134,16 @@ public function testGetResponse()
124
134
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request');
125
135
}
126
136
137
+
/**
138
+
* @group legacy
139
+
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Client::getResponse()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
140
+
*/
141
+
publicfunctiontestGetResponseNull()
142
+
{
143
+
$client = newTestClient();
144
+
$this->assertNull($client->getResponse());
145
+
}
146
+
127
147
publicfunctiontestGetInternalResponse()
128
148
{
129
149
$client = newTestClient();
@@ -135,6 +155,16 @@ public function testGetInternalResponse()
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Client::getInternalResponse()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
@@ -153,6 +183,16 @@ public function testGetCrawler()
153
183
$this->assertSame($crawler, $client->getCrawler(), '->getCrawler() returns the Crawler of the last request');
154
184
}
155
185
186
+
/**
187
+
* @group legacy
188
+
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Client::getCrawler()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
189
+
*/
190
+
publicfunctiontestGetCrawlerNull()
191
+
{
192
+
$client = newTestClient();
193
+
$this->assertNull($client->getCrawler());
194
+
}
195
+
156
196
publicfunctiontestRequestHttpHeaders()
157
197
{
158
198
$client = newTestClient();
@@ -720,6 +760,10 @@ public function testInternalRequest()
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Client::getInternalRequest()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
0 commit comments