Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c921ad

Browse files
authored
Merge pull request symfony#90 from dunglas/fix-createGoutte
Fix createGoutteClient signature. Document how to use custom servers.
2 parents 08952ce + 1231687 commit 8c921ad

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ to authenticate to an external SSO server, do I want to access the kernel of the
9797
<?php
9898

9999
use Symfony\Component\Panther\PantherTestCase;
100+
use Symfony\Component\Panther\Client;
100101

101102
class E2eTest extends PantherTestCase
102103
{
@@ -105,9 +106,13 @@ class E2eTest extends PantherTestCase
105106
$symfonyClient = static::createClient(); // A cute kitty: the Symfony's functional test too
106107
$goutteClient = static::createGoutteClient(); // An agile lynx: Goutte
107108
$pantherClient = static::createPantherClient(); // A majestic Panther
108-
109109
// Both Goutte and Panther benefits from the built-in HTTP server
110-
110+
111+
$customChromeClient = Client::createChromeClient(null, null, [], 'https://example.com'); // Create a custom Chrome client
112+
$customSeleniumClient = Client::createSeleniumClient('http://127.0.0.1:4444/wd/hub', null, 'https://example.com'); // Create a custom Selenium client
113+
// When initializing a custom client, the integrated web server IS NOT started automatically.
114+
// Use PantherTestCase::startWebServer() or WebServerManager if you want to start it manually.
115+
111116
// enjoy the same API for the 3 felines
112117
// $*client->request('GET', '...')
113118

@@ -177,6 +182,7 @@ php:
177182
script:
178183
- phpunit
179184
```
185+
180186
## AppVeyor Integration
181187
182188
Panther will work out of the box with AppVeyor as long as Google Chrome is installed. Here is a minimal `appveyor.yml`

src/PantherTestCaseTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ protected static function createPantherClient(string $hostname = '127.0.0.1', in
9898
return self::$pantherClient;
9999
}
100100

101-
protected static function createGoutteClient(): GoutteClient
101+
protected static function createGoutteClient(string $hostname = '127.0.0.1', int $port = 9000): GoutteClient
102102
{
103103
if (!\class_exists(GoutteClient::class)) {
104104
throw new \RuntimeException('Goutte is not installed. Run "composer req fabpot/goutte".');
105105
}
106106

107-
self::startWebServer();
107+
self::startWebServer(null, $hostname, $port);
108108
if (null === self::$goutteClient) {
109109
$goutteClient = new GoutteClient();
110110
$goutteClient->setClient(new GuzzleClient(['base_uri' => self::$baseUri]));

0 commit comments

Comments
 (0)