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 | https://github.com/symfony/symfony/pull/27807#issuecomment-420985940
Commits
-------
41cfde19f6
throw exception when request() wasn't called
This commit is contained in:
commit
3afe4e7b84
@ -297,7 +297,11 @@ abstract class Client
|
||||
*/
|
||||
public function clickLink(string $linkText): Crawler
|
||||
{
|
||||
return $this->click($this->getCrawler()->selectLink($linkText)->link());
|
||||
if (null === $this->crawler) {
|
||||
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
|
||||
}
|
||||
|
||||
return $this->click($this->crawler->selectLink($linkText)->link());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,7 +336,11 @@ abstract class Client
|
||||
*/
|
||||
public function submitForm(string $button, array $fieldValues = array(), string $method = 'POST', array $serverParameters = array()): Crawler
|
||||
{
|
||||
$buttonNode = $this->getCrawler()->selectButton($button);
|
||||
if (null === $this->crawler) {
|
||||
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
|
||||
}
|
||||
|
||||
$buttonNode = $this->crawler->selectButton($button);
|
||||
$form = $buttonNode->form($fieldValues, $method);
|
||||
|
||||
return $this->submit($form, array(), $serverParameters);
|
||||
|
Reference in New Issue
Block a user