|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of the phpunit-mink library. |
| 4 | + * For the full copyright and license information, please view |
| 5 | + * the LICENSE file that was distributed with this source code. |
| 6 | + * |
| 7 | + * @copyright Alexander Obuhovich <aik.bold@gmail.com> |
| 8 | + * @link https://github.com/aik099/phpunit-mink |
| 9 | + */ |
| 10 | + |
| 11 | + |
| 12 | +namespace aik099\PHPUnit\MinkDriver; |
| 13 | + |
| 14 | + |
| 15 | +use aik099\PHPUnit\BrowserConfiguration\BrowserConfiguration; |
| 16 | + |
| 17 | +class WebdriverClassicFactory extends AbstractDriverFactory |
| 18 | +{ |
| 19 | + |
| 20 | + /** |
| 21 | + * Returns driver name, that can be used in browser configuration. |
| 22 | + * |
| 23 | + * @return string |
| 24 | + */ |
| 25 | + public function getDriverName() |
| 26 | + { |
| 27 | + return 'webdriver-classic'; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @inheritDoc |
| 32 | + */ |
| 33 | + public function getDriverPackageUrl() |
| 34 | + { |
| 35 | + return 'https://packagist.org/packages/mink/webdriver-classic-driver'; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Returns default values for browser configuration. |
| 40 | + * |
| 41 | + * @return array |
| 42 | + */ |
| 43 | + public function getDriverDefaults() |
| 44 | + { |
| 45 | + return array( |
| 46 | + 'port' => 4444, |
| 47 | + 'driverOptions' => array(), |
| 48 | + ); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * @inheritDoc |
| 53 | + */ |
| 54 | + public function createDriver(BrowserConfiguration $browser) |
| 55 | + { |
| 56 | + $this->assertInstalled('Mink\WebdriverClassicDriver\WebdriverClassicDriver'); |
| 57 | + |
| 58 | + $browser_name = $browser->getBrowserName(); |
| 59 | + $capabilities = $browser->getDesiredCapabilities(); |
| 60 | + $capabilities['browserName'] = $browser_name; |
| 61 | + |
| 62 | + // TODO: Maybe doesn't work! |
| 63 | + ini_set('default_socket_timeout', $browser->getTimeout()); |
| 64 | + |
| 65 | + $driver = new \Mink\WebdriverClassicDriver\WebdriverClassicDriver( |
| 66 | + $browser_name, |
| 67 | + $capabilities, |
| 68 | + 'http://' . $browser->getHost() . ':' . $browser->getPort() . '/wd/hub' |
| 69 | + ); |
| 70 | + |
| 71 | + return $driver; |
| 72 | + } |
| 73 | + |
| 74 | +} |
0 commit comments