Mercurial > hg > isophonics-drupal-site
annotate vendor/behat/mink-goutte-driver/src/GoutteDriver.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 /* |
Chris@0 | 4 * This file is part of the Behat\Mink. |
Chris@0 | 5 * (c) Konstantin Kudryashov <ever.zet@gmail.com> |
Chris@0 | 6 * |
Chris@0 | 7 * For the full copyright and license information, please view the LICENSE |
Chris@0 | 8 * file that was distributed with this source code. |
Chris@0 | 9 */ |
Chris@0 | 10 |
Chris@0 | 11 namespace Behat\Mink\Driver; |
Chris@0 | 12 |
Chris@0 | 13 use Behat\Mink\Driver\Goutte\Client as ExtendedClient; |
Chris@0 | 14 use Goutte\Client; |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * Goutte driver. |
Chris@0 | 18 * |
Chris@0 | 19 * @author Konstantin Kudryashov <ever.zet@gmail.com> |
Chris@0 | 20 */ |
Chris@0 | 21 class GoutteDriver extends BrowserKitDriver |
Chris@0 | 22 { |
Chris@0 | 23 /** |
Chris@0 | 24 * Initializes Goutte driver. |
Chris@0 | 25 * |
Chris@0 | 26 * @param Client $client Goutte client instance |
Chris@0 | 27 */ |
Chris@0 | 28 public function __construct(Client $client = null) |
Chris@0 | 29 { |
Chris@0 | 30 parent::__construct($client ?: new ExtendedClient()); |
Chris@0 | 31 } |
Chris@0 | 32 |
Chris@0 | 33 /** |
Chris@0 | 34 * {@inheritdoc} |
Chris@0 | 35 */ |
Chris@0 | 36 public function setBasicAuth($user, $password) |
Chris@0 | 37 { |
Chris@0 | 38 if (false === $user) { |
Chris@0 | 39 $this->getClient()->resetAuth(); |
Chris@0 | 40 |
Chris@0 | 41 return; |
Chris@0 | 42 } |
Chris@0 | 43 |
Chris@0 | 44 $this->getClient()->setAuth($user, $password); |
Chris@0 | 45 } |
Chris@0 | 46 |
Chris@0 | 47 /** |
Chris@0 | 48 * Gets the Goutte client. |
Chris@0 | 49 * |
Chris@0 | 50 * The method is overwritten only to provide the appropriate return type hint. |
Chris@0 | 51 * |
Chris@0 | 52 * @return Client |
Chris@0 | 53 */ |
Chris@0 | 54 public function getClient() |
Chris@0 | 55 { |
Chris@0 | 56 return parent::getClient(); |
Chris@0 | 57 } |
Chris@0 | 58 |
Chris@0 | 59 /** |
Chris@0 | 60 * {@inheritdoc} |
Chris@0 | 61 */ |
Chris@0 | 62 public function reset() |
Chris@0 | 63 { |
Chris@0 | 64 parent::reset(); |
Chris@0 | 65 $this->getClient()->resetAuth(); |
Chris@0 | 66 } |
Chris@0 | 67 |
Chris@0 | 68 /** |
Chris@0 | 69 * {@inheritdoc} |
Chris@0 | 70 */ |
Chris@0 | 71 protected function prepareUrl($url) |
Chris@0 | 72 { |
Chris@0 | 73 return $url; |
Chris@0 | 74 } |
Chris@0 | 75 } |