10000 throw exception when request() wasn't called · symfony/symfony@41cfde1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41cfde1

Browse files
committed
throw exception when request() wasn't called
1 parent 5dadd95 commit 41cfde1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ public function click(Link $link)
297297
*/
298298
public function clickLink(string $linkText): Crawler
299299
{
300-
return $this->click($this->getCrawler()->selectLink($linkText)->link());
300+
if (null === $this->crawler) {
301+
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
302+
}
303+
304+
return $this->click($this->crawler->selectLink($linkText)->link());
301305
}
302306

303307
/**
@@ -332,7 +336,11 @@ public function submit(Form $form, array $values = array()/*, array $serverParam
332336
*/
333337
public function submitForm(string $button, array $fieldValues = array(), string $method = 'POST', array $serverParameters = array()): Crawler
334338
{
335-
$buttonNode = $this->getCrawler()->selectButton($button);
339+
if (null === $this->crawler) {
340+
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
341+
}
342+
343+
$buttonNode = $this->crawler->selectButton($button);
336344
$form = $buttonNode->form($fieldValues, $method);
337345

338346
return $this->submit($form, array(), $serverParameters);

0 commit comments

Comments
 (0)
0