symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

Call to undefined method Goutte\Client::setClient() #291

Closed alewolf closed 4 years ago

alewolf commented 4 years ago

When I try to initiate a Goutte client like in the example

$this->client = static::createGoutteClient();

I get following error

 Symfony\Component\Debug\Exception\FatalThrowableError  : Call to undefined method Goutte\Client::setClient()

  at /Users/user/dev/websites/crawler/vendor/symfony/panther/src/PantherTestCaseTrait.php:190
    186|
    187|         self::startWebServer($options);
    188|         if (null === self::$goutteClient) {
    189|             $goutteClient = new GoutteClient();
  > 190|             $goutteClient->setClient(new GuzzleClient(['base_uri' => self::$baseUri]));
    191|
    192|             self::$goutteClient = $goutteClient;
    193|         }
    194|

This look like a bug to me. If it is not, what do I do wrong?

corocraft commented 4 years ago

I have the same problem. How did you solve it?

alewolf commented 4 years ago

@corocraft Yes. Goutte recently switched entirely using the HttpBrowser which is a component of symfony/panther. This is why the method I used above is not working anymore. The simple solution is to start using HttpBrowser directly: https://symfony.com/doc/4.4/components/browser_kit.html#making-external-http-requests

BenoitDuffez commented 4 years ago

This is not a simple replacement, unless I am mistaken. If you have a whole stack implemented over GuzzleHttp\ClientInterface, is there a drop-in replacement or do you have to reimplement everything?