throw exception when request() wasn't called
This commit is contained in:
parent
5dadd95dea
commit
41cfde19f6
@ -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