8000 bug #28592 [BrowserKit] throw exception when request() wasn't called … · symfony/symfony@3afe4e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3afe4e7

Browse files
bug #28592 [BrowserKit] throw exception when request() wasn't called (xabbuh)
This PR was merged into the 4.2-dev branch. Discussion ---------- [BrowserKit] throw exception when request() wasn't called | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | #27807 (comment) Commits ------- 41cfde1 throw exception when request() wasn't called
2 parents d5e3f2f + 41cfde1 commit 3afe4e7

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